Skip to content

Commit

Permalink
rooms: remove unnecessary promise nesting
Browse files Browse the repository at this point in the history
We have the release promise in an object, this is no-longer necessary.
  • Loading branch information
AndyTWF committed Nov 6, 2024
1 parent baed485 commit 3513853
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class DefaultRooms implements Rooms {
private readonly _chatApi: ChatApi;
private readonly _clientOptions: NormalizedClientOptions;
private readonly _rooms: Map<string, RoomMapEntry> = new Map<string, RoomMapEntry>();
private readonly _releasing = new Map<string, { promise: Promise<void> }>();
private readonly _releasing = new Map<string, Promise<void>>();
private readonly _logger: Logger;

/**
Expand Down Expand Up @@ -154,7 +154,7 @@ export class DefaultRooms implements Rooms {

abortController.signal.addEventListener('abort', abortListener);

releasing.promise
releasing
.then(() => {
// We aborted before resolution
if (abortController.signal.aborted) {
Expand Down Expand Up @@ -206,7 +206,7 @@ export class DefaultRooms implements Rooms {
this._logger.debug('Rooms.release(); waiting for previous release call', {
roomId,
});
return releasing.promise;
return releasing;
}

// If the room is not releasing, there is nothing else to do
Expand Down Expand Up @@ -235,7 +235,7 @@ export class DefaultRooms implements Rooms {
});

this._logger.debug('Rooms.release(); creating new release promise', { roomId, nonce: existing.nonce });
this._releasing.set(roomId, { promise: releasePromise });
this._releasing.set(roomId, releasePromise);

return releasePromise;
}
Expand Down

0 comments on commit 3513853

Please sign in to comment.