Skip to content

Commit 61219bf

Browse files
authored
correctly remove the exploding timer state on gregor removal (#29174)
1 parent 2c0f090 commit 61219bf

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

shared/constants/chat2/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,7 @@ export const useChatState = Z.createZustand<State>((set, get) => {
18771877
}
18781878
} else {
18791879
// logger.info('Got push state with some exploding modes')
1880+
const activeConvs = new Set<string>()
18801881
explodingItems.forEach(i => {
18811882
try {
18821883
const {category, body} = i.item
@@ -1888,11 +1889,18 @@ export const useChatState = Z.createZustand<State>((set, get) => {
18881889
}
18891890
const _conversationIDKey = category.substring(Common.explodingModeGregorKeyPrefix.length)
18901891
const conversationIDKey = T.Chat.stringToConversationIDKey(_conversationIDKey)
1892+
activeConvs.add(conversationIDKey)
18911893
storeRegistry.getConvoState(conversationIDKey).dispatch.setExplodingMode(seconds, true)
18921894
} catch (e) {
18931895
logger.info('Error parsing exploding' + e)
18941896
}
18951897
})
1898+
// Clear any convos whose exploding mode was removed from gregor state
1899+
for (const [convKey, s] of chatStores) {
1900+
if (!activeConvs.has(convKey) && s.getState().explodingMode !== 0) {
1901+
s.getState().dispatch.setExplodingMode(0, true)
1902+
}
1903+
}
18961904
}
18971905

18981906
set(s => {

0 commit comments

Comments
 (0)