From 29dab70e12ed272c9c1f0cbb710b9cbfb57823b1 Mon Sep 17 00:00:00 2001 From: Martin Varmuza Date: Tue, 3 Sep 2024 08:59:26 +0200 Subject: [PATCH] chore(transport): remove duplicated fn --- packages/transport/src/sessions/background.ts | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/transport/src/sessions/background.ts b/packages/transport/src/sessions/background.ts index 99d03cb26ca..2ebe1e9e829 100644 --- a/packages/transport/src/sessions/background.ts +++ b/packages/transport/src/sessions/background.ts @@ -202,11 +202,12 @@ export class SessionsBackground extends TypedEmitter<{ } private async releaseIntent(payload: ReleaseIntentRequest) { - const path = this.getPathFromSessions({ session: payload.session }); + const pathResult = this.getPathBySession({ session: payload.session }); - if (!path) { - return this.error(ERRORS.SESSION_NOT_FOUND); + if (!pathResult.success) { + return pathResult; } + const { path } = pathResult.payload; await this.waitInQueue(); @@ -226,15 +227,6 @@ export class SessionsBackground extends TypedEmitter<{ } private getPathBySession({ session }: GetPathBySessionRequest) { - const path = this.getPathFromSessions({ session }); - if (!path) { - return this.error(ERRORS.SESSION_NOT_FOUND); - } - - return this.success({ path }); - } - - private getPathFromSessions({ session }: GetPathBySessionRequest) { let path: string | undefined; Object.keys(this.descriptors).forEach(pathKey => { if (this.descriptors[pathKey]?.session === session) { @@ -242,7 +234,11 @@ export class SessionsBackground extends TypedEmitter<{ } }); - return path; + if (!path) { + return this.error(ERRORS.SESSION_NOT_FOUND); + } + + return this.success({ path }); } private startLock() {