polfan-server-js-client 0.2.87 → 0.2.88

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.
@@ -55,4 +55,5 @@ export declare class RoomsManager {
55
55
  private handleSession;
56
56
  private handleUserUpdated;
57
57
  private handleNewMessage;
58
+ private handleMessagesRedacted;
58
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polfan-server-js-client",
3
- "version": "0.2.87",
3
+ "version": "0.2.88",
4
4
  "description": "JavaScript client library for handling communication with Polfan chat server.",
5
5
  "author": "Jarosław Żak",
6
6
  "license": "MIT",
@@ -1,5 +1,6 @@
1
1
  import {IndexedCollection, ObservableIndexedObjectCollection} from "../IndexedObjectCollection";
2
2
  import {
3
+ MessagesRedacted,
3
4
  NewMessage,
4
5
  NewTopic,
5
6
  Room, RoomDeleted,
@@ -29,6 +30,7 @@ export class RoomsManager {
29
30
  this.messages = new MessagesManager(tracker);
30
31
 
31
32
  this.tracker.client.on('NewMessage', ev => this.handleNewMessage(ev));
33
+ this.tracker.client.on('MessagesRedacted', ev => this.handleMessagesRedacted(ev));
32
34
  this.tracker.client.on('NewTopic', ev => this.handleNewTopic(ev));
33
35
  this.tracker.client.on('TopicDeleted', ev => this.handleTopicDeleted(ev));
34
36
  this.tracker.client.on('RoomJoined', ev => this.handleRoomJoined(ev));
@@ -365,4 +367,13 @@ export class RoomsManager {
365
367
  this.list.set({ ...room, defaultTopic: newTopic });
366
368
  }
367
369
  }
370
+
371
+ private handleMessagesRedacted(ev: MessagesRedacted): void {
372
+ // Remove redacted messages from topic.lastMessage
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);
378
+ }
368
379
  }