diff --git a/pkg/interface/src/logic/reducers/hark-update.ts b/pkg/interface/src/logic/reducers/hark-update.ts index 647c5fb0f7..7b59009abc 100644 --- a/pkg/interface/src/logic/reducers/hark-update.ts +++ b/pkg/interface/src/logic/reducers/hark-update.ts @@ -8,6 +8,7 @@ import { import { makePatDa } from "~/logic/lib/util"; import _ from "lodash"; import {StoreState} from "../store/type"; +import { BigIntOrderedMap } from '../lib/BigIntOrderedMap'; type HarkState = Pick; @@ -177,6 +178,7 @@ function unreadEach(json: any, state: HarkState) { function unreads(json: any, state: HarkState) { const data = _.get(json, 'unreads'); if(data) { + clearState(state); console.log(data); data.forEach(({ index, stats }) => { const { unreads, notifications, last } = stats; @@ -193,6 +195,29 @@ function unreads(json: any, state: HarkState) { } } +function clearState(state){ + let initialState = { + notifications: new BigIntOrderedMap(), + archivedNotifications: new BigIntOrderedMap(), + notificationsGroupConfig: [], + notificationsChatConfig: [], + notificationsGraphConfig: { + watchOnSelf: false, + mentions: false, + watching: [], + }, + unreads: { + graph: {}, + group: {} + }, + notificationsCount: 0 + }; + + Object.keys(initialState).forEach(key => { + state[key] = initialState[key]; + }); +} + function updateUnreadCount(state: HarkState, index: NotifIndex, count: (c: number) => number) { if(!('graph' in index)) { return;