polfan-server-js-client 0.2.94 → 0.2.96
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/.idea/workspace.xml +52 -29
- package/build/index.cjs.js +451 -185
- package/build/index.cjs.js.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/build/types/AbstractChatClient.d.ts +2 -1
- package/build/types/types/src/index.d.ts +2 -1
- package/build/types/types/src/schemes/commands/SetSessionData.d.ts +8 -0
- package/package.json +1 -1
- package/src/AbstractChatClient.ts +2 -1
- package/src/state-tracker/MessagesManager.ts +18 -9
- package/src/types/src/index.ts +3 -0
- package/src/types/src/schemes/commands/SetSessionData.ts +9 -0
package/build/index.cjs.js
CHANGED
|
@@ -1705,12 +1705,12 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
|
|
|
1705
1705
|
}();
|
|
1706
1706
|
;// ./src/state-tracker/MessagesManager.ts
|
|
1707
1707
|
function MessagesManager_typeof(o) { "@babel/helpers - typeof"; return MessagesManager_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; }, MessagesManager_typeof(o); }
|
|
1708
|
+
function MessagesManager_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; }
|
|
1709
|
+
function MessagesManager_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? MessagesManager_ownKeys(Object(t), !0).forEach(function (r) { MessagesManager_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : MessagesManager_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1708
1710
|
function MessagesManager_toConsumableArray(r) { return MessagesManager_arrayWithoutHoles(r) || MessagesManager_iterableToArray(r) || MessagesManager_unsupportedIterableToArray(r) || MessagesManager_nonIterableSpread(); }
|
|
1709
1711
|
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."); }
|
|
1710
1712
|
function MessagesManager_iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
1711
1713
|
function MessagesManager_arrayWithoutHoles(r) { if (Array.isArray(r)) return MessagesManager_arrayLikeToArray(r); }
|
|
1712
|
-
function MessagesManager_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; }
|
|
1713
|
-
function MessagesManager_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? MessagesManager_ownKeys(Object(t), !0).forEach(function (r) { MessagesManager_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : MessagesManager_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1714
1714
|
function MessagesManager_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = MessagesManager_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
1715
1715
|
function MessagesManager_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return MessagesManager_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) ? MessagesManager_arrayLikeToArray(r, a) : void 0; } }
|
|
1716
1716
|
function MessagesManager_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; }
|
|
@@ -1735,6 +1735,7 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1735
1735
|
MessagesManager_defineProperty(this, "followedTopics", new IndexedCollection());
|
|
1736
1736
|
MessagesManager_defineProperty(this, "followedTopicsPromises", new PromiseRegistry());
|
|
1737
1737
|
MessagesManager_defineProperty(this, "deferredSession", new DeferredTask());
|
|
1738
|
+
MessagesManager_defineProperty(this, "unreadSummariesCache", new Map());
|
|
1738
1739
|
this.tracker = tracker;
|
|
1739
1740
|
this.tracker.client.on('Session', function (ev) {
|
|
1740
1741
|
return _this.handleSession(ev);
|
|
@@ -1751,9 +1752,6 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1751
1752
|
this.tracker.client.on('TopicFollowed', function (ev) {
|
|
1752
1753
|
return _this.handleTopicFollowed(ev);
|
|
1753
1754
|
});
|
|
1754
|
-
this.tracker.client.on('TopicUnfollowed', function (ev) {
|
|
1755
|
-
return _this.handleTopicUnfollowed(ev);
|
|
1756
|
-
});
|
|
1757
1755
|
this.tracker.client.on('NewMessage', function (ev) {
|
|
1758
1756
|
return _this.handleNewMessage(ev);
|
|
1759
1757
|
});
|
|
@@ -1799,63 +1797,88 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1799
1797
|
}, {
|
|
1800
1798
|
key: "cacheSpaceFollowedTopics",
|
|
1801
1799
|
value: (function () {
|
|
1802
|
-
var _cacheSpaceFollowedTopics = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function
|
|
1800
|
+
var _cacheSpaceFollowedTopics = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function _callee3(spaceId) {
|
|
1803
1801
|
var _this2 = this;
|
|
1804
|
-
var roomIds,
|
|
1805
|
-
return MessagesManager_regenerator().w(function (
|
|
1806
|
-
while (1) switch (
|
|
1802
|
+
var rooms, roomIds, isAlreadyCached, spaceRegistryKey, _t;
|
|
1803
|
+
return MessagesManager_regenerator().w(function (_context3) {
|
|
1804
|
+
while (1) switch (_context3.n) {
|
|
1807
1805
|
case 0:
|
|
1808
1806
|
_t = spaceId;
|
|
1809
1807
|
if (!_t) {
|
|
1810
|
-
|
|
1808
|
+
_context3.n = 2;
|
|
1811
1809
|
break;
|
|
1812
1810
|
}
|
|
1813
|
-
|
|
1811
|
+
_context3.n = 1;
|
|
1814
1812
|
return this.tracker.spaces.get();
|
|
1815
1813
|
case 1:
|
|
1816
|
-
_t = !
|
|
1814
|
+
_t = !_context3.v.has(spaceId);
|
|
1817
1815
|
case 2:
|
|
1818
1816
|
if (!_t) {
|
|
1819
|
-
|
|
1817
|
+
_context3.n = 3;
|
|
1820
1818
|
break;
|
|
1821
1819
|
}
|
|
1822
1820
|
throw new Error("You are not in space ".concat(spaceId));
|
|
1823
1821
|
case 3:
|
|
1824
|
-
|
|
1822
|
+
_context3.n = 4;
|
|
1825
1823
|
return this.tracker.rooms.get();
|
|
1826
1824
|
case 4:
|
|
1827
|
-
|
|
1828
|
-
|
|
1825
|
+
rooms = _context3.v;
|
|
1826
|
+
roomIds = spaceId ? rooms.findBy('spaceId', spaceId).items.map(function (r) {
|
|
1827
|
+
return r.id;
|
|
1828
|
+
}) : rooms.items.filter(function (r) {
|
|
1829
|
+
return !r.spaceId;
|
|
1830
|
+
}).map(function (r) {
|
|
1831
|
+
return r.id;
|
|
1829
1832
|
});
|
|
1830
1833
|
if (roomIds.length) {
|
|
1831
|
-
|
|
1834
|
+
_context3.n = 5;
|
|
1832
1835
|
break;
|
|
1833
1836
|
}
|
|
1834
|
-
return
|
|
1837
|
+
return _context3.a(2);
|
|
1835
1838
|
case 5:
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
spaceId: spaceId
|
|
1839
|
-
}
|
|
1840
|
-
});
|
|
1841
|
-
roomIds.forEach(function (roomId) {
|
|
1842
|
-
return _this2.followedTopicsPromises.register(resultPromise, roomId);
|
|
1839
|
+
isAlreadyCached = roomIds.every(function (roomId) {
|
|
1840
|
+
return _this2.followedTopics.has(roomId);
|
|
1843
1841
|
});
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
case 6:
|
|
1847
|
-
result = _context2.v;
|
|
1848
|
-
if (!result.error) {
|
|
1849
|
-
_context2.n = 7;
|
|
1842
|
+
if (!isAlreadyCached) {
|
|
1843
|
+
_context3.n = 6;
|
|
1850
1844
|
break;
|
|
1851
1845
|
}
|
|
1852
|
-
|
|
1846
|
+
return _context3.a(2);
|
|
1847
|
+
case 6:
|
|
1848
|
+
spaceRegistryKey = "space_fetch_".concat(spaceId || 'spaceless');
|
|
1849
|
+
if (this.followedTopicsPromises.notExist(spaceRegistryKey)) {
|
|
1850
|
+
this.followedTopicsPromises.registerByFunction(/*#__PURE__*/MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function _callee2() {
|
|
1851
|
+
var result;
|
|
1852
|
+
return MessagesManager_regenerator().w(function (_context2) {
|
|
1853
|
+
while (1) switch (_context2.n) {
|
|
1854
|
+
case 0:
|
|
1855
|
+
_context2.n = 1;
|
|
1856
|
+
return _this2.tracker.client.send('GetFollowedTopics', {
|
|
1857
|
+
location: {
|
|
1858
|
+
spaceId: spaceId
|
|
1859
|
+
}
|
|
1860
|
+
});
|
|
1861
|
+
case 1:
|
|
1862
|
+
result = _context2.v;
|
|
1863
|
+
if (!result.error) {
|
|
1864
|
+
_context2.n = 2;
|
|
1865
|
+
break;
|
|
1866
|
+
}
|
|
1867
|
+
throw result.error;
|
|
1868
|
+
case 2:
|
|
1869
|
+
_this2.setFollowedTopicsArray(roomIds, result.data.followedTopics);
|
|
1870
|
+
case 3:
|
|
1871
|
+
return _context2.a(2);
|
|
1872
|
+
}
|
|
1873
|
+
}, _callee2);
|
|
1874
|
+
})), spaceRegistryKey);
|
|
1875
|
+
}
|
|
1876
|
+
_context3.n = 7;
|
|
1877
|
+
return this.followedTopicsPromises.get(spaceRegistryKey);
|
|
1853
1878
|
case 7:
|
|
1854
|
-
|
|
1855
|
-
case 8:
|
|
1856
|
-
return _context2.a(2);
|
|
1879
|
+
return _context3.a(2);
|
|
1857
1880
|
}
|
|
1858
|
-
},
|
|
1881
|
+
}, _callee3, this);
|
|
1859
1882
|
}));
|
|
1860
1883
|
function cacheSpaceFollowedTopics(_x2) {
|
|
1861
1884
|
return _cacheSpaceFollowedTopics.apply(this, arguments);
|
|
@@ -1870,57 +1893,57 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1870
1893
|
}, {
|
|
1871
1894
|
key: "getRoomFollowedTopics",
|
|
1872
1895
|
value: (function () {
|
|
1873
|
-
var _getRoomFollowedTopics = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function
|
|
1896
|
+
var _getRoomFollowedTopics = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function _callee5(roomId) {
|
|
1874
1897
|
var _this3 = this;
|
|
1875
|
-
return MessagesManager_regenerator().w(function (
|
|
1876
|
-
while (1) switch (
|
|
1898
|
+
return MessagesManager_regenerator().w(function (_context5) {
|
|
1899
|
+
while (1) switch (_context5.n) {
|
|
1877
1900
|
case 0:
|
|
1878
|
-
|
|
1901
|
+
_context5.n = 1;
|
|
1879
1902
|
return this.tracker.rooms.get();
|
|
1880
1903
|
case 1:
|
|
1881
|
-
if (
|
|
1882
|
-
|
|
1904
|
+
if (_context5.v.has(roomId)) {
|
|
1905
|
+
_context5.n = 2;
|
|
1883
1906
|
break;
|
|
1884
1907
|
}
|
|
1885
|
-
return
|
|
1908
|
+
return _context5.a(2, undefined);
|
|
1886
1909
|
case 2:
|
|
1887
1910
|
if (this.followedTopics.has(roomId)) {
|
|
1888
|
-
|
|
1911
|
+
_context5.n = 3;
|
|
1889
1912
|
break;
|
|
1890
1913
|
}
|
|
1891
1914
|
if (this.followedTopicsPromises.notExist(roomId)) {
|
|
1892
|
-
this.followedTopicsPromises.registerByFunction(/*#__PURE__*/MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function
|
|
1915
|
+
this.followedTopicsPromises.registerByFunction(/*#__PURE__*/MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function _callee4() {
|
|
1893
1916
|
var result;
|
|
1894
|
-
return MessagesManager_regenerator().w(function (
|
|
1895
|
-
while (1) switch (
|
|
1917
|
+
return MessagesManager_regenerator().w(function (_context4) {
|
|
1918
|
+
while (1) switch (_context4.n) {
|
|
1896
1919
|
case 0:
|
|
1897
|
-
|
|
1920
|
+
_context4.n = 1;
|
|
1898
1921
|
return _this3.tracker.client.send('GetFollowedTopics', {
|
|
1899
1922
|
location: {
|
|
1900
1923
|
roomId: roomId
|
|
1901
1924
|
}
|
|
1902
1925
|
});
|
|
1903
1926
|
case 1:
|
|
1904
|
-
result =
|
|
1927
|
+
result = _context4.v;
|
|
1905
1928
|
if (!result.error) {
|
|
1906
|
-
|
|
1929
|
+
_context4.n = 2;
|
|
1907
1930
|
break;
|
|
1908
1931
|
}
|
|
1909
1932
|
throw result.error;
|
|
1910
1933
|
case 2:
|
|
1911
1934
|
_this3.setFollowedTopicsArray([roomId], result.data.followedTopics);
|
|
1912
1935
|
case 3:
|
|
1913
|
-
return
|
|
1936
|
+
return _context4.a(2);
|
|
1914
1937
|
}
|
|
1915
|
-
},
|
|
1938
|
+
}, _callee4);
|
|
1916
1939
|
})), roomId);
|
|
1917
1940
|
}
|
|
1918
|
-
|
|
1941
|
+
_context5.n = 3;
|
|
1919
1942
|
return this.followedTopicsPromises.get(roomId);
|
|
1920
1943
|
case 3:
|
|
1921
|
-
return
|
|
1944
|
+
return _context5.a(2, this.followedTopics.get(roomId));
|
|
1922
1945
|
}
|
|
1923
|
-
},
|
|
1946
|
+
}, _callee5, this);
|
|
1924
1947
|
}));
|
|
1925
1948
|
function getRoomFollowedTopics(_x3) {
|
|
1926
1949
|
return _getRoomFollowedTopics.apply(this, arguments);
|
|
@@ -1928,102 +1951,220 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1928
1951
|
return getRoomFollowedTopics;
|
|
1929
1952
|
}()
|
|
1930
1953
|
/**
|
|
1931
|
-
* Batch acknowledge all
|
|
1954
|
+
* Batch acknowledge all messages for given room.
|
|
1932
1955
|
*/
|
|
1933
1956
|
)
|
|
1934
1957
|
}, {
|
|
1935
|
-
key: "
|
|
1958
|
+
key: "ackRoom",
|
|
1936
1959
|
value: (function () {
|
|
1937
|
-
var
|
|
1960
|
+
var _ackRoom = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function _callee6(roomId) {
|
|
1938
1961
|
var collection, _iterator, _step, followedTopic, _t2;
|
|
1939
|
-
return MessagesManager_regenerator().w(function (
|
|
1940
|
-
while (1) switch (
|
|
1962
|
+
return MessagesManager_regenerator().w(function (_context6) {
|
|
1963
|
+
while (1) switch (_context6.p = _context6.n) {
|
|
1941
1964
|
case 0:
|
|
1942
|
-
|
|
1965
|
+
_context6.n = 1;
|
|
1943
1966
|
return this.getRoomFollowedTopics(roomId);
|
|
1944
1967
|
case 1:
|
|
1945
|
-
collection =
|
|
1968
|
+
collection = _context6.v;
|
|
1946
1969
|
if (collection) {
|
|
1947
|
-
|
|
1970
|
+
_context6.n = 2;
|
|
1948
1971
|
break;
|
|
1949
1972
|
}
|
|
1950
|
-
return
|
|
1973
|
+
return _context6.a(2);
|
|
1951
1974
|
case 2:
|
|
1952
1975
|
_iterator = MessagesManager_createForOfIteratorHelper(collection.items);
|
|
1953
|
-
|
|
1976
|
+
_context6.p = 3;
|
|
1954
1977
|
_iterator.s();
|
|
1955
1978
|
case 4:
|
|
1956
1979
|
if ((_step = _iterator.n()).done) {
|
|
1957
|
-
|
|
1980
|
+
_context6.n = 6;
|
|
1958
1981
|
break;
|
|
1959
1982
|
}
|
|
1960
1983
|
followedTopic = _step.value;
|
|
1961
|
-
if (!followedTopic.
|
|
1962
|
-
|
|
1984
|
+
if (!followedTopic.isUnread) {
|
|
1985
|
+
_context6.n = 5;
|
|
1963
1986
|
break;
|
|
1964
1987
|
}
|
|
1965
|
-
|
|
1988
|
+
_context6.n = 5;
|
|
1966
1989
|
return this.tracker.client.send('Ack', {
|
|
1967
1990
|
location: followedTopic.location
|
|
1968
1991
|
});
|
|
1969
1992
|
case 5:
|
|
1970
|
-
|
|
1993
|
+
_context6.n = 4;
|
|
1971
1994
|
break;
|
|
1972
1995
|
case 6:
|
|
1973
|
-
|
|
1996
|
+
_context6.n = 8;
|
|
1974
1997
|
break;
|
|
1975
1998
|
case 7:
|
|
1976
|
-
|
|
1977
|
-
_t2 =
|
|
1999
|
+
_context6.p = 7;
|
|
2000
|
+
_t2 = _context6.v;
|
|
1978
2001
|
_iterator.e(_t2);
|
|
1979
2002
|
case 8:
|
|
1980
|
-
|
|
2003
|
+
_context6.p = 8;
|
|
1981
2004
|
_iterator.f();
|
|
1982
|
-
return
|
|
2005
|
+
return _context6.f(8);
|
|
1983
2006
|
case 9:
|
|
1984
|
-
return
|
|
2007
|
+
return _context6.a(2);
|
|
1985
2008
|
}
|
|
1986
|
-
},
|
|
2009
|
+
}, _callee6, this, [[3, 7, 8, 9]]);
|
|
1987
2010
|
}));
|
|
1988
|
-
function
|
|
1989
|
-
return
|
|
2011
|
+
function ackRoom(_x4) {
|
|
2012
|
+
return _ackRoom.apply(this, arguments);
|
|
1990
2013
|
}
|
|
1991
|
-
return
|
|
2014
|
+
return ackRoom;
|
|
1992
2015
|
}()
|
|
1993
2016
|
/**
|
|
1994
|
-
* Calculate missed messages from any topic in given room.
|
|
2017
|
+
* Calculate missed messages with mentions from any topic in given room.
|
|
1995
2018
|
* @return Undefined if you are not in room.
|
|
1996
2019
|
*/
|
|
1997
2020
|
)
|
|
1998
2021
|
}, {
|
|
1999
|
-
key: "
|
|
2022
|
+
key: "summarizeUnreadMessages",
|
|
2000
2023
|
value: (function () {
|
|
2001
|
-
var
|
|
2002
|
-
var collection;
|
|
2003
|
-
return MessagesManager_regenerator().w(function (
|
|
2004
|
-
while (1) switch (
|
|
2024
|
+
var _summarizeUnreadMessages = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function _callee7(location) {
|
|
2025
|
+
var cacheKey, roomIds, targetTopicId, rooms, mentionCount, isUnread, _iterator2, _step2, roomId, collection, _iterator3, _step3, _topic$mentionCount, topic, result, _t3, _t4;
|
|
2026
|
+
return MessagesManager_regenerator().w(function (_context7) {
|
|
2027
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
2005
2028
|
case 0:
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
collection = _context6.v;
|
|
2010
|
-
if (!collection) {
|
|
2011
|
-
_context6.n = 2;
|
|
2029
|
+
cacheKey = location.topicId ? "topic:".concat(location.roomId, ":").concat(location.topicId) : location.roomId ? "room:".concat(location.roomId) : location.spaceId ? "space:".concat(location.spaceId) : 'spaceless';
|
|
2030
|
+
if (!this.unreadSummariesCache.has(cacheKey)) {
|
|
2031
|
+
_context7.n = 1;
|
|
2012
2032
|
break;
|
|
2013
2033
|
}
|
|
2014
|
-
return
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2034
|
+
return _context7.a(2, this.unreadSummariesCache.get(cacheKey));
|
|
2035
|
+
case 1:
|
|
2036
|
+
roomIds = [];
|
|
2037
|
+
_context7.n = 2;
|
|
2038
|
+
return this.tracker.rooms.get();
|
|
2018
2039
|
case 2:
|
|
2019
|
-
|
|
2040
|
+
rooms = _context7.v;
|
|
2041
|
+
if (!location.topicId) {
|
|
2042
|
+
_context7.n = 4;
|
|
2043
|
+
break;
|
|
2044
|
+
}
|
|
2045
|
+
if (location.roomId) {
|
|
2046
|
+
_context7.n = 3;
|
|
2047
|
+
break;
|
|
2048
|
+
}
|
|
2049
|
+
throw new Error("roomId is required when querying by topicId");
|
|
2050
|
+
case 3:
|
|
2051
|
+
roomIds = [location.roomId];
|
|
2052
|
+
targetTopicId = location.topicId;
|
|
2053
|
+
_context7.n = 9;
|
|
2054
|
+
break;
|
|
2055
|
+
case 4:
|
|
2056
|
+
if (!location.roomId) {
|
|
2057
|
+
_context7.n = 5;
|
|
2058
|
+
break;
|
|
2059
|
+
}
|
|
2060
|
+
roomIds = [location.roomId];
|
|
2061
|
+
_context7.n = 9;
|
|
2062
|
+
break;
|
|
2063
|
+
case 5:
|
|
2064
|
+
if (!location.spaceId) {
|
|
2065
|
+
_context7.n = 7;
|
|
2066
|
+
break;
|
|
2067
|
+
}
|
|
2068
|
+
_context7.n = 6;
|
|
2069
|
+
return this.cacheSpaceFollowedTopics(location.spaceId);
|
|
2070
|
+
case 6:
|
|
2071
|
+
roomIds = rooms.findBy('spaceId', location.spaceId).items.map(function (r) {
|
|
2072
|
+
return r.id;
|
|
2073
|
+
});
|
|
2074
|
+
_context7.n = 9;
|
|
2075
|
+
break;
|
|
2076
|
+
case 7:
|
|
2077
|
+
_context7.n = 8;
|
|
2078
|
+
return this.cacheSpaceFollowedTopics(null);
|
|
2079
|
+
case 8:
|
|
2080
|
+
roomIds = rooms.items.filter(function (r) {
|
|
2081
|
+
return !r.spaceId;
|
|
2082
|
+
}).map(function (r) {
|
|
2083
|
+
return r.id;
|
|
2084
|
+
});
|
|
2085
|
+
case 9:
|
|
2086
|
+
mentionCount = 0;
|
|
2087
|
+
isUnread = false;
|
|
2088
|
+
_iterator2 = MessagesManager_createForOfIteratorHelper(roomIds);
|
|
2089
|
+
_context7.p = 10;
|
|
2090
|
+
_iterator2.s();
|
|
2091
|
+
case 11:
|
|
2092
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
2093
|
+
_context7.n = 22;
|
|
2094
|
+
break;
|
|
2095
|
+
}
|
|
2096
|
+
roomId = _step2.value;
|
|
2097
|
+
_context7.n = 12;
|
|
2098
|
+
return this.getRoomFollowedTopics(roomId);
|
|
2099
|
+
case 12:
|
|
2100
|
+
collection = _context7.v;
|
|
2101
|
+
if (collection) {
|
|
2102
|
+
_context7.n = 13;
|
|
2103
|
+
break;
|
|
2104
|
+
}
|
|
2105
|
+
return _context7.a(3, 21);
|
|
2106
|
+
case 13:
|
|
2107
|
+
_iterator3 = MessagesManager_createForOfIteratorHelper(collection.items);
|
|
2108
|
+
_context7.p = 14;
|
|
2109
|
+
_iterator3.s();
|
|
2110
|
+
case 15:
|
|
2111
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
2112
|
+
_context7.n = 18;
|
|
2113
|
+
break;
|
|
2114
|
+
}
|
|
2115
|
+
topic = _step3.value;
|
|
2116
|
+
if (!(targetTopicId && topic.location.topicId !== targetTopicId)) {
|
|
2117
|
+
_context7.n = 16;
|
|
2118
|
+
break;
|
|
2119
|
+
}
|
|
2120
|
+
return _context7.a(3, 17);
|
|
2121
|
+
case 16:
|
|
2122
|
+
if (topic.isUnread) {
|
|
2123
|
+
isUnread = true;
|
|
2124
|
+
}
|
|
2125
|
+
mentionCount += (_topic$mentionCount = topic.mentionCount) !== null && _topic$mentionCount !== void 0 ? _topic$mentionCount : 0;
|
|
2126
|
+
case 17:
|
|
2127
|
+
_context7.n = 15;
|
|
2128
|
+
break;
|
|
2129
|
+
case 18:
|
|
2130
|
+
_context7.n = 20;
|
|
2131
|
+
break;
|
|
2132
|
+
case 19:
|
|
2133
|
+
_context7.p = 19;
|
|
2134
|
+
_t3 = _context7.v;
|
|
2135
|
+
_iterator3.e(_t3);
|
|
2136
|
+
case 20:
|
|
2137
|
+
_context7.p = 20;
|
|
2138
|
+
_iterator3.f();
|
|
2139
|
+
return _context7.f(20);
|
|
2140
|
+
case 21:
|
|
2141
|
+
_context7.n = 11;
|
|
2142
|
+
break;
|
|
2143
|
+
case 22:
|
|
2144
|
+
_context7.n = 24;
|
|
2145
|
+
break;
|
|
2146
|
+
case 23:
|
|
2147
|
+
_context7.p = 23;
|
|
2148
|
+
_t4 = _context7.v;
|
|
2149
|
+
_iterator2.e(_t4);
|
|
2150
|
+
case 24:
|
|
2151
|
+
_context7.p = 24;
|
|
2152
|
+
_iterator2.f();
|
|
2153
|
+
return _context7.f(24);
|
|
2154
|
+
case 25:
|
|
2155
|
+
result = {
|
|
2156
|
+
mentionCount: mentionCount,
|
|
2157
|
+
isUnread: isUnread
|
|
2158
|
+
};
|
|
2159
|
+
this.unreadSummariesCache.set(cacheKey, result);
|
|
2160
|
+
return _context7.a(2, result);
|
|
2020
2161
|
}
|
|
2021
|
-
},
|
|
2162
|
+
}, _callee7, this, [[14, 19, 20, 21], [10, 23, 24, 25]]);
|
|
2022
2163
|
}));
|
|
2023
|
-
function
|
|
2024
|
-
return
|
|
2164
|
+
function summarizeUnreadMessages(_x5) {
|
|
2165
|
+
return _summarizeUnreadMessages.apply(this, arguments);
|
|
2025
2166
|
}
|
|
2026
|
-
return
|
|
2167
|
+
return summarizeUnreadMessages;
|
|
2027
2168
|
}()
|
|
2028
2169
|
/**
|
|
2029
2170
|
* For internal use. If you want to delete the message, execute a proper command on client object.
|
|
@@ -2033,11 +2174,15 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
2033
2174
|
}, {
|
|
2034
2175
|
key: "_deleteByTopicIds",
|
|
2035
2176
|
value: function _deleteByTopicIds(roomId) {
|
|
2036
|
-
var _this$followedTopics
|
|
2177
|
+
var _this$followedTopics$,
|
|
2178
|
+
_this4 = this;
|
|
2037
2179
|
for (var _len = arguments.length, topicIds = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2038
2180
|
topicIds[_key - 1] = arguments[_key];
|
|
2039
2181
|
}
|
|
2040
2182
|
(_this$followedTopics$ = this.followedTopics.get(roomId)) === null || _this$followedTopics$ === void 0 || _this$followedTopics$["delete"].apply(_this$followedTopics$, topicIds);
|
|
2183
|
+
topicIds.forEach(function (topicId) {
|
|
2184
|
+
return _this4.invalidateUnreadSummaries(roomId, topicId);
|
|
2185
|
+
});
|
|
2041
2186
|
}
|
|
2042
2187
|
|
|
2043
2188
|
/**
|
|
@@ -2047,41 +2192,116 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
2047
2192
|
}, {
|
|
2048
2193
|
key: "_resolveLastMessage",
|
|
2049
2194
|
value: (function () {
|
|
2050
|
-
var _resolveLastMessage2 = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function
|
|
2195
|
+
var _resolveLastMessage2 = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function _callee8(location) {
|
|
2051
2196
|
var message, _result$data, result;
|
|
2052
|
-
return MessagesManager_regenerator().w(function (
|
|
2053
|
-
while (1) switch (
|
|
2197
|
+
return MessagesManager_regenerator().w(function (_context8) {
|
|
2198
|
+
while (1) switch (_context8.n) {
|
|
2054
2199
|
case 0:
|
|
2055
|
-
|
|
2200
|
+
_context8.n = 1;
|
|
2056
2201
|
return this.getRoomHistory(location.roomId).then(function (roomHistory) {
|
|
2057
2202
|
return roomHistory === null || roomHistory === void 0 ? void 0 : roomHistory.getMessagesWindow(location.topicId, true);
|
|
2058
2203
|
}).then(function (historyWindow) {
|
|
2059
2204
|
return (historyWindow === null || historyWindow === void 0 ? void 0 : historyWindow.hasLatest) && historyWindow.getAt(historyWindow.length - 1);
|
|
2060
2205
|
});
|
|
2061
2206
|
case 1:
|
|
2062
|
-
message =
|
|
2207
|
+
message = _context8.v;
|
|
2063
2208
|
if (message) {
|
|
2064
|
-
|
|
2209
|
+
_context8.n = 3;
|
|
2065
2210
|
break;
|
|
2066
2211
|
}
|
|
2067
|
-
|
|
2212
|
+
_context8.n = 2;
|
|
2068
2213
|
return this.tracker.client.send('GetMessages', {
|
|
2069
2214
|
location: location,
|
|
2070
2215
|
limit: 1
|
|
2071
2216
|
});
|
|
2072
2217
|
case 2:
|
|
2073
|
-
result =
|
|
2218
|
+
result = _context8.v;
|
|
2074
2219
|
message = (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.messages[0];
|
|
2075
2220
|
case 3:
|
|
2076
|
-
return
|
|
2221
|
+
return _context8.a(2, message || null);
|
|
2077
2222
|
}
|
|
2078
|
-
},
|
|
2223
|
+
}, _callee8, this);
|
|
2079
2224
|
}));
|
|
2080
2225
|
function _resolveLastMessage(_x6) {
|
|
2081
2226
|
return _resolveLastMessage2.apply(this, arguments);
|
|
2082
2227
|
}
|
|
2083
2228
|
return _resolveLastMessage;
|
|
2084
|
-
}()
|
|
2229
|
+
}()
|
|
2230
|
+
/**
|
|
2231
|
+
* Wyczyść cache celowo, tylko dla lokalizacji których dotyczy zmiana.
|
|
2232
|
+
*/
|
|
2233
|
+
)
|
|
2234
|
+
}, {
|
|
2235
|
+
key: "invalidateUnreadSummaries",
|
|
2236
|
+
value: function invalidateUnreadSummaries(roomId, topicId) {
|
|
2237
|
+
if (!roomId) {
|
|
2238
|
+
this.unreadSummariesCache.clear();
|
|
2239
|
+
return;
|
|
2240
|
+
}
|
|
2241
|
+
this.unreadSummariesCache["delete"]("room:".concat(roomId));
|
|
2242
|
+
if (topicId) {
|
|
2243
|
+
this.unreadSummariesCache["delete"]("topic:".concat(roomId, ":").concat(topicId));
|
|
2244
|
+
} else {
|
|
2245
|
+
var _iterator4 = MessagesManager_createForOfIteratorHelper(this.unreadSummariesCache.keys()),
|
|
2246
|
+
_step4;
|
|
2247
|
+
try {
|
|
2248
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2249
|
+
var key = _step4.value;
|
|
2250
|
+
if (key.startsWith("topic:".concat(roomId, ":"))) {
|
|
2251
|
+
this.unreadSummariesCache["delete"](key);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
} catch (err) {
|
|
2255
|
+
_iterator4.e(err);
|
|
2256
|
+
} finally {
|
|
2257
|
+
_iterator4.f();
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
var _iterator5 = MessagesManager_createForOfIteratorHelper(this.unreadSummariesCache.keys()),
|
|
2261
|
+
_step5;
|
|
2262
|
+
try {
|
|
2263
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
2264
|
+
var _key2 = _step5.value;
|
|
2265
|
+
if (_key2.startsWith('space:') || _key2 === 'spaceless') {
|
|
2266
|
+
this.unreadSummariesCache["delete"](_key2);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
} catch (err) {
|
|
2270
|
+
_iterator5.e(err);
|
|
2271
|
+
} finally {
|
|
2272
|
+
_iterator5.f();
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
}, {
|
|
2276
|
+
key: "invalidateUnreadSummariesForRooms",
|
|
2277
|
+
value: function invalidateUnreadSummariesForRooms(roomIds) {
|
|
2278
|
+
var _this5 = this;
|
|
2279
|
+
var roomIdsSet = new Set(roomIds);
|
|
2280
|
+
roomIds.forEach(function (roomId) {
|
|
2281
|
+
_this5.unreadSummariesCache["delete"]("room:".concat(roomId));
|
|
2282
|
+
});
|
|
2283
|
+
var _iterator6 = MessagesManager_createForOfIteratorHelper(this.unreadSummariesCache.keys()),
|
|
2284
|
+
_step6;
|
|
2285
|
+
try {
|
|
2286
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
2287
|
+
var key = _step6.value;
|
|
2288
|
+
if (key.startsWith('space:') || key === 'spaceless') {
|
|
2289
|
+
this.unreadSummariesCache["delete"](key);
|
|
2290
|
+
continue;
|
|
2291
|
+
}
|
|
2292
|
+
if (key.startsWith('topic:')) {
|
|
2293
|
+
var parts = key.split(':');
|
|
2294
|
+
if (parts.length >= 2 && roomIdsSet.has(parts[1])) {
|
|
2295
|
+
this.unreadSummariesCache["delete"](key);
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
} catch (err) {
|
|
2300
|
+
_iterator6.e(err);
|
|
2301
|
+
} finally {
|
|
2302
|
+
_iterator6.f();
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2085
2305
|
}, {
|
|
2086
2306
|
key: "createHistoryForNewRoom",
|
|
2087
2307
|
value: function createHistoryForNewRoom(room) {
|
|
@@ -2090,24 +2310,20 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
2090
2310
|
}, {
|
|
2091
2311
|
key: "handleNewMessage",
|
|
2092
2312
|
value: function handleNewMessage(ev) {
|
|
2093
|
-
this.updateLocallyFollowedTopicOnNewMessage(ev);
|
|
2313
|
+
void this.updateLocallyFollowedTopicOnNewMessage(ev);
|
|
2094
2314
|
}
|
|
2095
2315
|
}, {
|
|
2096
2316
|
key: "handleFollowedTopicUpdated",
|
|
2097
2317
|
value: function handleFollowedTopicUpdated(ev) {
|
|
2098
2318
|
var _this$followedTopics$2;
|
|
2099
2319
|
(_this$followedTopics$2 = this.followedTopics.get(ev.followedTopic.location.roomId)) === null || _this$followedTopics$2 === void 0 || _this$followedTopics$2.set(ev.followedTopic);
|
|
2320
|
+
this.invalidateUnreadSummaries(ev.followedTopic.location.roomId, ev.followedTopic.location.topicId);
|
|
2100
2321
|
}
|
|
2101
2322
|
}, {
|
|
2102
2323
|
key: "handleTopicFollowed",
|
|
2103
2324
|
value: function handleTopicFollowed(ev) {
|
|
2104
2325
|
this.setFollowedTopicsArray([ev.followedTopic.location.roomId], [ev.followedTopic]);
|
|
2105
|
-
|
|
2106
|
-
}, {
|
|
2107
|
-
key: "handleTopicUnfollowed",
|
|
2108
|
-
value: function handleTopicUnfollowed(ev) {
|
|
2109
|
-
var _this$followedTopics$3;
|
|
2110
|
-
(_this$followedTopics$3 = this.followedTopics.get(ev.location.roomId)) === null || _this$followedTopics$3 === void 0 || _this$followedTopics$3["delete"](ev.location.topicId);
|
|
2326
|
+
this.invalidateUnreadSummaries(ev.followedTopic.location.roomId, ev.followedTopic.location.topicId);
|
|
2111
2327
|
}
|
|
2112
2328
|
}, {
|
|
2113
2329
|
key: "handleRoomDeleted",
|
|
@@ -2130,16 +2346,16 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
2130
2346
|
}, {
|
|
2131
2347
|
key: "handleNewTopic",
|
|
2132
2348
|
value: function () {
|
|
2133
|
-
var _handleNewTopic = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function
|
|
2349
|
+
var _handleNewTopic = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function _callee9(ev) {
|
|
2134
2350
|
var result, followedTopic;
|
|
2135
|
-
return MessagesManager_regenerator().w(function (
|
|
2136
|
-
while (1) switch (
|
|
2351
|
+
return MessagesManager_regenerator().w(function (_context9) {
|
|
2352
|
+
while (1) switch (_context9.n) {
|
|
2137
2353
|
case 0:
|
|
2138
2354
|
if (!this.followedTopics.has(ev.roomId)) {
|
|
2139
|
-
|
|
2355
|
+
_context9.n = 2;
|
|
2140
2356
|
break;
|
|
2141
2357
|
}
|
|
2142
|
-
|
|
2358
|
+
_context9.n = 1;
|
|
2143
2359
|
return this.tracker.client.send('GetFollowedTopics', {
|
|
2144
2360
|
location: {
|
|
2145
2361
|
roomId: ev.roomId,
|
|
@@ -2147,15 +2363,16 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
2147
2363
|
}
|
|
2148
2364
|
});
|
|
2149
2365
|
case 1:
|
|
2150
|
-
result =
|
|
2366
|
+
result = _context9.v;
|
|
2151
2367
|
followedTopic = result.data.followedTopics[0];
|
|
2152
2368
|
if (followedTopic) {
|
|
2153
2369
|
this.followedTopics.get(ev.roomId).set(followedTopic);
|
|
2370
|
+
this.invalidateUnreadSummaries(ev.roomId, ev.topic.id);
|
|
2154
2371
|
}
|
|
2155
2372
|
case 2:
|
|
2156
|
-
return
|
|
2373
|
+
return _context9.a(2);
|
|
2157
2374
|
}
|
|
2158
|
-
},
|
|
2375
|
+
}, _callee9, this);
|
|
2159
2376
|
}));
|
|
2160
2377
|
function handleNewTopic(_x7) {
|
|
2161
2378
|
return _handleNewTopic.apply(this, arguments);
|
|
@@ -2165,51 +2382,98 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
2165
2382
|
}, {
|
|
2166
2383
|
key: "handleTopicDeleted",
|
|
2167
2384
|
value: function handleTopicDeleted(ev) {
|
|
2168
|
-
var _this$followedTopics$
|
|
2169
|
-
(_this$followedTopics$
|
|
2385
|
+
var _this$followedTopics$3;
|
|
2386
|
+
(_this$followedTopics$3 = this.followedTopics.get(ev.location.roomId)) === null || _this$followedTopics$3 === void 0 || _this$followedTopics$3["delete"](ev.location.topicId);
|
|
2387
|
+
this.invalidateUnreadSummaries(ev.location.roomId, ev.location.topicId);
|
|
2170
2388
|
}
|
|
2171
2389
|
}, {
|
|
2172
2390
|
key: "handleSession",
|
|
2173
2391
|
value: function handleSession(ev) {
|
|
2174
|
-
var
|
|
2392
|
+
var _this6 = this;
|
|
2175
2393
|
this.followedTopics.deleteAll();
|
|
2176
2394
|
this.followedTopicsPromises.forgetAll();
|
|
2395
|
+
this.invalidateUnreadSummaries();
|
|
2177
2396
|
this.roomHistories.deleteAll();
|
|
2178
2397
|
ev.state.rooms.forEach(function (room) {
|
|
2179
|
-
return
|
|
2398
|
+
return _this6.createHistoryForNewRoom(room);
|
|
2180
2399
|
});
|
|
2181
2400
|
this.deferredSession.resolve();
|
|
2182
2401
|
}
|
|
2183
2402
|
}, {
|
|
2184
2403
|
key: "updateLocallyFollowedTopicOnNewMessage",
|
|
2185
|
-
value: function
|
|
2186
|
-
var
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2404
|
+
value: function () {
|
|
2405
|
+
var _updateLocallyFollowedTopicOnNewMessage = MessagesManager_asyncToGenerator(/*#__PURE__*/MessagesManager_regenerator().m(function _callee0(ev) {
|
|
2406
|
+
var _this$tracker$me;
|
|
2407
|
+
var roomFollowedTopics, followedTopic, isMe, update, _member$spaceMember$r, _member$spaceMember, member, roleIds, mentionHandlers, mentionExists;
|
|
2408
|
+
return MessagesManager_regenerator().w(function (_context0) {
|
|
2409
|
+
while (1) switch (_context0.n) {
|
|
2410
|
+
case 0:
|
|
2411
|
+
roomFollowedTopics = this.followedTopics.get(ev.message.location.roomId);
|
|
2412
|
+
followedTopic = roomFollowedTopics === null || roomFollowedTopics === void 0 ? void 0 : roomFollowedTopics.get(ev.message.location.topicId);
|
|
2413
|
+
if (!(!roomFollowedTopics || !followedTopic || ev.message.type === 'Ephemeral')) {
|
|
2414
|
+
_context0.n = 1;
|
|
2415
|
+
break;
|
|
2416
|
+
}
|
|
2417
|
+
return _context0.a(2);
|
|
2418
|
+
case 1:
|
|
2419
|
+
isMe = ev.message.author.user.id === ((_this$tracker$me = this.tracker.me) === null || _this$tracker$me === void 0 ? void 0 : _this$tracker$me.id);
|
|
2420
|
+
if (!isMe) {
|
|
2421
|
+
_context0.n = 2;
|
|
2422
|
+
break;
|
|
2423
|
+
}
|
|
2424
|
+
// Reset missed messages count if new message is authored by me
|
|
2425
|
+
update = {
|
|
2426
|
+
missed: 0,
|
|
2427
|
+
lastAckMessageId: ev.message.id
|
|
2428
|
+
};
|
|
2429
|
+
_context0.n = 5;
|
|
2430
|
+
break;
|
|
2431
|
+
case 2:
|
|
2432
|
+
if (!(ev.message.type === 'Text')) {
|
|
2433
|
+
_context0.n = 4;
|
|
2434
|
+
break;
|
|
2435
|
+
}
|
|
2436
|
+
_context0.n = 3;
|
|
2437
|
+
return this.tracker.rooms.getMe(ev.message.location.roomId);
|
|
2438
|
+
case 3:
|
|
2439
|
+
member = _context0.v;
|
|
2440
|
+
roleIds = [].concat(MessagesManager_toConsumableArray((_member$spaceMember$r = (_member$spaceMember = member.spaceMember) === null || _member$spaceMember === void 0 ? void 0 : _member$spaceMember.roles) !== null && _member$spaceMember$r !== void 0 ? _member$spaceMember$r : []), MessagesManager_toConsumableArray(member.roles));
|
|
2441
|
+
mentionHandlers = [].concat(MessagesManager_toConsumableArray(roleIds.map(function (id) {
|
|
2442
|
+
return "<@&".concat(id, ">");
|
|
2443
|
+
})), ["<@".concat(ev.message.author.user.id, ">")]);
|
|
2444
|
+
mentionExists = mentionHandlers.some(function (handler) {
|
|
2445
|
+
return ev.message.content.includes(handler);
|
|
2446
|
+
});
|
|
2447
|
+
update = {
|
|
2448
|
+
missed: followedTopic.missed === null ? null : followedTopic.missed + 1,
|
|
2449
|
+
isUnread: true,
|
|
2450
|
+
mentionCount: followedTopic.mentionCount + (mentionExists ? 1 : 0)
|
|
2451
|
+
};
|
|
2452
|
+
_context0.n = 5;
|
|
2453
|
+
break;
|
|
2454
|
+
case 4:
|
|
2455
|
+
// ...or just mark as unread.
|
|
2456
|
+
update = {
|
|
2457
|
+
missed: followedTopic.missed === null ? null : followedTopic.missed + 1,
|
|
2458
|
+
isUnread: true
|
|
2459
|
+
};
|
|
2460
|
+
case 5:
|
|
2461
|
+
roomFollowedTopics.set(MessagesManager_objectSpread(MessagesManager_objectSpread({}, followedTopic), update));
|
|
2462
|
+
this.invalidateUnreadSummaries(ev.message.location.roomId, ev.message.location.topicId);
|
|
2463
|
+
case 6:
|
|
2464
|
+
return _context0.a(2);
|
|
2465
|
+
}
|
|
2466
|
+
}, _callee0, this);
|
|
2467
|
+
}));
|
|
2468
|
+
function updateLocallyFollowedTopicOnNewMessage(_x8) {
|
|
2469
|
+
return _updateLocallyFollowedTopicOnNewMessage.apply(this, arguments);
|
|
2206
2470
|
}
|
|
2207
|
-
|
|
2208
|
-
}
|
|
2471
|
+
return updateLocallyFollowedTopicOnNewMessage;
|
|
2472
|
+
}()
|
|
2209
2473
|
}, {
|
|
2210
2474
|
key: "setFollowedTopicsArray",
|
|
2211
2475
|
value: function setFollowedTopicsArray(roomIds, followedTopics) {
|
|
2212
|
-
var
|
|
2476
|
+
var _this7 = this;
|
|
2213
2477
|
var roomToTopics = {};
|
|
2214
2478
|
|
|
2215
2479
|
// Reassign followed topics to limit collection change event emit
|
|
@@ -2219,22 +2483,24 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
2219
2483
|
roomToTopics[followedTopic.location.roomId].push(followedTopic);
|
|
2220
2484
|
});
|
|
2221
2485
|
roomIds.forEach(function (roomId) {
|
|
2222
|
-
if (!
|
|
2223
|
-
|
|
2486
|
+
if (!_this7.followedTopics.has(roomId)) {
|
|
2487
|
+
_this7.followedTopics.set([roomId, new ObservableIndexedObjectCollection(function (followedTopic) {
|
|
2224
2488
|
return followedTopic.location.topicId;
|
|
2225
2489
|
})]);
|
|
2226
2490
|
}
|
|
2227
2491
|
if (roomToTopics[roomId]) {
|
|
2228
|
-
var
|
|
2229
|
-
(
|
|
2492
|
+
var _this7$followedTopics;
|
|
2493
|
+
(_this7$followedTopics = _this7.followedTopics.get(roomId)).set.apply(_this7$followedTopics, MessagesManager_toConsumableArray(roomToTopics[roomId]));
|
|
2230
2494
|
}
|
|
2231
2495
|
});
|
|
2496
|
+
this.invalidateUnreadSummariesForRooms(roomIds);
|
|
2232
2497
|
}
|
|
2233
2498
|
}, {
|
|
2234
2499
|
key: "clearRoomFollowedTopicsStructures",
|
|
2235
2500
|
value: function clearRoomFollowedTopicsStructures(roomId) {
|
|
2236
2501
|
this.followedTopics["delete"](roomId);
|
|
2237
2502
|
this.followedTopicsPromises.forget(roomId);
|
|
2503
|
+
this.invalidateUnreadSummaries(roomId);
|
|
2238
2504
|
}
|
|
2239
2505
|
}]);
|
|
2240
2506
|
}();
|
|
@@ -2979,8 +3245,8 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
2979
3245
|
});
|
|
2980
3246
|
}
|
|
2981
3247
|
|
|
2982
|
-
/**
|
|
2983
|
-
* Get collection of all the spaces you are in.
|
|
3248
|
+
/**
|
|
3249
|
+
* Get collection of all the spaces you are in.
|
|
2984
3250
|
*/
|
|
2985
3251
|
return SpacesManager_createClass(SpacesManager, [{
|
|
2986
3252
|
key: "get",
|
|
@@ -3001,8 +3267,8 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
3001
3267
|
}
|
|
3002
3268
|
return get;
|
|
3003
3269
|
}()
|
|
3004
|
-
/**
|
|
3005
|
-
* Get collection of space roles.
|
|
3270
|
+
/**
|
|
3271
|
+
* Get collection of space roles.
|
|
3006
3272
|
*/
|
|
3007
3273
|
)
|
|
3008
3274
|
}, {
|
|
@@ -3024,8 +3290,8 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
3024
3290
|
}
|
|
3025
3291
|
return getRoles;
|
|
3026
3292
|
}()
|
|
3027
|
-
/**
|
|
3028
|
-
* Get collection of the all available rooms inside given space.
|
|
3293
|
+
/**
|
|
3294
|
+
* Get collection of the all available rooms inside given space.
|
|
3029
3295
|
*/
|
|
3030
3296
|
)
|
|
3031
3297
|
}, {
|
|
@@ -3073,8 +3339,8 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
3073
3339
|
}
|
|
3074
3340
|
return getRooms;
|
|
3075
3341
|
}()
|
|
3076
|
-
/**
|
|
3077
|
-
* Get collection of space members.
|
|
3342
|
+
/**
|
|
3343
|
+
* Get collection of space members.
|
|
3078
3344
|
*/
|
|
3079
3345
|
)
|
|
3080
3346
|
}, {
|
|
@@ -3122,8 +3388,8 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
3122
3388
|
}
|
|
3123
3389
|
return getMembers;
|
|
3124
3390
|
}()
|
|
3125
|
-
/**
|
|
3126
|
-
* Get a space member representing the current user.
|
|
3391
|
+
/**
|
|
3392
|
+
* Get a space member representing the current user.
|
|
3127
3393
|
*/
|
|
3128
3394
|
)
|
|
3129
3395
|
}, {
|
|
@@ -3315,9 +3581,9 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
3315
3581
|
case 0:
|
|
3316
3582
|
spaceId = this.roomIdToSpaceId.get(ev.summary.id);
|
|
3317
3583
|
summariesPromise = this.roomsPromises.get(spaceId);
|
|
3318
|
-
/**
|
|
3319
|
-
* Update summary only if the list was already loaded.
|
|
3320
|
-
* RoomSummaryUpdated event has a partial summary, so we need to update the existing summary by merging it.
|
|
3584
|
+
/**
|
|
3585
|
+
* Update summary only if the list was already loaded.
|
|
3586
|
+
* RoomSummaryUpdated event has a partial summary, so we need to update the existing summary by merging it.
|
|
3321
3587
|
*/
|
|
3322
3588
|
if (!(spaceId && summariesPromise)) {
|
|
3323
3589
|
_context9.n = 2;
|
|
@@ -4493,28 +4759,28 @@ var ChatStateTracker = /*#__PURE__*/function () {
|
|
|
4493
4759
|
var _this = this;
|
|
4494
4760
|
ChatStateTracker_classCallCheck(this, ChatStateTracker);
|
|
4495
4761
|
ChatStateTracker_defineProperty(this, "client", void 0);
|
|
4496
|
-
/**
|
|
4497
|
-
* State of your permissions.
|
|
4762
|
+
/**
|
|
4763
|
+
* State of your permissions.
|
|
4498
4764
|
*/
|
|
4499
4765
|
ChatStateTracker_defineProperty(this, "permissions", void 0);
|
|
4500
|
-
/**
|
|
4501
|
-
* State of the rooms you are in.
|
|
4766
|
+
/**
|
|
4767
|
+
* State of the rooms you are in.
|
|
4502
4768
|
*/
|
|
4503
4769
|
ChatStateTracker_defineProperty(this, "rooms", void 0);
|
|
4504
|
-
/**
|
|
4505
|
-
* State of the spaces you are in.
|
|
4770
|
+
/**
|
|
4771
|
+
* State of the spaces you are in.
|
|
4506
4772
|
*/
|
|
4507
4773
|
ChatStateTracker_defineProperty(this, "spaces", void 0);
|
|
4508
|
-
/**
|
|
4509
|
-
* State of the emoticons (global and space-related).
|
|
4774
|
+
/**
|
|
4775
|
+
* State of the emoticons (global and space-related).
|
|
4510
4776
|
*/
|
|
4511
4777
|
ChatStateTracker_defineProperty(this, "emoticons", void 0);
|
|
4512
|
-
/**
|
|
4513
|
-
* Users related state.
|
|
4778
|
+
/**
|
|
4779
|
+
* Users related state.
|
|
4514
4780
|
*/
|
|
4515
4781
|
ChatStateTracker_defineProperty(this, "users", void 0);
|
|
4516
|
-
/**
|
|
4517
|
-
* State of relationships with other users.
|
|
4782
|
+
/**
|
|
4783
|
+
* State of relationships with other users.
|
|
4518
4784
|
*/
|
|
4519
4785
|
ChatStateTracker_defineProperty(this, "relationships", void 0);
|
|
4520
4786
|
ChatStateTracker_defineProperty(this, "_me", null);
|