From 0c73c3380ea375565ff0cec785f4d1aa5aeaa5a7 Mon Sep 17 00:00:00 2001 From: balzack Date: Thu, 26 Sep 2024 21:21:51 -0700 Subject: [PATCH] cleanup on account remove --- app/sdk/src/api.ts | 1 - app/sdk/src/index.ts | 15 +++++---------- app/sdk/src/session.ts | 9 ++++++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/sdk/src/api.ts b/app/sdk/src/api.ts index 1df6fb00..c777c024 100644 --- a/app/sdk/src/api.ts +++ b/app/sdk/src/api.ts @@ -53,7 +53,6 @@ export interface Settings { unlockSeal(password: string): Promise; updaterSeal(password: string): Promise; forgetSeal(): Promise; - deleteAccount(): Promise; addConfigListener(ev: (config: Config) => void): void; removeConfigListener(ev: (config: Config) => void): void; diff --git a/app/sdk/src/index.ts b/app/sdk/src/index.ts index f93cc385..2b958a1c 100644 --- a/app/sdk/src/index.ts +++ b/app/sdk/src/index.ts @@ -82,32 +82,27 @@ export class DatabagSDK { public async remove(session: Session): Promise { const sessionModule = session as SessionModule; - const params = await sessionModule.close(); + const { node, secure, token } = sessionModule.getParams(); + await removeAccount(node, secure, token); + await sessionModule.close(); try { await this.store.clearLogin(); } catch(err) { this.log.error(err); } - try { - const { node, secure, token } = params; - await removeAccount(node, secure, token); - } - catch(err) { - this.log.error(err); - } } public async logout(session: Session, all: boolean): Promise { const sessionModule = session as SessionModule; - const params = await sessionModule.close(); + const { node, secure, token } = sessionModule.getParams(); + await sessionModule.close(); try { await this.store.clearLogin(); } catch(err) { this.log.error(err); } - const { node, secure, token } = params; clearLogin(node, secure, token, all).then(() => {}).catch(err => { console.log(err); }); diff --git a/app/sdk/src/session.ts b/app/sdk/src/session.ts index 005ec41f..27f4921a 100644 --- a/app/sdk/src/session.ts +++ b/app/sdk/src/session.ts @@ -100,8 +100,13 @@ export class SessionModule implements Session { private getStatus(): string { return this.status; } + + public getParams(): { node: string, secure: boolean, token: string } { + const { node, secure, token } = this; + return { node, secure, token }; + } - public async close(): Promise<{ node: string, secure: boolean, token: string }> { + public async close(): Promise { await this.content.close(); await this.attribute.close(); await this.alias.close(); @@ -110,8 +115,6 @@ export class SessionModule implements Session { await this.settings.close(); await this.stream.close(); this.connection.close(); - const { node, secure, token } = this; - return { node: node, secure: secure, token: token }; } public getSettings(): Settings {