Commit cc44f8dc authored by nanahira's avatar nanahira

update account provider interface

parent b2c925c3
......@@ -113,22 +113,22 @@ export class AccountPoolService
if (result) {
this.accountInfos.push(account);
}
await this.accountProvider.writeBack(this.accountInfos);
await this.accountProvider.writeBack(this.accountInfos, 'add', account);
return result;
}
async removeAccount(email: string) {
const index = this.accountInfos.findIndex((a) => a.email === email);
this.accountInfos.splice(index, 1);
if (index === -1) {
return false;
}
const account = this.accounts.get(email);
if (account) {
const [account] = this.accountInfos.splice(index, 1);
const state = this.accounts.get(email);
if (state) {
this.accounts.delete(email);
await account.close();
await state.close();
}
await this.accountProvider.writeBack(this.accountInfos);
await this.accountProvider.writeBack(this.accountInfos, 'remove', account);
return true;
}
......
......@@ -9,5 +9,9 @@ export class AccountProviderService {
return this.config.get<OpenAIAccount[]>('accounts');
}
async writeBack(accounts: OpenAIAccount[]) {}
async writeBack(
accounts: OpenAIAccount[],
type: 'add' | 'remove',
account: OpenAIAccount,
) {}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment