polfan-server-js-client 0.1.97 → 0.1.99
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
|
@@ -627,9 +627,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
627
627
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { MessagesManager_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
628
628
|
function MessagesManager_toConsumableArray(arr) { return MessagesManager_arrayWithoutHoles(arr) || MessagesManager_iterableToArray(arr) || MessagesManager_unsupportedIterableToArray(arr) || MessagesManager_nonIterableSpread(); }
|
|
629
629
|
function MessagesManager_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."); }
|
|
630
|
-
function MessagesManager_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return MessagesManager_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return MessagesManager_arrayLikeToArray(o, minLen); }
|
|
631
630
|
function MessagesManager_iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
632
631
|
function MessagesManager_arrayWithoutHoles(arr) { if (Array.isArray(arr)) return MessagesManager_arrayLikeToArray(arr); }
|
|
632
|
+
function MessagesManager_createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = MessagesManager_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
633
|
+
function MessagesManager_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return MessagesManager_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return MessagesManager_arrayLikeToArray(o, minLen); }
|
|
633
634
|
function MessagesManager_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
634
635
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == MessagesManager_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
635
636
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
@@ -641,6 +642,7 @@ function MessagesManager_defineProperty(obj, key, value) { key = MessagesManager
|
|
|
641
642
|
function MessagesManager_toPropertyKey(arg) { var key = MessagesManager_toPrimitive(arg, "string"); return MessagesManager_typeof(key) === "symbol" ? key : String(key); }
|
|
642
643
|
function MessagesManager_toPrimitive(input, hint) { if (MessagesManager_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (MessagesManager_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
643
644
|
|
|
645
|
+
|
|
644
646
|
var getCombinedId = function getCombinedId(location) {
|
|
645
647
|
var _location$roomId, _location$topicId;
|
|
646
648
|
return ((_location$roomId = location.roomId) !== null && _location$roomId !== void 0 ? _location$roomId : '') + ((_location$topicId = location.topicId) !== null && _location$topicId !== void 0 ? _location$topicId : '');
|
|
@@ -654,6 +656,7 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
654
656
|
this.tracker = tracker;
|
|
655
657
|
MessagesManager_defineProperty(this, "list", new IndexedCollection());
|
|
656
658
|
MessagesManager_defineProperty(this, "followedTopics", new IndexedCollection());
|
|
659
|
+
MessagesManager_defineProperty(this, "followedTopicsPromises", new PromiseRegistry());
|
|
657
660
|
this.tracker.client.on('Session', function (ev) {
|
|
658
661
|
return _this.handleSession(ev);
|
|
659
662
|
});
|
|
@@ -711,8 +714,8 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
711
714
|
return get;
|
|
712
715
|
}()
|
|
713
716
|
/**
|
|
714
|
-
* Cache
|
|
715
|
-
* Then you can get
|
|
717
|
+
* Cache followed topics for all joined rooms in a space and fetch them in bulk if necessary.
|
|
718
|
+
* Then you can get them using getRoomFollowedTopics().
|
|
716
719
|
* @see getRoomFollowedTopics
|
|
717
720
|
*/
|
|
718
721
|
}, {
|
|
@@ -761,60 +764,196 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
761
764
|
return cacheSpaceFollowedTopic;
|
|
762
765
|
}()
|
|
763
766
|
/**
|
|
764
|
-
* Get ack reports for the given room.
|
|
765
|
-
* @
|
|
767
|
+
* Get ack reports for the given room.
|
|
768
|
+
* @return Undefined if you are not in the room, collection otherwise.
|
|
766
769
|
*/
|
|
767
770
|
}, {
|
|
768
771
|
key: "getRoomFollowedTopics",
|
|
769
772
|
value: function () {
|
|
770
|
-
var _getRoomFollowedTopics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
771
|
-
var
|
|
772
|
-
return _regeneratorRuntime().wrap(function
|
|
773
|
+
var _getRoomFollowedTopics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(roomId) {
|
|
774
|
+
var _this2 = this;
|
|
775
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
773
776
|
while (1) {
|
|
774
|
-
switch (
|
|
777
|
+
switch (_context4.prev = _context4.next) {
|
|
775
778
|
case 0:
|
|
776
|
-
|
|
779
|
+
_context4.next = 2;
|
|
777
780
|
return this.tracker.rooms.get();
|
|
778
781
|
case 2:
|
|
779
|
-
if (
|
|
780
|
-
|
|
782
|
+
if (_context4.sent.has(roomId)) {
|
|
783
|
+
_context4.next = 4;
|
|
781
784
|
break;
|
|
782
785
|
}
|
|
783
|
-
return
|
|
786
|
+
return _context4.abrupt("return", undefined);
|
|
784
787
|
case 4:
|
|
785
788
|
if (this.followedTopics.has(roomId)) {
|
|
786
|
-
|
|
789
|
+
_context4.next = 8;
|
|
787
790
|
break;
|
|
788
791
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
792
|
+
if (this.followedTopicsPromises.notExist(roomId)) {
|
|
793
|
+
this.followedTopicsPromises.registerByFunction( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
794
|
+
var result;
|
|
795
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
796
|
+
while (1) {
|
|
797
|
+
switch (_context3.prev = _context3.next) {
|
|
798
|
+
case 0:
|
|
799
|
+
_context3.next = 2;
|
|
800
|
+
return _this2.tracker.client.send('GetFollowedTopics', {
|
|
801
|
+
location: {
|
|
802
|
+
roomId: roomId
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
case 2:
|
|
806
|
+
result = _context3.sent;
|
|
807
|
+
if (!result.error) {
|
|
808
|
+
_context3.next = 5;
|
|
809
|
+
break;
|
|
810
|
+
}
|
|
811
|
+
throw result.error;
|
|
812
|
+
case 5:
|
|
813
|
+
_this2.setFollowedTopicsArray(result.data.followedTopics);
|
|
814
|
+
case 6:
|
|
815
|
+
case "end":
|
|
816
|
+
return _context3.stop();
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}, _callee3);
|
|
820
|
+
})), roomId);
|
|
800
821
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
case 12:
|
|
822
|
+
_context4.next = 8;
|
|
823
|
+
return this.followedTopicsPromises.get(roomId);
|
|
824
|
+
case 8:
|
|
825
|
+
return _context4.abrupt("return", this.followedTopics.get(roomId));
|
|
826
|
+
case 9:
|
|
807
827
|
case "end":
|
|
808
|
-
return
|
|
828
|
+
return _context4.stop();
|
|
809
829
|
}
|
|
810
830
|
}
|
|
811
|
-
},
|
|
831
|
+
}, _callee4, this);
|
|
812
832
|
}));
|
|
813
833
|
function getRoomFollowedTopics(_x3) {
|
|
814
834
|
return _getRoomFollowedTopics.apply(this, arguments);
|
|
815
835
|
}
|
|
816
836
|
return getRoomFollowedTopics;
|
|
817
837
|
}()
|
|
838
|
+
/**
|
|
839
|
+
* Batch acknowledge all missed messages from any topics in given room.
|
|
840
|
+
*/
|
|
841
|
+
}, {
|
|
842
|
+
key: "ackRoomFollowedTopics",
|
|
843
|
+
value: function () {
|
|
844
|
+
var _ackRoomFollowedTopics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(roomId) {
|
|
845
|
+
var collection, _iterator, _step, followedTopic;
|
|
846
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
847
|
+
while (1) {
|
|
848
|
+
switch (_context5.prev = _context5.next) {
|
|
849
|
+
case 0:
|
|
850
|
+
_context5.next = 2;
|
|
851
|
+
return this.getRoomFollowedTopics(roomId);
|
|
852
|
+
case 2:
|
|
853
|
+
collection = _context5.sent;
|
|
854
|
+
if (collection) {
|
|
855
|
+
_context5.next = 5;
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
return _context5.abrupt("return");
|
|
859
|
+
case 5:
|
|
860
|
+
_iterator = MessagesManager_createForOfIteratorHelper(collection.items);
|
|
861
|
+
_context5.prev = 6;
|
|
862
|
+
_iterator.s();
|
|
863
|
+
case 8:
|
|
864
|
+
if ((_step = _iterator.n()).done) {
|
|
865
|
+
_context5.next = 15;
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
followedTopic = _step.value;
|
|
869
|
+
if (!followedTopic.missed) {
|
|
870
|
+
_context5.next = 13;
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
_context5.next = 13;
|
|
874
|
+
return this.tracker.client.send('Ack', {
|
|
875
|
+
location: followedTopic.location
|
|
876
|
+
});
|
|
877
|
+
case 13:
|
|
878
|
+
_context5.next = 8;
|
|
879
|
+
break;
|
|
880
|
+
case 15:
|
|
881
|
+
_context5.next = 20;
|
|
882
|
+
break;
|
|
883
|
+
case 17:
|
|
884
|
+
_context5.prev = 17;
|
|
885
|
+
_context5.t0 = _context5["catch"](6);
|
|
886
|
+
_iterator.e(_context5.t0);
|
|
887
|
+
case 20:
|
|
888
|
+
_context5.prev = 20;
|
|
889
|
+
_iterator.f();
|
|
890
|
+
return _context5.finish(20);
|
|
891
|
+
case 23:
|
|
892
|
+
case "end":
|
|
893
|
+
return _context5.stop();
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}, _callee5, this, [[6, 17, 20, 23]]);
|
|
897
|
+
}));
|
|
898
|
+
function ackRoomFollowedTopics(_x4) {
|
|
899
|
+
return _ackRoomFollowedTopics.apply(this, arguments);
|
|
900
|
+
}
|
|
901
|
+
return ackRoomFollowedTopics;
|
|
902
|
+
}()
|
|
903
|
+
/**
|
|
904
|
+
* Calculate missed messages from any topic in given room.
|
|
905
|
+
* @return Undefined if you are not in room, stats object otherwise.
|
|
906
|
+
*/
|
|
907
|
+
}, {
|
|
908
|
+
key: "calculateRoomMissedMessages",
|
|
909
|
+
value: function () {
|
|
910
|
+
var _calculateRoomMissedMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(roomId) {
|
|
911
|
+
var collection, missed, missedMore, _iterator2, _step2, _ref2, _followedTopic$missed, followedTopic;
|
|
912
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
913
|
+
while (1) {
|
|
914
|
+
switch (_context6.prev = _context6.next) {
|
|
915
|
+
case 0:
|
|
916
|
+
_context6.next = 2;
|
|
917
|
+
return this.getRoomFollowedTopics(roomId);
|
|
918
|
+
case 2:
|
|
919
|
+
collection = _context6.sent;
|
|
920
|
+
if (collection) {
|
|
921
|
+
_context6.next = 5;
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
return _context6.abrupt("return", undefined);
|
|
925
|
+
case 5:
|
|
926
|
+
missed = 0, missedMore = false;
|
|
927
|
+
_iterator2 = MessagesManager_createForOfIteratorHelper(collection.items);
|
|
928
|
+
try {
|
|
929
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
930
|
+
followedTopic = _step2.value;
|
|
931
|
+
missed += (_ref2 = (_followedTopic$missed = followedTopic.missed) !== null && _followedTopic$missed !== void 0 ? _followedTopic$missed : followedTopic.missedMoreThan) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
|
932
|
+
if (followedTopic.missedMoreThan) {
|
|
933
|
+
missedMore = true;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
} catch (err) {
|
|
937
|
+
_iterator2.e(err);
|
|
938
|
+
} finally {
|
|
939
|
+
_iterator2.f();
|
|
940
|
+
}
|
|
941
|
+
return _context6.abrupt("return", {
|
|
942
|
+
missed: missed,
|
|
943
|
+
missedMore: missedMore
|
|
944
|
+
});
|
|
945
|
+
case 9:
|
|
946
|
+
case "end":
|
|
947
|
+
return _context6.stop();
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}, _callee6, this);
|
|
951
|
+
}));
|
|
952
|
+
function calculateRoomMissedMessages(_x5) {
|
|
953
|
+
return _calculateRoomMissedMessages.apply(this, arguments);
|
|
954
|
+
}
|
|
955
|
+
return calculateRoomMissedMessages;
|
|
956
|
+
}()
|
|
818
957
|
/**
|
|
819
958
|
* For internal use. If you want to delete the message, execute a proper command on client object.
|
|
820
959
|
* @internal
|
|
@@ -909,18 +1048,18 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
909
1048
|
}, {
|
|
910
1049
|
key: "handleNewTopic",
|
|
911
1050
|
value: function () {
|
|
912
|
-
var _handleNewTopic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1051
|
+
var _handleNewTopic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(ev) {
|
|
913
1052
|
var result, followedTopic;
|
|
914
|
-
return _regeneratorRuntime().wrap(function
|
|
1053
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
915
1054
|
while (1) {
|
|
916
|
-
switch (
|
|
1055
|
+
switch (_context7.prev = _context7.next) {
|
|
917
1056
|
case 0:
|
|
918
1057
|
this.createHistoryForNewTopic(ev.roomId, ev.topic);
|
|
919
1058
|
if (!this.followedTopics.has(ev.roomId)) {
|
|
920
|
-
|
|
1059
|
+
_context7.next = 7;
|
|
921
1060
|
break;
|
|
922
1061
|
}
|
|
923
|
-
|
|
1062
|
+
_context7.next = 4;
|
|
924
1063
|
return this.tracker.client.send('GetFollowedTopics', {
|
|
925
1064
|
location: {
|
|
926
1065
|
roomId: ev.roomId,
|
|
@@ -928,19 +1067,19 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
928
1067
|
}
|
|
929
1068
|
});
|
|
930
1069
|
case 4:
|
|
931
|
-
result =
|
|
1070
|
+
result = _context7.sent;
|
|
932
1071
|
followedTopic = result.data.followedTopics[0];
|
|
933
1072
|
if (followedTopic) {
|
|
934
1073
|
this.followedTopics.get(ev.roomId).set(followedTopic);
|
|
935
1074
|
}
|
|
936
1075
|
case 7:
|
|
937
1076
|
case "end":
|
|
938
|
-
return
|
|
1077
|
+
return _context7.stop();
|
|
939
1078
|
}
|
|
940
1079
|
}
|
|
941
|
-
},
|
|
1080
|
+
}, _callee7, this);
|
|
942
1081
|
}));
|
|
943
|
-
function handleNewTopic(
|
|
1082
|
+
function handleNewTopic(_x6) {
|
|
944
1083
|
return _handleNewTopic.apply(this, arguments);
|
|
945
1084
|
}
|
|
946
1085
|
return handleNewTopic;
|
|
@@ -954,10 +1093,10 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
954
1093
|
}, {
|
|
955
1094
|
key: "handleSession",
|
|
956
1095
|
value: function handleSession(ev) {
|
|
957
|
-
var
|
|
1096
|
+
var _this3 = this;
|
|
958
1097
|
ev.state.rooms.forEach(function (room) {
|
|
959
1098
|
if (room.defaultTopic) {
|
|
960
|
-
|
|
1099
|
+
_this3.createHistoryForNewTopic(room.id, room.defaultTopic);
|
|
961
1100
|
}
|
|
962
1101
|
});
|
|
963
1102
|
}
|