polfan-server-js-client 0.2.109 → 0.2.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ interface EventMap {
8
8
  export interface UnreadSummary {
9
9
  mentionCount: number;
10
10
  unreadTopicCount: number;
11
+ unreadRoomCount: number;
11
12
  isUnread: boolean;
12
13
  }
13
14
  export declare class FollowedTopicsManager extends EventTarget<EventMap> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polfan-server-js-client",
3
- "version": "0.2.109",
3
+ "version": "0.2.110",
4
4
  "description": "JavaScript client library for handling communication with Polfan chat server.",
5
5
  "author": "Jarosław Żak",
6
6
  "license": "MIT",
@@ -20,6 +20,7 @@ interface EventMap {
20
20
  export interface UnreadSummary {
21
21
  mentionCount: number;
22
22
  unreadTopicCount: number;
23
+ unreadRoomCount: number;
23
24
  isUnread: boolean;
24
25
  }
25
26
 
@@ -168,6 +169,7 @@ export class FollowedTopicsManager extends EventTarget<EventMap> {
168
169
 
169
170
  let mentionCount = 0;
170
171
  let unreadTopicCount = 0;
172
+ let unreadRoomCount = 0;
171
173
 
172
174
  for (const roomId of roomIds) {
173
175
  const collection = await this.getForRoom(roomId);
@@ -176,12 +178,17 @@ export class FollowedTopicsManager extends EventTarget<EventMap> {
176
178
  continue;
177
179
  }
178
180
 
181
+ let isRoomUnreadCount = false;
179
182
  for (const topic of collection.items) {
180
183
  if (targetTopicId && topic.location.topicId !== targetTopicId) {
181
184
  continue;
182
185
  }
183
186
 
184
187
  if (topic.isUnread) {
188
+ if (!isRoomUnreadCount) {
189
+ unreadRoomCount++;
190
+ isRoomUnreadCount = true;
191
+ }
185
192
  unreadTopicCount++;
186
193
  }
187
194
 
@@ -189,7 +196,7 @@ export class FollowedTopicsManager extends EventTarget<EventMap> {
189
196
  }
190
197
  }
191
198
 
192
- const result = { mentionCount, unreadTopicCount, isUnread: unreadTopicCount > 0 };
199
+ const result = { mentionCount, unreadTopicCount, unreadRoomCount, isUnread: unreadTopicCount > 0 };
193
200
  this.summariesCache.set(cacheKey, result);
194
201
 
195
202
  return result;