polfan-server-js-client 0.2.88 → 0.2.89

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polfan-server-js-client",
3
- "version": "0.2.88",
3
+ "version": "0.2.89",
4
4
  "description": "JavaScript client library for handling communication with Polfan chat server.",
5
5
  "author": "Jarosław Żak",
6
6
  "license": "MIT",
@@ -369,11 +369,15 @@ export class RoomsManager {
369
369
  }
370
370
 
371
371
  private handleMessagesRedacted(ev: MessagesRedacted): void {
372
- // Remove redacted messages from topic.lastMessage
372
+ // Remove redacted messages from topic and update metadata
373
373
  const topics = this.topics.get(ev.location.roomId);
374
- const updatedTopics: Topic[] = topics.items
375
- .filter(topic => topic.lastMessage?.id && ev.ids.includes(topic.lastMessage.id))
376
- .map(topic => ({ ...topic, lastMessage: null }));
377
- topics.set(...updatedTopics);
374
+ const topic = topics?.get(ev.location.topicId);
375
+ if (topic) {
376
+ topics.set({
377
+ ...topic,
378
+ messageCount: Math.max(topic.messageCount - ev.ids.length, 0),
379
+ lastMessage: ev.ids.includes(topic.lastMessage?.id) ? null : topic.lastMessage,
380
+ } as Topic);
381
+ }
378
382
  }
379
383
  }