1
0
Fork 0
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:
Andrew Simachev 2025-04-13 09:56:57 +02:00
parent ae661be4b1
commit d9f2a15fe4
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF

View file

@ -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;
};