polfan-server-js-client 0.1.994 → 0.1.996

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -650,9 +650,10 @@ function TopicHistoryWindow_toPrimitive(input, hint) { if (TopicHistoryWindow_ty
650
650
 
651
651
  var WindowState;
652
652
  (function (WindowState) {
653
- WindowState[WindowState["UNINITIALIZED"] = 0] = "UNINITIALIZED";
653
+ WindowState[WindowState["LIVE"] = 0] = "LIVE";
654
654
  WindowState[WindowState["LATEST"] = 1] = "LATEST";
655
655
  WindowState[WindowState["PAST"] = 2] = "PAST";
656
+ WindowState[WindowState["OLDEST"] = 3] = "OLDEST";
656
657
  })(WindowState || (WindowState = {}));
657
658
  var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj) {
658
659
  TopicHistoryWindow_inherits(TraversableRemoteCollection, _ObservableIndexedObj);
@@ -665,7 +666,7 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
665
666
  }
666
667
  _this = _super.call.apply(_super, [this].concat(args));
667
668
  TopicHistoryWindow_defineProperty(TopicHistoryWindow_assertThisInitialized(_this), "limit", 50);
668
- TopicHistoryWindow_defineProperty(TopicHistoryWindow_assertThisInitialized(_this), "currentState", WindowState.UNINITIALIZED);
669
+ TopicHistoryWindow_defineProperty(TopicHistoryWindow_assertThisInitialized(_this), "currentState", WindowState.LIVE);
669
670
  TopicHistoryWindow_defineProperty(TopicHistoryWindow_assertThisInitialized(_this), "fetchingState", undefined);
670
671
  return _this;
671
672
  }
@@ -734,49 +735,46 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
734
735
  while (1) {
735
736
  switch (_context2.prev = _context2.next) {
736
737
  case 0:
738
+ if (!(this.state === WindowState.OLDEST)) {
739
+ _context2.next = 2;
740
+ break;
741
+ }
742
+ return _context2.abrupt("return");
743
+ case 2:
737
744
  this.throwIfFetchingInProgress();
738
745
  this.fetchingState = WindowState.PAST;
739
- _context2.prev = 2;
740
- _context2.next = 5;
746
+ _context2.prev = 4;
747
+ _context2.next = 7;
741
748
  return this.fetchItemsBefore();
742
- case 5:
749
+ case 7:
743
750
  result = _context2.sent;
744
- case 6:
745
- _context2.prev = 6;
751
+ case 8:
752
+ _context2.prev = 8;
746
753
  this.fetchingState = undefined;
747
- return _context2.finish(6);
748
- case 9:
754
+ return _context2.finish(8);
755
+ case 11:
749
756
  if (result) {
750
- _context2.next = 11;
757
+ _context2.next = 13;
751
758
  break;
752
759
  }
753
760
  return _context2.abrupt("return", this.resetToLatest());
754
- case 11:
755
- if (!result.length) {
756
- _context2.next = 21;
761
+ case 13:
762
+ if (result.length) {
763
+ _context2.next = 16;
757
764
  break;
758
765
  }
766
+ this.currentState = WindowState.OLDEST;
767
+ return _context2.abrupt("return");
768
+ case 16:
759
769
  this.addItems(result, 'head');
760
- _context2.next = 15;
761
- return this.isLatestItemLoaded();
762
- case 15:
763
- if (!_context2.sent) {
764
- _context2.next = 19;
765
- break;
766
- }
767
- _context2.t0 = WindowState.LATEST;
768
- _context2.next = 20;
769
- break;
770
+ _context2.next = 19;
771
+ return this.refreshFetchedState();
770
772
  case 19:
771
- _context2.t0 = WindowState.PAST;
772
- case 20:
773
- this.currentState = _context2.t0;
774
- case 21:
775
773
  case "end":
776
774
  return _context2.stop();
777
775
  }
778
776
  }
779
- }, _callee2, this, [[2,, 6, 9]]);
777
+ }, _callee2, this, [[4,, 8, 11]]);
780
778
  }));
781
779
  function fetchPrevious() {
782
780
  return _fetchPrevious.apply(this, arguments);
@@ -793,38 +791,39 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
793
791
  switch (_context3.prev = _context3.next) {
794
792
  case 0:
795
793
  this.throwIfFetchingInProgress();
796
- _context3.prev = 1;
797
- _context3.next = 4;
794
+ this.fetchingState = WindowState.PAST;
795
+ _context3.prev = 2;
796
+ _context3.next = 5;
798
797
  return this.fetchItemsAfter();
799
- case 4:
800
- result = _context3.sent;
801
798
  case 5:
802
- _context3.prev = 5;
799
+ result = _context3.sent;
800
+ case 6:
801
+ _context3.prev = 6;
803
802
  this.fetchingState = undefined;
804
- return _context3.finish(5);
805
- case 8:
803
+ return _context3.finish(6);
804
+ case 9:
806
805
  if (result) {
807
- _context3.next = 12;
806
+ _context3.next = 13;
808
807
  break;
809
808
  }
810
- _context3.next = 11;
809
+ _context3.next = 12;
811
810
  return this.resetToLatest();
812
- case 11:
813
- return _context3.abrupt("return");
814
811
  case 12:
812
+ return _context3.abrupt("return");
813
+ case 13:
815
814
  if (!result.length) {
816
- _context3.next = 16;
815
+ _context3.next = 17;
817
816
  break;
818
817
  }
819
818
  this.addItems(result, 'tail');
820
- _context3.next = 16;
821
- return this.refreshMode();
822
- case 16:
819
+ _context3.next = 17;
820
+ return this.refreshFetchedState();
821
+ case 17:
823
822
  case "end":
824
823
  return _context3.stop();
825
824
  }
826
825
  }
827
- }, _callee3, this, [[1,, 5, 8]]);
826
+ }, _callee3, this, [[2,, 6, 9]]);
828
827
  }));
829
828
  function fetchNext() {
830
829
  return _fetchNext.apply(this, arguments);
@@ -832,9 +831,9 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
832
831
  return fetchNext;
833
832
  }()
834
833
  }, {
835
- key: "refreshMode",
834
+ key: "refreshFetchedState",
836
835
  value: function () {
837
- var _refreshMode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
836
+ var _refreshFetchedState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
838
837
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
839
838
  while (1) {
840
839
  switch (_context4.prev = _context4.next) {
@@ -860,18 +859,11 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
860
859
  }
861
860
  }, _callee4, this);
862
861
  }));
863
- function refreshMode() {
864
- return _refreshMode.apply(this, arguments);
862
+ function refreshFetchedState() {
863
+ return _refreshFetchedState.apply(this, arguments);
865
864
  }
866
- return refreshMode;
865
+ return refreshFetchedState;
867
866
  }()
868
- }, {
869
- key: "throwIfFetchingInProgress",
870
- value: function throwIfFetchingInProgress() {
871
- if (this.fetchingState) {
872
- throw new Error("Items fetching in progress: ".concat(WindowState[this.fetchingState]));
873
- }
874
- }
875
867
  }, {
876
868
  key: "addItems",
877
869
  value: function addItems(newItems, to) {
@@ -885,6 +877,13 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
885
877
  this.deleteAll();
886
878
  this.set.apply(this, TopicHistoryWindow_toConsumableArray(result));
887
879
  }
880
+ }, {
881
+ key: "throwIfFetchingInProgress",
882
+ value: function throwIfFetchingInProgress() {
883
+ if (this.fetchingState) {
884
+ throw new Error("Items fetching in progress: ".concat(WindowState[this.fetchingState]));
885
+ }
886
+ }
888
887
 
889
888
  /**
890
889
  * Return array with messages of count that matching limit.
@@ -952,18 +951,10 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
952
951
  while (1) {
953
952
  switch (_context5.prev = _context5.next) {
954
953
  case 0:
955
- if (!([WindowState.LATEST, WindowState.UNINITIALIZED].includes(this.state) && ev.location.roomId === this.roomId && ev.location.topicId === this.topicId)) {
956
- _context5.next = 5;
957
- break;
954
+ if ([WindowState.LATEST, WindowState.LIVE].includes(this.state) && ev.location.roomId === this.roomId && ev.location.topicId === this.topicId) {
955
+ this.addItems([ev.message], 'tail');
958
956
  }
959
- this.set(ev.message);
960
- if (!(this.state === WindowState.UNINITIALIZED)) {
961
- _context5.next = 5;
962
- break;
963
- }
964
- _context5.next = 5;
965
- return this.refreshMode();
966
- case 5:
957
+ case 1:
967
958
  case "end":
968
959
  return _context5.stop();
969
960
  }
@@ -1189,7 +1180,7 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
1189
1180
  return this.getLatestMessageId();
1190
1181
  case 2:
1191
1182
  lastMessageId = _context11.sent;
1192
- return _context11.abrupt("return", lastMessageId ? this.has(lastMessageId) : false);
1183
+ return _context11.abrupt("return", lastMessageId ? this.has(lastMessageId) : true);
1193
1184
  case 4:
1194
1185
  case "end":
1195
1186
  return _context11.stop();