polfan-server-js-client 0.2.34 → 0.2.36

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.34",
3
+ "version": "0.2.36",
4
4
  "description": "JavaScript client library for handling communication with Polfan chat server.",
5
5
  "author": "Jarosław Żak",
6
6
  "license": "MIT",
@@ -319,12 +319,21 @@ export class RoomsManager {
319
319
  const topics = this.topics.get(ev.message.location.roomId);
320
320
  const topic = topics?.get(ev.message.location.topicId);
321
321
 
322
- if (topic) {
323
- topics.set({
324
- ...topic,
325
- messageCount: topic.messageCount + 1,
326
- lastMessage: ev.message,
327
- });
322
+ if (!topic) {
323
+ return; // No topic found, nothing to update
324
+ }
325
+
326
+ const newTopic = {
327
+ ...topic,
328
+ messageCount: topic.messageCount + 1,
329
+ lastMessage: ev.message,
330
+ };
331
+
332
+ topics.set(newTopic);
333
+ const room = this.list.get(ev.message.location.roomId);
334
+
335
+ if (room.defaultTopic?.id === ev.message.location.topicId) {
336
+ this.list.set({ ...room, defaultTopic: newTopic });
328
337
  }
329
338
  }
330
339
  }
@@ -41,7 +41,7 @@ export class UsersManager {
41
41
  users.forEach(newUser => {
42
42
  const oldUser = this.users.get(newUser.id);
43
43
  if (oldUser && oldUser.online !== newUser.online) {
44
- this.onlineStatus.emit('changed', newUser);
44
+ this.onlineStatus.emit('change', newUser);
45
45
  }
46
46
  });
47
47