mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
fix total counters
This commit is contained in:
parent
ae661be4b1
commit
d9f2a15fe4
1 changed files with 13 additions and 4 deletions
|
@ -156,13 +156,22 @@ class ChatStore {
|
|||
};
|
||||
|
||||
getTotalCounters (): { mentionCounter: number; messageCounter: number; } {
|
||||
const spaces = U.Space.getList();
|
||||
const ret = { mentionCounter: 0, messageCounter: 0 };
|
||||
for (const [ key, value ] of this.stateMap.entries()) {
|
||||
if (key.startsWith(J.Constant.subId.chatPreview)) {
|
||||
ret.mentionCounter += value.mentionCounter || 0;
|
||||
ret.messageCounter += value.messageCounter || 0;
|
||||
|
||||
if (!spaces.length) {
|
||||
return ret;
|
||||
};
|
||||
|
||||
for (const space of spaces) {
|
||||
const counters = this.getSpaceCounters(space.targetSpaceId);
|
||||
|
||||
if (counters) {
|
||||
ret.mentionCounter += counters.mentionCounter || 0;
|
||||
ret.messageCounter += counters.messageCounter || 0;
|
||||
};
|
||||
};
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue