polfan-server-js-client 0.3.3 → 0.4.1

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.
Files changed (69) hide show
  1. package/.gitmodules +3 -3
  2. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28_[Changes]/shelved.patch +447 -0
  3. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28_[Changes]1/shelved.patch +0 -0
  4. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_05_08_2026_17_28__Changes_.xml +4 -0
  5. package/.idea/workspace.xml +61 -52
  6. package/CODE_OF_CONDUCT.md +76 -76
  7. package/README.md +44 -44
  8. package/babel.config.js +5 -5
  9. package/build/index.cjs.js +398 -427
  10. package/build/index.cjs.js.map +1 -1
  11. package/build/index.umd.js +1 -1
  12. package/build/index.umd.js.map +1 -1
  13. package/build/types/index.d.ts +2 -1
  14. package/build/types/state-tracker/RoomMessagesHistory.d.ts +4 -15
  15. package/build/types/state-tracker/TopicHistoryWindow.d.ts +0 -48
  16. package/build/types/types/src/index.d.ts +11 -3
  17. package/build/types/types/src/schemes/Message.d.ts +5 -1
  18. package/build/types/types/src/schemes/MessagePoll.d.ts +10 -0
  19. package/build/types/types/src/schemes/Reaction.d.ts +13 -0
  20. package/build/types/types/src/schemes/SessionData.d.ts +6 -0
  21. package/build/types/types/src/schemes/User.d.ts +15 -0
  22. package/build/types/types/src/schemes/UserData.d.ts +5 -0
  23. package/build/types/types/src/schemes/commands/CreateMessage.d.ts +3 -0
  24. package/build/types/types/src/schemes/commands/GetMessages.d.ts +5 -0
  25. package/build/types/types/src/schemes/commands/GetReactionDetails.d.ts +8 -0
  26. package/build/types/types/src/schemes/commands/React.d.ts +6 -0
  27. package/build/types/types/src/schemes/commands/SetSessionData.d.ts +9 -1
  28. package/build/types/types/src/schemes/commands/SetUserData.d.ts +1 -0
  29. package/build/types/types/src/schemes/commands/Unreact.d.ts +6 -0
  30. package/build/types/types/src/schemes/events/Messages.d.ts +3 -0
  31. package/build/types/types/src/schemes/events/Reacted.d.ts +9 -0
  32. package/build/types/types/src/schemes/events/ReactionDetails.d.ts +11 -0
  33. package/build/types/types/src/schemes/events/ReactionUpdated.d.ts +8 -0
  34. package/jest.config.ts +199 -199
  35. package/package.json +1 -1
  36. package/scripts/getPackageJson.js +24 -24
  37. package/src/FilesClient.ts +42 -42
  38. package/src/index.ts +2 -0
  39. package/src/state-tracker/ChatStateTracker.ts +71 -71
  40. package/src/state-tracker/RoomMessagesHistory.ts +9 -27
  41. package/src/state-tracker/TopicHistoryWindow.ts +1 -133
  42. package/src/state-tracker/UsersManager.ts +1 -1
  43. package/src/state-tracker/functions.ts +28 -28
  44. package/src/types/src/index.ts +24 -2
  45. package/src/types/src/schemes/Message.ts +5 -1
  46. package/src/types/src/schemes/MessagePoll.ts +12 -0
  47. package/src/types/src/schemes/Reaction.ts +16 -0
  48. package/src/types/src/schemes/SessionData.ts +8 -1
  49. package/src/types/src/schemes/User.ts +17 -1
  50. package/src/types/src/schemes/UserData.ts +5 -0
  51. package/src/types/src/schemes/commands/CreateMessage.ts +3 -0
  52. package/src/types/src/schemes/commands/GetMessages.ts +5 -0
  53. package/src/types/src/schemes/commands/GetReactionDetails.ts +9 -0
  54. package/src/types/src/schemes/commands/React.ts +7 -0
  55. package/src/types/src/schemes/commands/SetSessionData.ts +11 -2
  56. package/src/types/src/schemes/commands/SetUserData.ts +1 -0
  57. package/src/types/src/schemes/commands/Unreact.ts +7 -0
  58. package/src/types/src/schemes/events/Messages.ts +3 -0
  59. package/src/types/src/schemes/events/Reacted.ts +10 -0
  60. package/src/types/src/schemes/events/ReactionDetails.ts +12 -0
  61. package/src/types/src/schemes/events/ReactionUpdated.ts +9 -0
  62. package/tests/async-utils.test.ts +29 -29
  63. package/tests/history-window.test.ts +0 -131
  64. package/tests/space-roles.test.ts +42 -42
  65. package/tests/state-reconnect.test.ts +0 -260
  66. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_26_07_2026_21_26_[Changes]/shelved.patch +0 -174
  67. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_26_07_2026_21_26__Changes_.xml +0 -4
  68. package/.idea/shelf/Uncommitted_changes_before_rebase_[Changes]/shelved.patch +0 -18
  69. package/.idea/shelf/Uncommitted_changes_before_rebase__Changes_.xml +0 -4
@@ -48,6 +48,7 @@ __webpack_require__.d(__webpack_exports__, {
48
48
  ObservableIndexedObjectCollection: () => (/* reexport */ ObservableIndexedObjectCollection),
49
49
  PermissionDefinition: () => (/* reexport */ PermissionDefinition),
50
50
  Permissions: () => (/* reexport */ Permissions),
51
+ UserStatus: () => (/* reexport */ UserStatus),
51
52
  WebApiChatClient: () => (/* reexport */ WebApiChatClient),
52
53
  WebSocketChatClient: () => (/* reexport */ WebSocketChatClient),
53
54
  extractUserFromMember: () => (/* reexport */ extractUserFromMember)
@@ -719,16 +720,19 @@ var PromiseRegistry = /*#__PURE__*/function () {
719
720
  function TopicHistoryWindow_typeof(o) { "@babel/helpers - typeof"; return TopicHistoryWindow_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, TopicHistoryWindow_typeof(o); }
720
721
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
721
722
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { TopicHistoryWindow_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
722
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
723
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
724
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
725
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
723
+ function TopicHistoryWindow_superPropGet(t, o, e, r) { var p = TopicHistoryWindow_get(TopicHistoryWindow_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
724
+ function TopicHistoryWindow_get() { return TopicHistoryWindow_get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = TopicHistoryWindow_superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, TopicHistoryWindow_get.apply(null, arguments); }
725
+ function TopicHistoryWindow_superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = TopicHistoryWindow_getPrototypeOf(t));); return t; }
726
726
  function TopicHistoryWindow_toConsumableArray(r) { return TopicHistoryWindow_arrayWithoutHoles(r) || TopicHistoryWindow_iterableToArray(r) || TopicHistoryWindow_unsupportedIterableToArray(r) || TopicHistoryWindow_nonIterableSpread(); }
727
727
  function TopicHistoryWindow_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
728
728
  function TopicHistoryWindow_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return TopicHistoryWindow_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? TopicHistoryWindow_arrayLikeToArray(r, a) : void 0; } }
729
729
  function TopicHistoryWindow_iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
730
730
  function TopicHistoryWindow_arrayWithoutHoles(r) { if (Array.isArray(r)) return TopicHistoryWindow_arrayLikeToArray(r); }
731
731
  function TopicHistoryWindow_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
732
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
733
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
734
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
735
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
732
736
  function TopicHistoryWindow_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
733
737
  function TopicHistoryWindow_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, TopicHistoryWindow_toPropertyKey(o.key), o); } }
734
738
  function TopicHistoryWindow_createClass(e, r, t) { return r && TopicHistoryWindow_defineProperties(e.prototype, r), t && TopicHistoryWindow_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -736,9 +740,6 @@ function TopicHistoryWindow_callSuper(t, o, e) { return o = TopicHistoryWindow_g
736
740
  function TopicHistoryWindow_possibleConstructorReturn(t, e) { if (e && ("object" == TopicHistoryWindow_typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return TopicHistoryWindow_assertThisInitialized(t); }
737
741
  function TopicHistoryWindow_assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
738
742
  function TopicHistoryWindow_isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (TopicHistoryWindow_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
739
- function TopicHistoryWindow_superPropGet(t, o, e, r) { var p = TopicHistoryWindow_get(TopicHistoryWindow_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
740
- function TopicHistoryWindow_get() { return TopicHistoryWindow_get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = TopicHistoryWindow_superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, TopicHistoryWindow_get.apply(null, arguments); }
741
- function TopicHistoryWindow_superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = TopicHistoryWindow_getPrototypeOf(t));); return t; }
742
743
  function TopicHistoryWindow_getPrototypeOf(t) { return TopicHistoryWindow_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, TopicHistoryWindow_getPrototypeOf(t); }
743
744
  function TopicHistoryWindow_inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && TopicHistoryWindow_setPrototypeOf(t, e); }
744
745
  function TopicHistoryWindow_setPrototypeOf(t, e) { return TopicHistoryWindow_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, TopicHistoryWindow_setPrototypeOf(t, e); }
@@ -782,8 +783,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
782
783
  retainRatio: 1,
783
784
  fetchLimit: 50,
784
785
  lastFetchCount: 0,
785
- oldestId: null,
786
- gaps: []
786
+ oldestId: null
787
787
  });
788
788
  return _this;
789
789
  }
@@ -852,23 +852,6 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
852
852
  get: function get() {
853
853
  return [WindowState.LATEST, WindowState.LIVE].includes(this.state);
854
854
  }
855
-
856
- /**
857
- * IDs of the items the window could not stitch to the ones loaded before
858
- * them: there is a gap in front of each of them, i.e. the item right above
859
- * it in the window is not its real predecessor and an unknown number of
860
- * items in between was never fetched.
861
- *
862
- * Such a gap appears when the collection is resynchronised after a
863
- * reconnect (see resyncToLatest) and more items than a single page arrived
864
- * while the connection was down. The markers are kept in the window order
865
- * and disappear together with the items they point at.
866
- */
867
- }, {
868
- key: "gaps",
869
- get: function get() {
870
- return TopicHistoryWindow_toConsumableArray(this.internalState.gaps);
871
- }
872
855
  }, {
873
856
  key: "hasOldest",
874
857
  get: function get() {
@@ -906,7 +889,6 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
906
889
  return _context.f(4);
907
890
  case 5:
908
891
  this._items.deleteAll(); // Directly call deleteAll to prevent event emit.
909
- this.internalState.gaps = []; // Whole content is replaced, old markers mean nothing.
910
892
  this.addItems(result, 'tail');
911
893
  this.internalState.current = WindowState.LATEST;
912
894
  this.emitChangeWithDiff(true, originalState);
@@ -920,119 +902,46 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
920
902
  }
921
903
  return resetToLatest;
922
904
  }()
923
- /**
924
- * Refresh the window with the latest page, keeping the already loaded items
925
- * instead of replacing them.
926
- *
927
- * This is the reconnect-friendly variant of resetToLatest: the items missed
928
- * while the connection was down are pulled with a single request and merged
929
- * on top of the loaded ones (items returned in both are deduplicated), so
930
- * the context the application already had does not disappear. The window
931
- * size limit is the only thing that pushes the oldest items out.
932
- *
933
- * An empty or partial page is not a reason to drop anything: it only means
934
- * the collection has little (or nothing) left on the remote side, while the
935
- * items loaded earlier are still valid. When the page is full and does not
936
- * reach the loaded items, an unknown number of items in between was never
937
- * fetched - both parts are still kept, and the seam between them is recorded
938
- * in `gaps` so the application can show where the history is not continuous.
939
- */
940
905
  }, {
941
- key: "resyncToLatest",
942
- value: (function () {
943
- var _resyncToLatest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
944
- var _this2 = this;
945
- var result, originalState, loaded, fetchedIds, retained, isContinuous;
906
+ key: "fetchPrevious",
907
+ value: function () {
908
+ var _fetchPrevious = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
909
+ var result, originalState, firstItem;
946
910
  return _regenerator().w(function (_context2) {
947
911
  while (1) switch (_context2.p = _context2.n) {
948
912
  case 0:
949
- if (!this.internalState.ongoing) {
913
+ if (!(this.internalState.ongoing || this.hasOldest)) {
950
914
  _context2.n = 1;
951
915
  break;
952
916
  }
953
917
  return _context2.a(2);
954
918
  case 1:
955
919
  originalState = this.state;
956
- this.internalState.ongoing = WindowState.LATEST;
920
+ this.internalState.ongoing = WindowState.PAST;
957
921
  _context2.p = 2;
958
922
  _context2.n = 3;
959
- return this.fetchLatestItems();
923
+ return this.fetchItemsBefore();
960
924
  case 3:
961
925
  result = _context2.v;
962
- this.internalState.lastFetchCount = result.length;
926
+ this.internalState.lastFetchCount = result ? result.length : 0;
963
927
  case 4:
964
928
  _context2.p = 4;
965
929
  this.internalState.ongoing = undefined;
966
930
  return _context2.f(4);
967
- case 5:
968
- loaded = this.items;
969
- fetchedIds = new Set(result.map(function (item) {
970
- return _this2.getId(item);
971
- })); // Items present in the page are taken from it - the server copy is the
972
- // up-to-date one.
973
- retained = loaded.filter(function (item) {
974
- return !fetchedIds.has(_this2.getId(item));
975
- }); // Nothing can be missing in between when there is nothing to stitch,
976
- // when the page is everything the remote side has (it is shorter than
977
- // the requested limit), or when the page reaches the newest loaded item.
978
- isContinuous = !retained.length || result.length < this.internalState.fetchLimit || fetchedIds.has(this.getId(loaded[loaded.length - 1]));
979
- if (!isContinuous) {
980
- this.markGapBefore(this.getId(result[0]));
981
- }
982
- this._items.deleteAll(); // Directly call deleteAll to prevent event emit.
983
- this.addItems([].concat(TopicHistoryWindow_toConsumableArray(retained), TopicHistoryWindow_toConsumableArray(result)), 'tail');
984
- this.internalState.current = WindowState.LATEST;
985
- this.emitChangeWithDiff(true, originalState);
986
- case 6:
987
- return _context2.a(2);
988
- }
989
- }, _callee2, this, [[2,, 4, 5]]);
990
- }));
991
- function resyncToLatest() {
992
- return _resyncToLatest.apply(this, arguments);
993
- }
994
- return resyncToLatest;
995
- }())
996
- }, {
997
- key: "fetchPrevious",
998
- value: function () {
999
- var _fetchPrevious = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
1000
- var result, originalState, firstItem;
1001
- return _regenerator().w(function (_context3) {
1002
- while (1) switch (_context3.p = _context3.n) {
1003
- case 0:
1004
- if (!(this.internalState.ongoing || this.hasOldest)) {
1005
- _context3.n = 1;
1006
- break;
1007
- }
1008
- return _context3.a(2);
1009
- case 1:
1010
- originalState = this.state;
1011
- firstItem = this.getAt(0);
1012
- this.internalState.ongoing = WindowState.PAST;
1013
- _context3.p = 2;
1014
- _context3.n = 3;
1015
- return this.fetchItemsBefore();
1016
- case 3:
1017
- result = _context3.v;
1018
- this.internalState.lastFetchCount = result ? result.length : 0;
1019
- case 4:
1020
- _context3.p = 4;
1021
- this.internalState.ongoing = undefined;
1022
- return _context3.f(4);
1023
931
  case 5:
1024
932
  if (result) {
1025
- _context3.n = 6;
933
+ _context2.n = 6;
1026
934
  break;
1027
935
  }
1028
- return _context3.a(2, this.resetToLatest());
936
+ return _context2.a(2, this.resetToLatest());
1029
937
  case 6:
1030
938
  if (result.length) {
1031
- _context3.n = 8;
939
+ _context2.n = 8;
1032
940
  break;
1033
941
  }
942
+ firstItem = this.getAt(0);
1034
943
  this.internalState.oldestId = firstItem ? this.getId(firstItem) : null;
1035
- _context3.n = 7;
944
+ _context2.n = 7;
1036
945
  return this.refreshFetchedState();
1037
946
  case 7:
1038
947
  // LATEST state has priority over OLDEST
@@ -1040,23 +949,17 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
1040
949
  this.internalState.current = WindowState.OLDEST;
1041
950
  }
1042
951
  this.emitChangeWithDiff(false, originalState);
1043
- return _context3.a(2);
952
+ return _context2.a(2);
1044
953
  case 8:
1045
- if (firstItem) {
1046
- // The fetch asked for the items right before the one that was first,
1047
- // so whatever came back is its real predecessor: a gap marked in
1048
- // front of it (it used to be the top of the window) is closed now.
1049
- this.clearGapBefore(this.getId(firstItem));
1050
- }
1051
954
  this.addItems(result, 'head');
1052
- _context3.n = 9;
955
+ _context2.n = 9;
1053
956
  return this.refreshFetchedState();
1054
957
  case 9:
1055
958
  this.emitChangeWithDiff(true, originalState);
1056
959
  case 10:
1057
- return _context3.a(2);
960
+ return _context2.a(2);
1058
961
  }
1059
- }, _callee3, this, [[2,, 4, 5]]);
962
+ }, _callee2, this, [[2,, 4, 5]]);
1060
963
  }));
1061
964
  function fetchPrevious() {
1062
965
  return _fetchPrevious.apply(this, arguments);
@@ -1066,53 +969,53 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
1066
969
  }, {
1067
970
  key: "fetchNext",
1068
971
  value: function () {
1069
- var _fetchNext = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
972
+ var _fetchNext = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
1070
973
  var result, originalState;
1071
- return _regenerator().w(function (_context4) {
1072
- while (1) switch (_context4.p = _context4.n) {
974
+ return _regenerator().w(function (_context3) {
975
+ while (1) switch (_context3.p = _context3.n) {
1073
976
  case 0:
1074
977
  if (!(this.internalState.ongoing || this.hasLatest)) {
1075
- _context4.n = 1;
978
+ _context3.n = 1;
1076
979
  break;
1077
980
  }
1078
- return _context4.a(2);
981
+ return _context3.a(2);
1079
982
  case 1:
1080
983
  originalState = this.state;
1081
984
  this.internalState.ongoing = WindowState.PAST;
1082
- _context4.p = 2;
1083
- _context4.n = 3;
985
+ _context3.p = 2;
986
+ _context3.n = 3;
1084
987
  return this.fetchItemsAfter();
1085
988
  case 3:
1086
- result = _context4.v;
989
+ result = _context3.v;
1087
990
  this.internalState.lastFetchCount = result ? result.length : 0;
1088
991
  case 4:
1089
- _context4.p = 4;
992
+ _context3.p = 4;
1090
993
  this.internalState.ongoing = undefined;
1091
- return _context4.f(4);
994
+ return _context3.f(4);
1092
995
  case 5:
1093
996
  if (result) {
1094
- _context4.n = 7;
997
+ _context3.n = 7;
1095
998
  break;
1096
999
  }
1097
- _context4.n = 6;
1000
+ _context3.n = 6;
1098
1001
  return this.resetToLatest();
1099
1002
  case 6:
1100
- return _context4.a(2);
1003
+ return _context3.a(2);
1101
1004
  case 7:
1102
1005
  if (!result.length) {
1103
- _context4.n = 9;
1006
+ _context3.n = 9;
1104
1007
  break;
1105
1008
  }
1106
1009
  this.addItems(result, 'tail');
1107
- _context4.n = 8;
1010
+ _context3.n = 8;
1108
1011
  return this.refreshFetchedState();
1109
1012
  case 8:
1110
1013
  this.emitChangeWithDiff(true, originalState);
1111
- return _context4.a(2);
1014
+ return _context3.a(2);
1112
1015
  case 9:
1113
- return _context4.a(2);
1016
+ return _context3.a(2);
1114
1017
  }
1115
- }, _callee4, this, [[2,, 4, 5]]);
1018
+ }, _callee3, this, [[2,, 4, 5]]);
1116
1019
  }));
1117
1020
  function fetchNext() {
1118
1021
  return _fetchNext.apply(this, arguments);
@@ -1122,91 +1025,75 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
1122
1025
  }, {
1123
1026
  key: "jumpTo",
1124
1027
  value: function () {
1125
- var _jumpTo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(id) {
1028
+ var _jumpTo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(id) {
1126
1029
  var result, originalState;
1127
- return _regenerator().w(function (_context5) {
1128
- while (1) switch (_context5.p = _context5.n) {
1030
+ return _regenerator().w(function (_context4) {
1031
+ while (1) switch (_context4.p = _context4.n) {
1129
1032
  case 0:
1130
1033
  if (!(this.internalState.ongoing || this.state !== WindowState.LIVE && this._items.has(id))) {
1131
- _context5.n = 1;
1034
+ _context4.n = 1;
1132
1035
  break;
1133
1036
  }
1134
- return _context5.a(2);
1037
+ return _context4.a(2);
1135
1038
  case 1:
1136
1039
  originalState = this.state;
1137
1040
  this.internalState.ongoing = WindowState.PAST;
1138
- _context5.p = 2;
1139
- _context5.n = 3;
1041
+ _context4.p = 2;
1042
+ _context4.n = 3;
1140
1043
  return this.fetchItemsAround(id);
1141
1044
  case 3:
1142
- result = _context5.v;
1045
+ result = _context4.v;
1143
1046
  this.internalState.lastFetchCount = result ? result.length : 0;
1144
1047
  if (!result) {
1145
- _context5.n = 4;
1048
+ _context4.n = 4;
1146
1049
  break;
1147
1050
  }
1148
1051
  this._items.deleteAll(); // Directly call deleteAll to prevent event emit.
1149
- this.internalState.gaps = []; // Whole content is replaced, old markers mean nothing.
1150
1052
  this.addItems(result, 'tail');
1151
- _context5.n = 4;
1053
+ _context4.n = 4;
1152
1054
  return this.refreshFetchedState();
1153
1055
  case 4:
1154
- _context5.p = 4;
1056
+ _context4.p = 4;
1155
1057
  this.internalState.ongoing = undefined;
1156
- return _context5.f(4);
1058
+ return _context4.f(4);
1157
1059
  case 5:
1158
1060
  this.emitChangeWithDiff(!!result, originalState);
1159
1061
  case 6:
1160
- return _context5.a(2);
1062
+ return _context4.a(2);
1161
1063
  }
1162
- }, _callee5, this, [[2,, 4, 5]]);
1064
+ }, _callee4, this, [[2,, 4, 5]]);
1163
1065
  }));
1164
1066
  function jumpTo(_x) {
1165
1067
  return _jumpTo.apply(this, arguments);
1166
1068
  }
1167
1069
  return jumpTo;
1168
1070
  }()
1169
- }, {
1170
- key: "delete",
1171
- value: function _delete() {
1172
- for (var _len2 = arguments.length, ids = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1173
- ids[_key2] = arguments[_key2];
1174
- }
1175
- TopicHistoryWindow_superPropGet(TraversableRemoteCollection, "delete", this, 3)(ids);
1176
- this.dropDanglingGaps();
1177
- }
1178
- }, {
1179
- key: "deleteAll",
1180
- value: function deleteAll() {
1181
- TopicHistoryWindow_superPropGet(TraversableRemoteCollection, "deleteAll", this, 3)([]);
1182
- this.internalState.gaps = [];
1183
- }
1184
1071
  }, {
1185
1072
  key: "refreshFetchedState",
1186
1073
  value: function () {
1187
- var _refreshFetchedState = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
1074
+ var _refreshFetchedState = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
1188
1075
  var _t;
1189
- return _regenerator().w(function (_context6) {
1190
- while (1) switch (_context6.n) {
1076
+ return _regenerator().w(function (_context5) {
1077
+ while (1) switch (_context5.n) {
1191
1078
  case 0:
1192
- _context6.n = 1;
1079
+ _context5.n = 1;
1193
1080
  return this.isLatestItemLoaded();
1194
1081
  case 1:
1195
- if (!_context6.v) {
1196
- _context6.n = 2;
1082
+ if (!_context5.v) {
1083
+ _context5.n = 2;
1197
1084
  break;
1198
1085
  }
1199
1086
  _t = WindowState.LATEST;
1200
- _context6.n = 3;
1087
+ _context5.n = 3;
1201
1088
  break;
1202
1089
  case 2:
1203
1090
  _t = WindowState.PAST;
1204
1091
  case 3:
1205
1092
  this.internalState.current = _t;
1206
1093
  case 4:
1207
- return _context6.a(2);
1094
+ return _context5.a(2);
1208
1095
  }
1209
- }, _callee6, this);
1096
+ }, _callee5, this);
1210
1097
  }));
1211
1098
  function refreshFetchedState() {
1212
1099
  return _refreshFetchedState.apply(this, arguments);
@@ -1217,7 +1104,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
1217
1104
  key: "addItems",
1218
1105
  value: function addItems(newItems, to) {
1219
1106
  var _this$_items,
1220
- _this3 = this;
1107
+ _this2 = this;
1221
1108
  var result;
1222
1109
  if (to === 'head') {
1223
1110
  result = this.trimItemsArrayToLimit([].concat(TopicHistoryWindow_toConsumableArray(newItems), TopicHistoryWindow_toConsumableArray(this.items)), 'tail');
@@ -1229,9 +1116,8 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
1229
1116
  // Directly calls to prevent event emit.
1230
1117
  this._items.deleteAll();
1231
1118
  (_this$_items = this._items).set.apply(_this$_items, TopicHistoryWindow_toConsumableArray(result.map(function (item) {
1232
- return [_this3.getId(item), item];
1119
+ return [_this2.getId(item), item];
1233
1120
  })));
1234
- this.dropDanglingGaps();
1235
1121
  }
1236
1122
  }, {
1237
1123
  key: "emitChangeWithDiff",
@@ -1243,47 +1129,6 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
1243
1129
  }
1244
1130
  }
1245
1131
 
1246
- /**
1247
- * Record that the history is not continuous in front of the given item.
1248
- */
1249
- }, {
1250
- key: "markGapBefore",
1251
- value: function markGapBefore(id) {
1252
- if (!this.internalState.gaps.includes(id)) {
1253
- this.internalState.gaps = [].concat(TopicHistoryWindow_toConsumableArray(this.internalState.gaps), [id]);
1254
- }
1255
- }
1256
-
1257
- /**
1258
- * Forget the gap in front of the given item - the items before it are known
1259
- * to be its real predecessors now.
1260
- */
1261
- }, {
1262
- key: "clearGapBefore",
1263
- value: function clearGapBefore(id) {
1264
- if (this.internalState.gaps.includes(id)) {
1265
- this.internalState.gaps = this.internalState.gaps.filter(function (gapId) {
1266
- return gapId !== id;
1267
- });
1268
- }
1269
- }
1270
-
1271
- /**
1272
- * Forget the gap markers pointing at items that are no longer in the window
1273
- * (trimmed, deleted or replaced), so `gaps` never refers to nothing.
1274
- */
1275
- }, {
1276
- key: "dropDanglingGaps",
1277
- value: function dropDanglingGaps() {
1278
- var _this4 = this;
1279
- if (!this.internalState.gaps.length) {
1280
- return;
1281
- }
1282
- this.internalState.gaps = this.internalState.gaps.filter(function (id) {
1283
- return _this4.has(id);
1284
- });
1285
- }
1286
-
1287
1132
  /**
1288
1133
  * Return array with messages trimmed using High/Low Watermark strategy.
1289
1134
  */
@@ -1307,27 +1152,27 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
1307
1152
  }(ObservableIndexedObjectCollection);
1308
1153
  var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1309
1154
  function TopicHistoryWindow(roomId, topicId, tracker) {
1310
- var _this5;
1155
+ var _this3;
1311
1156
  var bindEvents = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
1312
1157
  TopicHistoryWindow_classCallCheck(this, TopicHistoryWindow);
1313
- _this5 = TopicHistoryWindow_callSuper(this, TopicHistoryWindow, ['id']);
1158
+ _this3 = TopicHistoryWindow_callSuper(this, TopicHistoryWindow, ['id']);
1314
1159
  /**
1315
1160
  * Reexported available window modes enum.
1316
1161
  */
1317
- TopicHistoryWindow_defineProperty(_this5, "WindowState", WindowState);
1318
- _this5.roomId = roomId;
1319
- _this5.topicId = topicId;
1320
- _this5.tracker = tracker;
1321
- _this5.internalState.traverseLock = false;
1162
+ TopicHistoryWindow_defineProperty(_this3, "WindowState", WindowState);
1163
+ _this3.roomId = roomId;
1164
+ _this3.topicId = topicId;
1165
+ _this3.tracker = tracker;
1166
+ _this3.internalState.traverseLock = false;
1322
1167
  if (bindEvents) {
1323
- _this5.tracker.client.on('NewMessage', function (ev) {
1324
- return _this5.handleNewMessage(ev);
1168
+ _this3.tracker.client.on('NewMessage', function (ev) {
1169
+ return _this3.handleNewMessage(ev);
1325
1170
  });
1326
- _this5.tracker.client.on('MessagesRedacted', function (ev) {
1327
- return _this5.handleMessagesRedacted(ev);
1171
+ _this3.tracker.client.on('MessagesRedacted', function (ev) {
1172
+ return _this3.handleMessagesRedacted(ev);
1328
1173
  });
1329
1174
  }
1330
- return _this5;
1175
+ return _this3;
1331
1176
  }
1332
1177
  TopicHistoryWindow_inherits(TopicHistoryWindow, _TraversableRemoteCol);
1333
1178
  return TopicHistoryWindow_createClass(TopicHistoryWindow, [{
@@ -1347,21 +1192,21 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1347
1192
  }, {
1348
1193
  key: "setTraverseLock",
1349
1194
  value: function () {
1350
- var _setTraverseLock = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(lock) {
1351
- return _regenerator().w(function (_context7) {
1352
- while (1) switch (_context7.n) {
1195
+ var _setTraverseLock = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(lock) {
1196
+ return _regenerator().w(function (_context6) {
1197
+ while (1) switch (_context6.n) {
1353
1198
  case 0:
1354
1199
  this.internalState.traverseLock = lock;
1355
1200
  if (!(lock && this.state !== WindowState.LIVE && this.state !== WindowState.LATEST)) {
1356
- _context7.n = 1;
1201
+ _context6.n = 1;
1357
1202
  break;
1358
1203
  }
1359
- _context7.n = 1;
1204
+ _context6.n = 1;
1360
1205
  return TopicHistoryWindow_superPropGet(TopicHistoryWindow, "resetToLatest", this, 3)([]);
1361
1206
  case 1:
1362
- return _context7.a(2);
1207
+ return _context6.a(2);
1363
1208
  }
1364
- }, _callee7, this);
1209
+ }, _callee6, this);
1365
1210
  }));
1366
1211
  function setTraverseLock(_x2) {
1367
1212
  return _setTraverseLock.apply(this, arguments);
@@ -1371,66 +1216,44 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1371
1216
  }, {
1372
1217
  key: "resetToLatest",
1373
1218
  value: function () {
1374
- var _resetToLatest2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
1219
+ var _resetToLatest2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
1375
1220
  var force,
1376
- _args8 = arguments;
1377
- return _regenerator().w(function (_context8) {
1378
- while (1) switch (_context8.n) {
1221
+ _args7 = arguments;
1222
+ return _regenerator().w(function (_context7) {
1223
+ while (1) switch (_context7.n) {
1379
1224
  case 0:
1380
- force = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : false;
1225
+ force = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : false;
1381
1226
  if (!this.internalState.traverseLock) {
1382
- _context8.n = 1;
1227
+ _context7.n = 1;
1383
1228
  break;
1384
1229
  }
1385
- return _context8.a(2);
1230
+ return _context7.a(2);
1386
1231
  case 1:
1387
- return _context8.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "resetToLatest", this, 3)([force]));
1232
+ return _context7.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "resetToLatest", this, 3)([force]));
1388
1233
  }
1389
- }, _callee8, this);
1234
+ }, _callee7, this);
1390
1235
  }));
1391
1236
  function resetToLatest() {
1392
1237
  return _resetToLatest2.apply(this, arguments);
1393
1238
  }
1394
1239
  return resetToLatest;
1395
1240
  }()
1396
- }, {
1397
- key: "resyncToLatest",
1398
- value: function () {
1399
- var _resyncToLatest2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
1400
- return _regenerator().w(function (_context9) {
1401
- while (1) switch (_context9.n) {
1402
- case 0:
1403
- if (!this.internalState.traverseLock) {
1404
- _context9.n = 1;
1405
- break;
1406
- }
1407
- return _context9.a(2);
1408
- case 1:
1409
- return _context9.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "resyncToLatest", this, 3)([]));
1410
- }
1411
- }, _callee9, this);
1412
- }));
1413
- function resyncToLatest() {
1414
- return _resyncToLatest2.apply(this, arguments);
1415
- }
1416
- return resyncToLatest;
1417
- }()
1418
1241
  }, {
1419
1242
  key: "fetchNext",
1420
1243
  value: function () {
1421
- var _fetchNext2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
1422
- return _regenerator().w(function (_context0) {
1423
- while (1) switch (_context0.n) {
1244
+ var _fetchNext2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
1245
+ return _regenerator().w(function (_context8) {
1246
+ while (1) switch (_context8.n) {
1424
1247
  case 0:
1425
1248
  if (!this.internalState.traverseLock) {
1426
- _context0.n = 1;
1249
+ _context8.n = 1;
1427
1250
  break;
1428
1251
  }
1429
- return _context0.a(2);
1252
+ return _context8.a(2);
1430
1253
  case 1:
1431
- return _context0.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "fetchNext", this, 3)([]));
1254
+ return _context8.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "fetchNext", this, 3)([]));
1432
1255
  }
1433
- }, _callee0, this);
1256
+ }, _callee8, this);
1434
1257
  }));
1435
1258
  function fetchNext() {
1436
1259
  return _fetchNext2.apply(this, arguments);
@@ -1440,19 +1263,19 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1440
1263
  }, {
1441
1264
  key: "fetchPrevious",
1442
1265
  value: function () {
1443
- var _fetchPrevious2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
1444
- return _regenerator().w(function (_context1) {
1445
- while (1) switch (_context1.n) {
1266
+ var _fetchPrevious2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
1267
+ return _regenerator().w(function (_context9) {
1268
+ while (1) switch (_context9.n) {
1446
1269
  case 0:
1447
1270
  if (!this.internalState.traverseLock) {
1448
- _context1.n = 1;
1271
+ _context9.n = 1;
1449
1272
  break;
1450
1273
  }
1451
- return _context1.a(2);
1274
+ return _context9.a(2);
1452
1275
  case 1:
1453
- return _context1.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "fetchPrevious", this, 3)([]));
1276
+ return _context9.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "fetchPrevious", this, 3)([]));
1454
1277
  }
1455
- }, _callee1, this);
1278
+ }, _callee9, this);
1456
1279
  }));
1457
1280
  function fetchPrevious() {
1458
1281
  return _fetchPrevious2.apply(this, arguments);
@@ -1462,19 +1285,19 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1462
1285
  }, {
1463
1286
  key: "jumpTo",
1464
1287
  value: function () {
1465
- var _jumpTo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(id) {
1466
- return _regenerator().w(function (_context10) {
1467
- while (1) switch (_context10.n) {
1288
+ var _jumpTo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(id) {
1289
+ return _regenerator().w(function (_context0) {
1290
+ while (1) switch (_context0.n) {
1468
1291
  case 0:
1469
1292
  if (!this.internalState.traverseLock) {
1470
- _context10.n = 1;
1293
+ _context0.n = 1;
1471
1294
  break;
1472
1295
  }
1473
- return _context10.a(2);
1296
+ return _context0.a(2);
1474
1297
  case 1:
1475
- return _context10.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "jumpTo", this, 3)([id]));
1298
+ return _context0.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "jumpTo", this, 3)([id]));
1476
1299
  }
1477
- }, _callee10, this);
1300
+ }, _callee0, this);
1478
1301
  }));
1479
1302
  function jumpTo(_x3) {
1480
1303
  return _jumpTo2.apply(this, arguments);
@@ -1499,20 +1322,20 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1499
1322
  }, {
1500
1323
  key: "fetchItemsAfter",
1501
1324
  value: function () {
1502
- var _fetchItemsAfter = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
1325
+ var _fetchItemsAfter = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
1503
1326
  var _this$getAt;
1504
1327
  var afterId, result;
1505
- return _regenerator().w(function (_context11) {
1506
- while (1) switch (_context11.n) {
1328
+ return _regenerator().w(function (_context1) {
1329
+ while (1) switch (_context1.n) {
1507
1330
  case 0:
1508
1331
  afterId = (_this$getAt = this.getAt(this.length - 1)) === null || _this$getAt === void 0 ? void 0 : _this$getAt.id;
1509
1332
  if (afterId) {
1510
- _context11.n = 1;
1333
+ _context1.n = 1;
1511
1334
  break;
1512
1335
  }
1513
- return _context11.a(2, null);
1336
+ return _context1.a(2, null);
1514
1337
  case 1:
1515
- _context11.n = 2;
1338
+ _context1.n = 2;
1516
1339
  return this.tracker.client.send('GetMessages', {
1517
1340
  location: {
1518
1341
  roomId: this.roomId,
@@ -1522,16 +1345,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1522
1345
  limit: this.internalState.fetchLimit
1523
1346
  });
1524
1347
  case 2:
1525
- result = _context11.v;
1348
+ result = _context1.v;
1526
1349
  if (!result.error) {
1527
- _context11.n = 3;
1350
+ _context1.n = 3;
1528
1351
  break;
1529
1352
  }
1530
1353
  throw new Error("Cannot fetch messages: ".concat(result.error.message));
1531
1354
  case 3:
1532
- return _context11.a(2, result.data.messages);
1355
+ return _context1.a(2, result.data.messages);
1533
1356
  }
1534
- }, _callee11, this);
1357
+ }, _callee1, this);
1535
1358
  }));
1536
1359
  function fetchItemsAfter() {
1537
1360
  return _fetchItemsAfter.apply(this, arguments);
@@ -1541,12 +1364,12 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1541
1364
  }, {
1542
1365
  key: "fetchItemsAround",
1543
1366
  value: function () {
1544
- var _fetchItemsAround = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(id) {
1367
+ var _fetchItemsAround = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(id) {
1545
1368
  var result;
1546
- return _regenerator().w(function (_context12) {
1547
- while (1) switch (_context12.n) {
1369
+ return _regenerator().w(function (_context10) {
1370
+ while (1) switch (_context10.n) {
1548
1371
  case 0:
1549
- _context12.n = 1;
1372
+ _context10.n = 1;
1550
1373
  return this.tracker.client.send('GetMessages', {
1551
1374
  location: {
1552
1375
  roomId: this.roomId,
@@ -1556,16 +1379,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1556
1379
  limit: this.internalState.fetchLimit
1557
1380
  });
1558
1381
  case 1:
1559
- result = _context12.v;
1382
+ result = _context10.v;
1560
1383
  if (!result.error) {
1561
- _context12.n = 2;
1384
+ _context10.n = 2;
1562
1385
  break;
1563
1386
  }
1564
1387
  throw new Error("Cannot fetch messages: ".concat(result.error.message));
1565
1388
  case 2:
1566
- return _context12.a(2, result.data.messages);
1389
+ return _context10.a(2, result.data.messages);
1567
1390
  }
1568
- }, _callee12, this);
1391
+ }, _callee10, this);
1569
1392
  }));
1570
1393
  function fetchItemsAround(_x4) {
1571
1394
  return _fetchItemsAround.apply(this, arguments);
@@ -1575,20 +1398,20 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1575
1398
  }, {
1576
1399
  key: "fetchItemsBefore",
1577
1400
  value: function () {
1578
- var _fetchItemsBefore = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
1401
+ var _fetchItemsBefore = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
1579
1402
  var _this$getAt2;
1580
1403
  var beforeId, result;
1581
- return _regenerator().w(function (_context13) {
1582
- while (1) switch (_context13.n) {
1404
+ return _regenerator().w(function (_context11) {
1405
+ while (1) switch (_context11.n) {
1583
1406
  case 0:
1584
1407
  beforeId = (_this$getAt2 = this.getAt(0)) === null || _this$getAt2 === void 0 ? void 0 : _this$getAt2.id;
1585
1408
  if (beforeId) {
1586
- _context13.n = 1;
1409
+ _context11.n = 1;
1587
1410
  break;
1588
1411
  }
1589
- return _context13.a(2, null);
1412
+ return _context11.a(2, null);
1590
1413
  case 1:
1591
- _context13.n = 2;
1414
+ _context11.n = 2;
1592
1415
  return this.tracker.client.send('GetMessages', {
1593
1416
  location: {
1594
1417
  roomId: this.roomId,
@@ -1598,16 +1421,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1598
1421
  limit: this.internalState.fetchLimit
1599
1422
  });
1600
1423
  case 2:
1601
- result = _context13.v;
1424
+ result = _context11.v;
1602
1425
  if (!result.error) {
1603
- _context13.n = 3;
1426
+ _context11.n = 3;
1604
1427
  break;
1605
1428
  }
1606
1429
  throw new Error("Cannot fetch messages: ".concat(result.error.message));
1607
1430
  case 3:
1608
- return _context13.a(2, result.data.messages);
1431
+ return _context11.a(2, result.data.messages);
1609
1432
  }
1610
- }, _callee13, this);
1433
+ }, _callee11, this);
1611
1434
  }));
1612
1435
  function fetchItemsBefore() {
1613
1436
  return _fetchItemsBefore.apply(this, arguments);
@@ -1617,12 +1440,12 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1617
1440
  }, {
1618
1441
  key: "fetchLatestItems",
1619
1442
  value: function () {
1620
- var _fetchLatestItems = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
1443
+ var _fetchLatestItems = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
1621
1444
  var result;
1622
- return _regenerator().w(function (_context14) {
1623
- while (1) switch (_context14.n) {
1445
+ return _regenerator().w(function (_context12) {
1446
+ while (1) switch (_context12.n) {
1624
1447
  case 0:
1625
- _context14.n = 1;
1448
+ _context12.n = 1;
1626
1449
  return this.tracker.client.send('GetMessages', {
1627
1450
  location: {
1628
1451
  roomId: this.roomId,
@@ -1631,16 +1454,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1631
1454
  limit: this.internalState.fetchLimit
1632
1455
  });
1633
1456
  case 1:
1634
- result = _context14.v;
1457
+ result = _context12.v;
1635
1458
  if (!result.error) {
1636
- _context14.n = 2;
1459
+ _context12.n = 2;
1637
1460
  break;
1638
1461
  }
1639
1462
  throw new Error("Cannot fetch messages: ".concat(result.error.message));
1640
1463
  case 2:
1641
- return _context14.a(2, result.data.messages);
1464
+ return _context12.a(2, result.data.messages);
1642
1465
  }
1643
- }, _callee14, this);
1466
+ }, _callee12, this);
1644
1467
  }));
1645
1468
  function fetchLatestItems() {
1646
1469
  return _fetchLatestItems.apply(this, arguments);
@@ -1650,16 +1473,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1650
1473
  }, {
1651
1474
  key: "getTopic",
1652
1475
  value: function () {
1653
- var _getTopic = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
1654
- return _regenerator().w(function (_context15) {
1655
- while (1) switch (_context15.n) {
1476
+ var _getTopic = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
1477
+ return _regenerator().w(function (_context13) {
1478
+ while (1) switch (_context13.n) {
1656
1479
  case 0:
1657
- _context15.n = 1;
1480
+ _context13.n = 1;
1658
1481
  return this.tracker.rooms.getTopics(this.roomId, [this.topicId]);
1659
1482
  case 1:
1660
- return _context15.a(2, _context15.v.get(this.topicId));
1483
+ return _context13.a(2, _context13.v.get(this.topicId));
1661
1484
  }
1662
- }, _callee15, this);
1485
+ }, _callee13, this);
1663
1486
  }));
1664
1487
  function getTopic() {
1665
1488
  return _getTopic.apply(this, arguments);
@@ -1669,43 +1492,43 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1669
1492
  }, {
1670
1493
  key: "getLatestMessageId",
1671
1494
  value: function () {
1672
- var _getLatestMessageId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
1495
+ var _getLatestMessageId = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
1673
1496
  var _yield$this$getTopic;
1674
1497
  var _t2, _t3, _t4, _t5;
1675
- return _regenerator().w(function (_context16) {
1676
- while (1) switch (_context16.n) {
1498
+ return _regenerator().w(function (_context14) {
1499
+ while (1) switch (_context14.n) {
1677
1500
  case 0:
1678
- _context16.n = 1;
1501
+ _context14.n = 1;
1679
1502
  return this.getTopic();
1680
1503
  case 1:
1681
- _t4 = _yield$this$getTopic = _context16.v;
1504
+ _t4 = _yield$this$getTopic = _context14.v;
1682
1505
  _t3 = _t4 === null;
1683
1506
  if (_t3) {
1684
- _context16.n = 2;
1507
+ _context14.n = 2;
1685
1508
  break;
1686
1509
  }
1687
1510
  _t3 = _yield$this$getTopic === void 0;
1688
1511
  case 2:
1689
1512
  _t2 = _t3;
1690
1513
  if (_t2) {
1691
- _context16.n = 3;
1514
+ _context14.n = 3;
1692
1515
  break;
1693
1516
  }
1694
1517
  _t2 = (_yield$this$getTopic = _yield$this$getTopic.lastMessage) === null || _yield$this$getTopic === void 0;
1695
1518
  case 3:
1696
1519
  if (!_t2) {
1697
- _context16.n = 4;
1520
+ _context14.n = 4;
1698
1521
  break;
1699
1522
  }
1700
1523
  _t5 = void 0;
1701
- _context16.n = 5;
1524
+ _context14.n = 5;
1702
1525
  break;
1703
1526
  case 4:
1704
1527
  _t5 = _yield$this$getTopic.id;
1705
1528
  case 5:
1706
- return _context16.a(2, _t5);
1529
+ return _context14.a(2, _t5);
1707
1530
  }
1708
- }, _callee16, this);
1531
+ }, _callee14, this);
1709
1532
  }));
1710
1533
  function getLatestMessageId() {
1711
1534
  return _getLatestMessageId.apply(this, arguments);
@@ -1715,18 +1538,18 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1715
1538
  }, {
1716
1539
  key: "isLatestItemLoaded",
1717
1540
  value: function () {
1718
- var _isLatestItemLoaded = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
1541
+ var _isLatestItemLoaded = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
1719
1542
  var lastMessageId;
1720
- return _regenerator().w(function (_context17) {
1721
- while (1) switch (_context17.n) {
1543
+ return _regenerator().w(function (_context15) {
1544
+ while (1) switch (_context15.n) {
1722
1545
  case 0:
1723
- _context17.n = 1;
1546
+ _context15.n = 1;
1724
1547
  return this.getLatestMessageId();
1725
1548
  case 1:
1726
- lastMessageId = _context17.v;
1727
- return _context17.a(2, lastMessageId ? this.has(lastMessageId) : true);
1549
+ lastMessageId = _context15.v;
1550
+ return _context15.a(2, lastMessageId ? this.has(lastMessageId) : true);
1728
1551
  }
1729
- }, _callee17, this);
1552
+ }, _callee15, this);
1730
1553
  }));
1731
1554
  function isLatestItemLoaded() {
1732
1555
  return _isLatestItemLoaded.apply(this, arguments);
@@ -1736,10 +1559,10 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1736
1559
  }, {
1737
1560
  key: "handleNewMessage",
1738
1561
  value: function () {
1739
- var _handleNewMessage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(ev) {
1562
+ var _handleNewMessage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(ev) {
1740
1563
  var originalState;
1741
- return _regenerator().w(function (_context18) {
1742
- while (1) switch (_context18.n) {
1564
+ return _regenerator().w(function (_context16) {
1565
+ while (1) switch (_context16.n) {
1743
1566
  case 0:
1744
1567
  if ([WindowState.LATEST, WindowState.LIVE].includes(this.state) && ev.message.location.roomId === this.roomId && ev.message.location.topicId === this.topicId) {
1745
1568
  originalState = this.state;
@@ -1747,9 +1570,9 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1747
1570
  this.emitChangeWithDiff(true, originalState);
1748
1571
  }
1749
1572
  case 1:
1750
- return _context18.a(2);
1573
+ return _context16.a(2);
1751
1574
  }
1752
- }, _callee18, this);
1575
+ }, _callee16, this);
1753
1576
  }));
1754
1577
  function handleNewMessage(_x5) {
1755
1578
  return _handleNewMessage.apply(this, arguments);
@@ -1759,16 +1582,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1759
1582
  }, {
1760
1583
  key: "handleMessagesRedacted",
1761
1584
  value: function () {
1762
- var _handleMessagesRedacted = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(ev) {
1585
+ var _handleMessagesRedacted = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(ev) {
1763
1586
  var refTopicIds;
1764
- return _regenerator().w(function (_context19) {
1765
- while (1) switch (_context19.n) {
1587
+ return _regenerator().w(function (_context17) {
1588
+ while (1) switch (_context17.n) {
1766
1589
  case 0:
1767
1590
  if (!(ev.location.topicId !== this.topicId || ev.location.roomId !== this.roomId)) {
1768
- _context19.n = 1;
1591
+ _context17.n = 1;
1769
1592
  break;
1770
1593
  }
1771
- return _context19.a(2);
1594
+ return _context17.a(2);
1772
1595
  case 1:
1773
1596
  refTopicIds = this.items.filter(function (msg) {
1774
1597
  return msg.topicRef && ev.ids.includes(msg.id);
@@ -1777,19 +1600,19 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1777
1600
  });
1778
1601
  this["delete"].apply(this, TopicHistoryWindow_toConsumableArray(ev.ids));
1779
1602
  if (!(this.length === 0)) {
1780
- _context19.n = 2;
1603
+ _context17.n = 2;
1781
1604
  break;
1782
1605
  }
1783
- _context19.n = 2;
1606
+ _context17.n = 2;
1784
1607
  return this.resetToLatest();
1785
1608
  case 2:
1786
1609
  if (refTopicIds.length > 0) {
1787
1610
  this.eventTarget.emit('reftopicsdeleted', refTopicIds);
1788
1611
  }
1789
1612
  case 3:
1790
- return _context19.a(2);
1613
+ return _context17.a(2);
1791
1614
  }
1792
- }, _callee19, this);
1615
+ }, _callee17, this);
1793
1616
  }));
1794
1617
  function handleMessagesRedacted(_x6) {
1795
1618
  return _handleMessagesRedacted.apply(this, arguments);
@@ -1829,7 +1652,6 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
1829
1652
  RoomMessagesHistory_classCallCheck(this, RoomMessagesHistory);
1830
1653
  RoomMessagesHistory_defineProperty(this, "historyWindows", new IndexedCollection());
1831
1654
  RoomMessagesHistory_defineProperty(this, "traverseLock", false);
1832
- RoomMessagesHistory_defineProperty(this, "timeLimitedHistory", false);
1833
1655
  this.room = room;
1834
1656
  this.tracker = tracker;
1835
1657
  this.tracker.client.on('RoomUpdated', function (ev) {
@@ -1841,7 +1663,7 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
1841
1663
  this.tracker.client.on('TopicDeleted', function (ev) {
1842
1664
  return _this.handleTopicDeleted(ev);
1843
1665
  });
1844
- this.updateHistoryMode(this.room);
1666
+ this.updateTraverseLock(this.room);
1845
1667
  if (this.room.defaultTopic) {
1846
1668
  this.createHistoryWindowForTopic(this.room.defaultTopic);
1847
1669
  }
@@ -1891,19 +1713,9 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
1891
1713
  *
1892
1714
  * The window bindings are preserved; only windows that the application had
1893
1715
  * actually pulled to the latest page (state === LATEST) are refreshed, with
1894
- * a single request instead of a chain of catch-up requests. Windows that
1895
- * were never pulled (LIVE) or belong to an ephemeral room are left untouched
1896
- * so their in-memory context survives the reconnect.
1897
- *
1898
- * How a refreshed window is rebuilt depends on the room history mode: rooms
1899
- * keeping the full history are simply reset to the latest page (it can
1900
- * always be traversed back on demand), while rooms with a time-limited
1901
- * history (MaxAge) load the messages missed during the downtime on top of
1902
- * the already loaded ones, with the messages returned in both deduplicated.
1903
- * The maxAge retention applies to what the server serves - so that users
1904
- * joining later do not see the older conversation - and never to what this
1905
- * client already has: messages the user witnessed stay in the window until
1906
- * they are pushed out by its own size limit.
1716
+ * a single resetToLatest instead of a chain of catch-up requests. Windows
1717
+ * that were never pulled (LIVE) or belong to an ephemeral room are left
1718
+ * untouched so their in-memory context survives the reconnect.
1907
1719
  */
1908
1720
  )
1909
1721
  }, {
@@ -1915,14 +1727,14 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
1915
1727
  while (1) switch (_context2.p = _context2.n) {
1916
1728
  case 0:
1917
1729
  this.room = room;
1918
- this.updateHistoryMode(room);
1730
+ this.updateTraverseLock(room);
1919
1731
  if (this.room.defaultTopic) {
1920
1732
  this.createHistoryWindowForTopic(this.room.defaultTopic);
1921
1733
  }
1922
1734
  _i = 0, _Array$from = Array.from(this.historyWindows.items);
1923
1735
  case 1:
1924
1736
  if (!(_i < _Array$from.length)) {
1925
- _context2.n = 11;
1737
+ _context2.n = 8;
1926
1738
  break;
1927
1739
  }
1928
1740
  _Array$from$_i = RoomMessagesHistory_slicedToArray(_Array$from[_i], 2), window = _Array$from$_i[1];
@@ -1934,40 +1746,28 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
1934
1746
  _context2.n = 4;
1935
1747
  break;
1936
1748
  }
1937
- return _context2.a(3, 10);
1749
+ return _context2.a(3, 7);
1938
1750
  case 4:
1939
- if (!(window.state !== WindowState.LATEST)) {
1751
+ if (!(window.state === WindowState.LATEST)) {
1940
1752
  _context2.n = 5;
1941
1753
  break;
1942
1754
  }
1943
- return _context2.a(3, 10);
1944
- case 5:
1945
- if (!this.timeLimitedHistory) {
1946
- _context2.n = 7;
1947
- break;
1948
- }
1949
- _context2.n = 6;
1950
- return window.resyncToLatest();
1951
- case 6:
1952
- _context2.n = 8;
1953
- break;
1954
- case 7:
1955
- _context2.n = 8;
1755
+ _context2.n = 5;
1956
1756
  return window.resetToLatest(true);
1957
- case 8:
1958
- _context2.n = 10;
1757
+ case 5:
1758
+ _context2.n = 7;
1959
1759
  break;
1960
- case 9:
1961
- _context2.p = 9;
1760
+ case 6:
1761
+ _context2.p = 6;
1962
1762
  _t = _context2.v;
1963
- case 10:
1763
+ case 7:
1964
1764
  _i++;
1965
1765
  _context2.n = 1;
1966
1766
  break;
1967
- case 11:
1767
+ case 8:
1968
1768
  return _context2.a(2);
1969
1769
  }
1970
- }, _callee2, this, [[2, 9]]);
1770
+ }, _callee2, this, [[2, 6]]);
1971
1771
  }));
1972
1772
  function resync(_x2) {
1973
1773
  return _resync.apply(this, arguments);
@@ -1987,7 +1787,7 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
1987
1787
  break;
1988
1788
  }
1989
1789
  this.room = ev.room;
1990
- this.updateHistoryMode(ev.room);
1790
+ this.updateTraverseLock(ev.room);
1991
1791
  if (ev.room.defaultTopic) {
1992
1792
  this.createHistoryWindowForTopic(ev.room.defaultTopic);
1993
1793
  }
@@ -2065,11 +1865,9 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
2065
1865
  }
2066
1866
  }
2067
1867
  }, {
2068
- key: "updateHistoryMode",
2069
- value: function updateHistoryMode(room) {
2070
- var _room$history, _room$history2;
2071
- this.traverseLock = ((_room$history = room.history) === null || _room$history === void 0 ? void 0 : _room$history.mode) === 'Ephemeral';
2072
- this.timeLimitedHistory = ((_room$history2 = room.history) === null || _room$history2 === void 0 ? void 0 : _room$history2.mode) === 'MaxAge';
1868
+ key: "updateTraverseLock",
1869
+ value: function updateTraverseLock(room) {
1870
+ this.traverseLock = room.history.mode === 'Ephemeral';
2073
1871
  }
2074
1872
  }]);
2075
1873
  }();
@@ -5264,7 +5062,7 @@ var UsersManager = /*#__PURE__*/function () {
5264
5062
  _this$users;
5265
5063
  users.forEach(function (newUser) {
5266
5064
  var oldUser = _this2.users.get(newUser.id);
5267
- if (oldUser && oldUser.online !== newUser.online) {
5065
+ if (oldUser && oldUser.status !== newUser.status) {
5268
5066
  _this2.onlineStatus.emit('change', newUser);
5269
5067
  }
5270
5068
  });
@@ -5433,28 +5231,28 @@ var ChatStateTracker = /*#__PURE__*/function () {
5433
5231
  var _this = this;
5434
5232
  ChatStateTracker_classCallCheck(this, ChatStateTracker);
5435
5233
  ChatStateTracker_defineProperty(this, "client", void 0);
5436
- /**
5437
- * State of your permissions.
5234
+ /**
5235
+ * State of your permissions.
5438
5236
  */
5439
5237
  ChatStateTracker_defineProperty(this, "permissions", void 0);
5440
- /**
5441
- * State of the rooms you are in.
5238
+ /**
5239
+ * State of the rooms you are in.
5442
5240
  */
5443
5241
  ChatStateTracker_defineProperty(this, "rooms", void 0);
5444
- /**
5445
- * State of the spaces you are in.
5242
+ /**
5243
+ * State of the spaces you are in.
5446
5244
  */
5447
5245
  ChatStateTracker_defineProperty(this, "spaces", void 0);
5448
- /**
5449
- * State of the emoticons (global and space-related).
5246
+ /**
5247
+ * State of the emoticons (global and space-related).
5450
5248
  */
5451
5249
  ChatStateTracker_defineProperty(this, "emoticons", void 0);
5452
- /**
5453
- * Users related state.
5250
+ /**
5251
+ * Users related state.
5454
5252
  */
5455
5253
  ChatStateTracker_defineProperty(this, "users", void 0);
5456
- /**
5457
- * State of relationships with other users.
5254
+ /**
5255
+ * State of relationships with other users.
5458
5256
  */
5459
5257
  ChatStateTracker_defineProperty(this, "relationships", void 0);
5460
5258
  ChatStateTracker_defineProperty(this, "_me", null);
@@ -6250,6 +6048,178 @@ var FilesClient = /*#__PURE__*/function (_AbstractRestClient) {
6250
6048
  }()
6251
6049
  }]);
6252
6050
  }(AbstractRestClient);
6051
+ ;// ./src/types/src/schemes/User.ts
6052
+ /**
6053
+ * Availability of a user, aggregated over all of their sessions.
6054
+ *
6055
+ * - `Offline` - no session is connected and none can be reached asynchronously.
6056
+ * - `Online` - at least one session holds a live connection.
6057
+ * - `OnlineAsync` - no live connection, but a push-registered device was active
6058
+ * recently, so a message will still reach the user.
6059
+ */
6060
+ var UserStatus = /*#__PURE__*/function (UserStatus) {
6061
+ UserStatus[UserStatus["Offline"] = 0] = "Offline";
6062
+ UserStatus[UserStatus["Online"] = 1] = "Online";
6063
+ UserStatus[UserStatus["OnlineAsync"] = 2] = "OnlineAsync";
6064
+ return UserStatus;
6065
+ }({});
6066
+ ;// ./src/types/src/index.ts
6067
+
6068
+
6069
+
6070
+
6071
+
6072
+
6073
+
6074
+
6075
+
6076
+
6077
+
6078
+
6079
+
6080
+
6081
+
6082
+
6083
+
6084
+
6085
+
6086
+
6087
+
6088
+
6089
+
6090
+
6091
+
6092
+
6093
+
6094
+
6095
+
6096
+
6097
+
6098
+
6099
+
6100
+
6101
+
6102
+
6103
+
6104
+
6105
+
6106
+
6107
+
6108
+
6109
+
6110
+
6111
+
6112
+
6113
+
6114
+
6115
+
6116
+
6117
+
6118
+
6119
+
6120
+
6121
+
6122
+
6123
+
6124
+
6125
+
6126
+
6127
+
6128
+
6129
+
6130
+
6131
+
6132
+
6133
+
6134
+
6135
+
6136
+
6137
+
6138
+
6139
+
6140
+
6141
+
6142
+
6143
+
6144
+
6145
+
6146
+
6147
+
6148
+
6149
+
6150
+
6151
+
6152
+
6153
+
6154
+
6155
+
6156
+
6157
+
6158
+
6159
+
6160
+
6161
+
6162
+
6163
+
6164
+
6165
+
6166
+
6167
+
6168
+
6169
+
6170
+
6171
+
6172
+
6173
+
6174
+
6175
+
6176
+
6177
+
6178
+
6179
+
6180
+
6181
+
6182
+
6183
+
6184
+
6185
+
6186
+
6187
+
6188
+
6189
+
6190
+
6191
+
6192
+
6193
+
6194
+
6195
+
6196
+
6197
+
6198
+
6199
+
6200
+
6201
+
6202
+
6203
+
6204
+
6205
+
6206
+
6207
+
6208
+
6209
+
6210
+
6211
+
6212
+
6213
+
6214
+
6215
+
6216
+
6217
+
6218
+
6219
+
6220
+
6221
+
6222
+
6253
6223
  ;// ./src/index.ts
6254
6224
 
6255
6225
 
@@ -6259,6 +6229,7 @@ var FilesClient = /*#__PURE__*/function (_AbstractRestClient) {
6259
6229
 
6260
6230
 
6261
6231
 
6232
+
6262
6233
  module.exports = __webpack_exports__;
6263
6234
  /******/ })()
6264
6235
  ;