polfan-server-js-client 0.2.90 → 0.2.91

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.
@@ -5,9 +5,7 @@
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
7
  <list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Update Topic on redacted message">
8
- <change beforePath="$PROJECT_DIR$/src/state-tracker/MessagesManager.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/state-tracker/MessagesManager.ts" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/src/state-tracker/RoomMessagesHistory.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/state-tracker/RoomMessagesHistory.ts" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/src/state-tracker/RoomsManager.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/state-tracker/RoomsManager.ts" afterDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/src/state-tracker/TopicHistoryWindow.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/state-tracker/TopicHistoryWindow.ts" afterDir="false" />
11
9
  </list>
12
10
  <option name="SHOW_DIALOG" value="false" />
13
11
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -192,15 +190,7 @@
192
190
  <workItem from="1776327180094" duration="5055000" />
193
191
  <workItem from="1777136687009" duration="3369000" />
194
192
  <workItem from="1777301595900" duration="1696000" />
195
- <workItem from="1778067371586" duration="4596000" />
196
- </task>
197
- <task id="LOCAL-00040" summary="Adapt FilesClient to new files API">
198
- <option name="closed" value="true" />
199
- <created>1752752404949</created>
200
- <option name="number" value="00040" />
201
- <option name="presentableId" value="LOCAL-00040" />
202
- <option name="project" value="LOCAL" />
203
- <updated>1752752404949</updated>
193
+ <workItem from="1778067371586" duration="10579000" />
204
194
  </task>
205
195
  <task id="LOCAL-00041" summary="Adapt FilesClient to new files API">
206
196
  <option name="closed" value="true" />
@@ -586,7 +576,15 @@
586
576
  <option name="project" value="LOCAL" />
587
577
  <updated>1778069870246</updated>
588
578
  </task>
589
- <option name="localTasksCounter" value="89" />
579
+ <task id="LOCAL-00089" summary="Update Topic on redacted message">
580
+ <option name="closed" value="true" />
581
+ <created>1778076405751</created>
582
+ <option name="number" value="00089" />
583
+ <option name="presentableId" value="LOCAL-00089" />
584
+ <option name="project" value="LOCAL" />
585
+ <updated>1778076405751</updated>
586
+ </task>
587
+ <option name="localTasksCounter" value="90" />
590
588
  <servers />
591
589
  </component>
592
590
  <component name="TypeScriptGeneratedFilesManager">
@@ -767,7 +767,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
767
767
  key: "resetToLatest",
768
768
  value: function () {
769
769
  var _resetToLatest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
770
- var result;
770
+ var result, originalState;
771
771
  return _regenerator().w(function (_context) {
772
772
  while (1) switch (_context.p = _context.n) {
773
773
  case 0:
@@ -777,6 +777,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
777
777
  }
778
778
  return _context.a(2);
779
779
  case 1:
780
+ originalState = this.state;
780
781
  this.internalState.ongoing = WindowState.LATEST;
781
782
  _context.p = 2;
782
783
  _context.n = 3;
@@ -792,6 +793,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
792
793
  this._items.deleteAll(); // Directly call deleteAll to prevent event emit.
793
794
  this.addItems(result, 'tail');
794
795
  this.internalState.current = WindowState.LATEST;
796
+ this.emitChangeWithDiff(true, originalState);
795
797
  case 6:
796
798
  return _context.a(2);
797
799
  }
@@ -806,7 +808,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
806
808
  key: "fetchPrevious",
807
809
  value: function () {
808
810
  var _fetchPrevious = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
809
- var result, firstItem;
811
+ var result, originalState, firstItem;
810
812
  return _regenerator().w(function (_context2) {
811
813
  while (1) switch (_context2.p = _context2.n) {
812
814
  case 0:
@@ -816,6 +818,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
816
818
  }
817
819
  return _context2.a(2);
818
820
  case 1:
821
+ originalState = this.state;
819
822
  this.internalState.ongoing = WindowState.PAST;
820
823
  _context2.p = 2;
821
824
  _context2.n = 3;
@@ -847,12 +850,15 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
847
850
  if (this.internalState.current === WindowState.PAST) {
848
851
  this.internalState.current = WindowState.OLDEST;
849
852
  }
853
+ this.emitChangeWithDiff(false, originalState);
850
854
  return _context2.a(2);
851
855
  case 8:
852
856
  this.addItems(result, 'head');
853
857
  _context2.n = 9;
854
858
  return this.refreshFetchedState();
855
859
  case 9:
860
+ this.emitChangeWithDiff(true, originalState);
861
+ case 10:
856
862
  return _context2.a(2);
857
863
  }
858
864
  }, _callee2, this, [[2,, 4, 5]]);
@@ -866,7 +872,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
866
872
  key: "fetchNext",
867
873
  value: function () {
868
874
  var _fetchNext = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
869
- var result;
875
+ var result, originalState;
870
876
  return _regenerator().w(function (_context3) {
871
877
  while (1) switch (_context3.p = _context3.n) {
872
878
  case 0:
@@ -876,6 +882,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
876
882
  }
877
883
  return _context3.a(2);
878
884
  case 1:
885
+ originalState = this.state;
879
886
  this.internalState.ongoing = WindowState.PAST;
880
887
  _context3.p = 2;
881
888
  _context3.n = 3;
@@ -905,6 +912,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
905
912
  _context3.n = 8;
906
913
  return this.refreshFetchedState();
907
914
  case 8:
915
+ this.emitChangeWithDiff(true, originalState);
908
916
  return _context3.a(2);
909
917
  case 9:
910
918
  return _context3.a(2);
@@ -951,6 +959,8 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
951
959
  }, {
952
960
  key: "addItems",
953
961
  value: function addItems(newItems, to) {
962
+ var _this$_items,
963
+ _this2 = this;
954
964
  var result;
955
965
  if (to === 'head') {
956
966
  result = this.trimItemsArrayToLimit([].concat(TopicHistoryWindow_toConsumableArray(newItems), TopicHistoryWindow_toConsumableArray(this.items)), 'tail');
@@ -958,8 +968,21 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
958
968
  if (to === 'tail') {
959
969
  result = this.trimItemsArrayToLimit([].concat(TopicHistoryWindow_toConsumableArray(this.items), TopicHistoryWindow_toConsumableArray(newItems)), 'head');
960
970
  }
961
- this._items.deleteAll(); // Directly call deleteAll to prevent event emit.
962
- this.set.apply(this, TopicHistoryWindow_toConsumableArray(result));
971
+
972
+ // Directly calls to prevent event emit.
973
+ this._items.deleteAll();
974
+ (_this$_items = this._items).set.apply(_this$_items, TopicHistoryWindow_toConsumableArray(result.map(function (item) {
975
+ return [_this2.getId(item), item];
976
+ })));
977
+ }
978
+ }, {
979
+ key: "emitChangeWithDiff",
980
+ value: function emitChangeWithDiff(itemChanged, originalState) {
981
+ if (itemChanged || originalState !== this.state) {
982
+ this.eventTarget.emit('change', {
983
+ setItems: Array.from(this._items.items.keys())
984
+ });
985
+ }
963
986
  }
964
987
 
965
988
  /**
@@ -985,27 +1008,27 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
985
1008
  }(ObservableIndexedObjectCollection);
986
1009
  var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
987
1010
  function TopicHistoryWindow(roomId, topicId, tracker) {
988
- var _this2;
1011
+ var _this3;
989
1012
  var bindEvents = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
990
1013
  TopicHistoryWindow_classCallCheck(this, TopicHistoryWindow);
991
- _this2 = TopicHistoryWindow_callSuper(this, TopicHistoryWindow, ['id']);
1014
+ _this3 = TopicHistoryWindow_callSuper(this, TopicHistoryWindow, ['id']);
992
1015
  /**
993
1016
  * Reexported available window modes enum.
994
1017
  */
995
- TopicHistoryWindow_defineProperty(_this2, "WindowState", WindowState);
996
- _this2.roomId = roomId;
997
- _this2.topicId = topicId;
998
- _this2.tracker = tracker;
999
- _this2.internalState.traverseLock = false;
1018
+ TopicHistoryWindow_defineProperty(_this3, "WindowState", WindowState);
1019
+ _this3.roomId = roomId;
1020
+ _this3.topicId = topicId;
1021
+ _this3.tracker = tracker;
1022
+ _this3.internalState.traverseLock = false;
1000
1023
  if (bindEvents) {
1001
- _this2.tracker.client.on('NewMessage', function (ev) {
1002
- return _this2.handleNewMessage(ev);
1024
+ _this3.tracker.client.on('NewMessage', function (ev) {
1025
+ return _this3.handleNewMessage(ev);
1003
1026
  });
1004
- _this2.tracker.client.on('MessagesRedacted', function (ev) {
1005
- return _this2.handleMessagesRedacted(ev);
1027
+ _this3.tracker.client.on('MessagesRedacted', function (ev) {
1028
+ return _this3.handleMessagesRedacted(ev);
1006
1029
  });
1007
1030
  }
1008
- return _this2;
1031
+ return _this3;
1009
1032
  }
1010
1033
  TopicHistoryWindow_inherits(TopicHistoryWindow, _TraversableRemoteCol);
1011
1034
  return TopicHistoryWindow_createClass(TopicHistoryWindow, [{
@@ -1127,83 +1150,23 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1127
1150
  }));
1128
1151
  }
1129
1152
  }
1130
- }, {
1131
- key: "handleNewMessage",
1132
- value: function () {
1133
- var _handleNewMessage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(ev) {
1134
- return _regenerator().w(function (_context9) {
1135
- while (1) switch (_context9.n) {
1136
- case 0:
1137
- if ([WindowState.LATEST, WindowState.LIVE].includes(this.state) && ev.message.location.roomId === this.roomId && ev.message.location.topicId === this.topicId) {
1138
- this.addItems([ev.message], 'tail');
1139
- }
1140
- case 1:
1141
- return _context9.a(2);
1142
- }
1143
- }, _callee9, this);
1144
- }));
1145
- function handleNewMessage(_x2) {
1146
- return _handleNewMessage.apply(this, arguments);
1147
- }
1148
- return handleNewMessage;
1149
- }()
1150
- }, {
1151
- key: "handleMessagesRedacted",
1152
- value: function () {
1153
- var _handleMessagesRedacted = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(ev) {
1154
- var refTopicIds;
1155
- return _regenerator().w(function (_context0) {
1156
- while (1) switch (_context0.n) {
1157
- case 0:
1158
- if (!(ev.location.topicId !== this.topicId || ev.location.roomId !== this.roomId)) {
1159
- _context0.n = 1;
1160
- break;
1161
- }
1162
- return _context0.a(2);
1163
- case 1:
1164
- refTopicIds = this.items.filter(function (msg) {
1165
- return msg.topicRef && ev.ids.includes(msg.id);
1166
- }).map(function (msg) {
1167
- return msg.topicRef;
1168
- });
1169
- this["delete"].apply(this, TopicHistoryWindow_toConsumableArray(ev.ids));
1170
- if (!(this.length === 0)) {
1171
- _context0.n = 2;
1172
- break;
1173
- }
1174
- _context0.n = 2;
1175
- return this.resetToLatest();
1176
- case 2:
1177
- if (refTopicIds.length > 0) {
1178
- this.eventTarget.emit('reftopicsdeleted', refTopicIds);
1179
- }
1180
- case 3:
1181
- return _context0.a(2);
1182
- }
1183
- }, _callee0, this);
1184
- }));
1185
- function handleMessagesRedacted(_x3) {
1186
- return _handleMessagesRedacted.apply(this, arguments);
1187
- }
1188
- return handleMessagesRedacted;
1189
- }()
1190
1153
  }, {
1191
1154
  key: "fetchItemsAfter",
1192
1155
  value: function () {
1193
- var _fetchItemsAfter = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
1156
+ var _fetchItemsAfter = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
1194
1157
  var _this$getAt;
1195
1158
  var afterId, result;
1196
- return _regenerator().w(function (_context1) {
1197
- while (1) switch (_context1.n) {
1159
+ return _regenerator().w(function (_context9) {
1160
+ while (1) switch (_context9.n) {
1198
1161
  case 0:
1199
1162
  afterId = (_this$getAt = this.getAt(this.length - 1)) === null || _this$getAt === void 0 ? void 0 : _this$getAt.id;
1200
1163
  if (afterId) {
1201
- _context1.n = 1;
1164
+ _context9.n = 1;
1202
1165
  break;
1203
1166
  }
1204
- return _context1.a(2, null);
1167
+ return _context9.a(2, null);
1205
1168
  case 1:
1206
- _context1.n = 2;
1169
+ _context9.n = 2;
1207
1170
  return this.tracker.client.send('GetMessages', {
1208
1171
  location: {
1209
1172
  roomId: this.roomId,
@@ -1213,16 +1176,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1213
1176
  limit: this.internalState.fetchLimit
1214
1177
  });
1215
1178
  case 2:
1216
- result = _context1.v;
1179
+ result = _context9.v;
1217
1180
  if (!result.error) {
1218
- _context1.n = 3;
1181
+ _context9.n = 3;
1219
1182
  break;
1220
1183
  }
1221
1184
  throw new Error("Cannot fetch messages: ".concat(result.error.message));
1222
1185
  case 3:
1223
- return _context1.a(2, result.data.messages);
1186
+ return _context9.a(2, result.data.messages);
1224
1187
  }
1225
- }, _callee1, this);
1188
+ }, _callee9, this);
1226
1189
  }));
1227
1190
  function fetchItemsAfter() {
1228
1191
  return _fetchItemsAfter.apply(this, arguments);
@@ -1232,20 +1195,20 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1232
1195
  }, {
1233
1196
  key: "fetchItemsBefore",
1234
1197
  value: function () {
1235
- var _fetchItemsBefore = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
1198
+ var _fetchItemsBefore = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
1236
1199
  var _this$getAt2;
1237
1200
  var beforeId, result;
1238
- return _regenerator().w(function (_context10) {
1239
- while (1) switch (_context10.n) {
1201
+ return _regenerator().w(function (_context0) {
1202
+ while (1) switch (_context0.n) {
1240
1203
  case 0:
1241
1204
  beforeId = (_this$getAt2 = this.getAt(0)) === null || _this$getAt2 === void 0 ? void 0 : _this$getAt2.id;
1242
1205
  if (beforeId) {
1243
- _context10.n = 1;
1206
+ _context0.n = 1;
1244
1207
  break;
1245
1208
  }
1246
- return _context10.a(2, null);
1209
+ return _context0.a(2, null);
1247
1210
  case 1:
1248
- _context10.n = 2;
1211
+ _context0.n = 2;
1249
1212
  return this.tracker.client.send('GetMessages', {
1250
1213
  location: {
1251
1214
  roomId: this.roomId,
@@ -1255,16 +1218,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1255
1218
  limit: this.internalState.fetchLimit
1256
1219
  });
1257
1220
  case 2:
1258
- result = _context10.v;
1221
+ result = _context0.v;
1259
1222
  if (!result.error) {
1260
- _context10.n = 3;
1223
+ _context0.n = 3;
1261
1224
  break;
1262
1225
  }
1263
1226
  throw new Error("Cannot fetch messages: ".concat(result.error.message));
1264
1227
  case 3:
1265
- return _context10.a(2, result.data.messages);
1228
+ return _context0.a(2, result.data.messages);
1266
1229
  }
1267
- }, _callee10, this);
1230
+ }, _callee0, this);
1268
1231
  }));
1269
1232
  function fetchItemsBefore() {
1270
1233
  return _fetchItemsBefore.apply(this, arguments);
@@ -1274,12 +1237,12 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1274
1237
  }, {
1275
1238
  key: "fetchLatestItems",
1276
1239
  value: function () {
1277
- var _fetchLatestItems = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
1240
+ var _fetchLatestItems = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
1278
1241
  var result;
1279
- return _regenerator().w(function (_context11) {
1280
- while (1) switch (_context11.n) {
1242
+ return _regenerator().w(function (_context1) {
1243
+ while (1) switch (_context1.n) {
1281
1244
  case 0:
1282
- _context11.n = 1;
1245
+ _context1.n = 1;
1283
1246
  return this.tracker.client.send('GetMessages', {
1284
1247
  location: {
1285
1248
  roomId: this.roomId,
@@ -1288,16 +1251,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1288
1251
  limit: this.internalState.fetchLimit
1289
1252
  });
1290
1253
  case 1:
1291
- result = _context11.v;
1254
+ result = _context1.v;
1292
1255
  if (!result.error) {
1293
- _context11.n = 2;
1256
+ _context1.n = 2;
1294
1257
  break;
1295
1258
  }
1296
1259
  throw new Error("Cannot fetch messages: ".concat(result.error.message));
1297
1260
  case 2:
1298
- return _context11.a(2, result.data.messages);
1261
+ return _context1.a(2, result.data.messages);
1299
1262
  }
1300
- }, _callee11, this);
1263
+ }, _callee1, this);
1301
1264
  }));
1302
1265
  function fetchLatestItems() {
1303
1266
  return _fetchLatestItems.apply(this, arguments);
@@ -1307,16 +1270,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1307
1270
  }, {
1308
1271
  key: "getTopic",
1309
1272
  value: function () {
1310
- var _getTopic = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
1311
- return _regenerator().w(function (_context12) {
1312
- while (1) switch (_context12.n) {
1273
+ var _getTopic = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
1274
+ return _regenerator().w(function (_context10) {
1275
+ while (1) switch (_context10.n) {
1313
1276
  case 0:
1314
- _context12.n = 1;
1277
+ _context10.n = 1;
1315
1278
  return this.tracker.rooms.getTopics(this.roomId, [this.topicId]);
1316
1279
  case 1:
1317
- return _context12.a(2, _context12.v.get(this.topicId));
1280
+ return _context10.a(2, _context10.v.get(this.topicId));
1318
1281
  }
1319
- }, _callee12, this);
1282
+ }, _callee10, this);
1320
1283
  }));
1321
1284
  function getTopic() {
1322
1285
  return _getTopic.apply(this, arguments);
@@ -1326,43 +1289,43 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1326
1289
  }, {
1327
1290
  key: "getLatestMessageId",
1328
1291
  value: function () {
1329
- var _getLatestMessageId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
1292
+ var _getLatestMessageId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
1330
1293
  var _yield$this$getTopic;
1331
1294
  var _t2, _t3, _t4, _t5;
1332
- return _regenerator().w(function (_context13) {
1333
- while (1) switch (_context13.n) {
1295
+ return _regenerator().w(function (_context11) {
1296
+ while (1) switch (_context11.n) {
1334
1297
  case 0:
1335
- _context13.n = 1;
1298
+ _context11.n = 1;
1336
1299
  return this.getTopic();
1337
1300
  case 1:
1338
- _t4 = _yield$this$getTopic = _context13.v;
1301
+ _t4 = _yield$this$getTopic = _context11.v;
1339
1302
  _t3 = _t4 === null;
1340
1303
  if (_t3) {
1341
- _context13.n = 2;
1304
+ _context11.n = 2;
1342
1305
  break;
1343
1306
  }
1344
1307
  _t3 = _yield$this$getTopic === void 0;
1345
1308
  case 2:
1346
1309
  _t2 = _t3;
1347
1310
  if (_t2) {
1348
- _context13.n = 3;
1311
+ _context11.n = 3;
1349
1312
  break;
1350
1313
  }
1351
1314
  _t2 = (_yield$this$getTopic = _yield$this$getTopic.lastMessage) === null || _yield$this$getTopic === void 0;
1352
1315
  case 3:
1353
1316
  if (!_t2) {
1354
- _context13.n = 4;
1317
+ _context11.n = 4;
1355
1318
  break;
1356
1319
  }
1357
1320
  _t5 = void 0;
1358
- _context13.n = 5;
1321
+ _context11.n = 5;
1359
1322
  break;
1360
1323
  case 4:
1361
1324
  _t5 = _yield$this$getTopic.id;
1362
1325
  case 5:
1363
- return _context13.a(2, _t5);
1326
+ return _context11.a(2, _t5);
1364
1327
  }
1365
- }, _callee13, this);
1328
+ }, _callee11, this);
1366
1329
  }));
1367
1330
  function getLatestMessageId() {
1368
1331
  return _getLatestMessageId.apply(this, arguments);
@@ -1372,24 +1335,87 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1372
1335
  }, {
1373
1336
  key: "isLatestItemLoaded",
1374
1337
  value: function () {
1375
- var _isLatestItemLoaded = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
1338
+ var _isLatestItemLoaded = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
1376
1339
  var lastMessageId;
1377
- return _regenerator().w(function (_context14) {
1378
- while (1) switch (_context14.n) {
1340
+ return _regenerator().w(function (_context12) {
1341
+ while (1) switch (_context12.n) {
1379
1342
  case 0:
1380
- _context14.n = 1;
1343
+ _context12.n = 1;
1381
1344
  return this.getLatestMessageId();
1382
1345
  case 1:
1383
- lastMessageId = _context14.v;
1384
- return _context14.a(2, lastMessageId ? this.has(lastMessageId) : true);
1346
+ lastMessageId = _context12.v;
1347
+ return _context12.a(2, lastMessageId ? this.has(lastMessageId) : true);
1385
1348
  }
1386
- }, _callee14, this);
1349
+ }, _callee12, this);
1387
1350
  }));
1388
1351
  function isLatestItemLoaded() {
1389
1352
  return _isLatestItemLoaded.apply(this, arguments);
1390
1353
  }
1391
1354
  return isLatestItemLoaded;
1392
1355
  }()
1356
+ }, {
1357
+ key: "handleNewMessage",
1358
+ value: function () {
1359
+ var _handleNewMessage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(ev) {
1360
+ var originalState;
1361
+ return _regenerator().w(function (_context13) {
1362
+ while (1) switch (_context13.n) {
1363
+ case 0:
1364
+ if ([WindowState.LATEST, WindowState.LIVE].includes(this.state) && ev.message.location.roomId === this.roomId && ev.message.location.topicId === this.topicId) {
1365
+ originalState = this.state;
1366
+ this.addItems([ev.message], 'tail');
1367
+ this.emitChangeWithDiff(true, originalState);
1368
+ }
1369
+ case 1:
1370
+ return _context13.a(2);
1371
+ }
1372
+ }, _callee13, this);
1373
+ }));
1374
+ function handleNewMessage(_x2) {
1375
+ return _handleNewMessage.apply(this, arguments);
1376
+ }
1377
+ return handleNewMessage;
1378
+ }()
1379
+ }, {
1380
+ key: "handleMessagesRedacted",
1381
+ value: function () {
1382
+ var _handleMessagesRedacted = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(ev) {
1383
+ var refTopicIds;
1384
+ return _regenerator().w(function (_context14) {
1385
+ while (1) switch (_context14.n) {
1386
+ case 0:
1387
+ if (!(ev.location.topicId !== this.topicId || ev.location.roomId !== this.roomId)) {
1388
+ _context14.n = 1;
1389
+ break;
1390
+ }
1391
+ return _context14.a(2);
1392
+ case 1:
1393
+ refTopicIds = this.items.filter(function (msg) {
1394
+ return msg.topicRef && ev.ids.includes(msg.id);
1395
+ }).map(function (msg) {
1396
+ return msg.topicRef;
1397
+ });
1398
+ this["delete"].apply(this, TopicHistoryWindow_toConsumableArray(ev.ids));
1399
+ if (!(this.length === 0)) {
1400
+ _context14.n = 2;
1401
+ break;
1402
+ }
1403
+ _context14.n = 2;
1404
+ return this.resetToLatest();
1405
+ case 2:
1406
+ if (refTopicIds.length > 0) {
1407
+ this.eventTarget.emit('reftopicsdeleted', refTopicIds);
1408
+ }
1409
+ case 3:
1410
+ return _context14.a(2);
1411
+ }
1412
+ }, _callee14, this);
1413
+ }));
1414
+ function handleMessagesRedacted(_x3) {
1415
+ return _handleMessagesRedacted.apply(this, arguments);
1416
+ }
1417
+ return handleMessagesRedacted;
1418
+ }()
1393
1419
  }]);
1394
1420
  }(TraversableRemoteCollection);
1395
1421
  ;// ./src/state-tracker/RoomMessagesHistory.ts