Skip to content

Commit

Permalink
Short circuit if store is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Dec 22, 2023
1 parent f1b1238 commit 470f398
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ export function createMessageContextSpecificObjectStore<T>(init: () => T) {
},
clear: (newValue?: MessageContextMap<T>): void =>
store.set(newValue ?? new MessageContextMap<T>()),
size: (): number => storeValue.size,
};
}
1 change: 1 addition & 0 deletions frontend/openchat-client/src/stores/failedMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function createFailedMessagesStore() {
}));
},
contains: (key: MessageContext, messageId: bigint): boolean => {
if (store.size() === 0) return false;
const chatState = store.get(key);
return chatState ? chatState[messageId.toString()] !== undefined : false;
},
Expand Down

0 comments on commit 470f398

Please sign in to comment.