Skip to content

Commit

Permalink
fix: Add some typesafety (#919)
Browse files Browse the repository at this point in the history
Add type safety when setting spamscore

Co-authored-by: Alex Risch <[email protected]>
  • Loading branch information
alexrisch and Alex Risch authored Oct 7, 2024
1 parent 9e4555e commit 901ab7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions data/store/chatStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,11 @@ export const initChatStore = (account: string) => {
lastUpdateAt: now(),
};
Object.entries(topicSpamScores).forEach(([topic, spamScore]) => {
newState.conversations[topic].spamScore = spamScore;
newState.conversations[topic].lastUpdateAt = now();
// This is indicative of an issue, how are we setting spam scores for non existent conversations?
if (newState.conversations[topic]) {
newState.conversations[topic].spamScore = spamScore;
newState.conversations[topic].lastUpdateAt = now();
}
});
return newState;
}),
Expand Down

0 comments on commit 901ab7b

Please sign in to comment.