stream-chat 8.55.0 → 8.56.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.
- package/dist/browser.es.js +1165 -156
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +1169 -155
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1165 -156
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1169 -155
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_manager.d.ts +111 -0
- package/dist/types/channel_manager.d.ts.map +1 -0
- package/dist/types/client.d.ts +65 -2
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/insights.d.ts +2 -2
- package/dist/types/store.d.ts +3 -1
- package/dist/types/store.d.ts.map +1 -1
- package/dist/types/types.d.ts +11 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +91 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +6 -7
- package/src/channel_manager.ts +589 -0
- package/src/client.ts +27 -3
- package/src/index.ts +1 -0
- package/src/store.ts +4 -3
- package/src/types.ts +12 -0
- package/src/utils.ts +301 -0
package/dist/index.es.js
CHANGED
|
@@ -300,11 +300,11 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
300
300
|
return Campaign;
|
|
301
301
|
}();
|
|
302
302
|
|
|
303
|
-
function ownKeys$
|
|
303
|
+
function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
304
304
|
|
|
305
|
-
function _objectSpread$
|
|
305
|
+
function _objectSpread$e(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$e(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$e(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
306
306
|
|
|
307
|
-
function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(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) { function e(
|
|
307
|
+
function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(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) { function e(_x2) { return _e.apply(this, arguments); } e.toString = function () { return _e.toString(); }; return e; }(function (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 (_e2) { function e(_x3) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
308
308
|
|
|
309
309
|
function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(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 _arrayLikeToArray$5(o, minLen); }
|
|
310
310
|
|
|
@@ -399,8 +399,8 @@ function normalizeQuerySort(sort) {
|
|
|
399
399
|
|
|
400
400
|
try {
|
|
401
401
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
402
|
-
var
|
|
403
|
-
var entries = Object.entries(
|
|
402
|
+
var _item = _step.value;
|
|
403
|
+
var entries = Object.entries(_item);
|
|
404
404
|
|
|
405
405
|
if (entries.length > 1) {
|
|
406
406
|
console.warn("client._buildSort() - multiple fields in a single sort object detected. Object's field order is not guaranteed");
|
|
@@ -564,7 +564,7 @@ var axiosParamsSerializer = function axiosParamsSerializer(params) {
|
|
|
564
564
|
*/
|
|
565
565
|
|
|
566
566
|
function formatMessage(message) {
|
|
567
|
-
return _objectSpread$
|
|
567
|
+
return _objectSpread$e(_objectSpread$e({}, message), {}, {
|
|
568
568
|
/**
|
|
569
569
|
* @deprecated please use `html`
|
|
570
570
|
*/
|
|
@@ -808,6 +808,28 @@ var throttle = function throttle(fn) {
|
|
|
808
808
|
runningTimeout = setTimeout(timeoutHandler, timeout);
|
|
809
809
|
};
|
|
810
810
|
};
|
|
811
|
+
|
|
812
|
+
var get = function get(obj, path) {
|
|
813
|
+
return path.split('.').reduce(function (acc, key) {
|
|
814
|
+
if (acc && _typeof(acc) === 'object' && key in acc) {
|
|
815
|
+
return acc[key];
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
return undefined;
|
|
819
|
+
}, obj);
|
|
820
|
+
}; // works exactly the same as lodash.uniqBy
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
var uniqBy = function uniqBy(array, iteratee) {
|
|
824
|
+
if (!Array.isArray(array)) return [];
|
|
825
|
+
var seen = new Set();
|
|
826
|
+
return array.filter(function (item) {
|
|
827
|
+
var key = typeof iteratee === 'function' ? iteratee(item) : get(item, iteratee);
|
|
828
|
+
if (seen.has(key)) return false;
|
|
829
|
+
seen.add(key);
|
|
830
|
+
return true;
|
|
831
|
+
});
|
|
832
|
+
};
|
|
811
833
|
function binarySearchByDateEqualOrNearestGreater(array, targetDate) {
|
|
812
834
|
var left = 0;
|
|
813
835
|
var right = array.length - 1;
|
|
@@ -841,7 +863,7 @@ var messagePaginationCreatedAtAround = function messagePaginationCreatedAtAround
|
|
|
841
863
|
returnedPage = _ref4.returnedPage,
|
|
842
864
|
messagePaginationOptions = _ref4.messagePaginationOptions;
|
|
843
865
|
|
|
844
|
-
var newPagination = _objectSpread$
|
|
866
|
+
var newPagination = _objectSpread$e({}, parentSet.pagination);
|
|
845
867
|
|
|
846
868
|
if (!(messagePaginationOptions !== null && messagePaginationOptions !== void 0 && messagePaginationOptions.created_at_around)) return newPagination;
|
|
847
869
|
var hasPrev;
|
|
@@ -906,7 +928,7 @@ var messagePaginationIdAround = function messagePaginationIdAround(_ref6) {
|
|
|
906
928
|
returnedPage = _ref6.returnedPage,
|
|
907
929
|
messagePaginationOptions = _ref6.messagePaginationOptions;
|
|
908
930
|
|
|
909
|
-
var newPagination = _objectSpread$
|
|
931
|
+
var newPagination = _objectSpread$e({}, parentSet.pagination);
|
|
910
932
|
|
|
911
933
|
var _ref7 = messagePaginationOptions || {},
|
|
912
934
|
id_around = _ref7.id_around;
|
|
@@ -964,7 +986,7 @@ var messagePaginationLinear = function messagePaginationLinear(_ref9) {
|
|
|
964
986
|
returnedPage = _ref9.returnedPage,
|
|
965
987
|
messagePaginationOptions = _ref9.messagePaginationOptions;
|
|
966
988
|
|
|
967
|
-
var newPagination = _objectSpread$
|
|
989
|
+
var newPagination = _objectSpread$e({}, parentSet.pagination);
|
|
968
990
|
|
|
969
991
|
var hasPrev;
|
|
970
992
|
var hasNext;
|
|
@@ -1010,6 +1032,294 @@ var messageSetPagination = function messageSetPagination(params) {
|
|
|
1010
1032
|
return messagePaginationLinear(params);
|
|
1011
1033
|
}
|
|
1012
1034
|
};
|
|
1035
|
+
/**
|
|
1036
|
+
* A utility object used to prevent duplicate invocation of channel.watch() to be triggered when
|
|
1037
|
+
* 'notification.message_new' and 'notification.added_to_channel' events arrive at the same time.
|
|
1038
|
+
*/
|
|
1039
|
+
|
|
1040
|
+
var WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL = {};
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
|
|
1044
|
+
* If the channel is not passed as a property, it will get it either by its channel.cid or by its members list and do the same.
|
|
1045
|
+
* @param client
|
|
1046
|
+
* @param members
|
|
1047
|
+
* @param options
|
|
1048
|
+
* @param type
|
|
1049
|
+
* @param id
|
|
1050
|
+
* @param channel
|
|
1051
|
+
*/
|
|
1052
|
+
var getAndWatchChannel = /*#__PURE__*/function () {
|
|
1053
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref11) {
|
|
1054
|
+
var channel, client, id, members, options, type, channelToWatch, originalCid, queryPromise;
|
|
1055
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1056
|
+
while (1) {
|
|
1057
|
+
switch (_context.prev = _context.next) {
|
|
1058
|
+
case 0:
|
|
1059
|
+
channel = _ref11.channel, client = _ref11.client, id = _ref11.id, members = _ref11.members, options = _ref11.options, type = _ref11.type;
|
|
1060
|
+
|
|
1061
|
+
if (!(!channel && !type)) {
|
|
1062
|
+
_context.next = 3;
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
throw new Error('Channel or channel type have to be provided to query a channel.');
|
|
1067
|
+
|
|
1068
|
+
case 3:
|
|
1069
|
+
// unfortunately typescript is not able to infer that if (!channel && !type) === false, then channel or type has to be truthy
|
|
1070
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1071
|
+
channelToWatch = channel || client.channel(type, id, {
|
|
1072
|
+
members: members
|
|
1073
|
+
}); // need to keep as with call to channel.watch the id can be changed from undefined to an actual ID generated server-side
|
|
1074
|
+
|
|
1075
|
+
originalCid = channelToWatch.id ? channelToWatch.cid : members && members.length ? generateChannelTempCid(channelToWatch.type, members) : undefined;
|
|
1076
|
+
|
|
1077
|
+
if (originalCid) {
|
|
1078
|
+
_context.next = 7;
|
|
1079
|
+
break;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
throw new Error('Channel ID or channel members array have to be provided to query a channel.');
|
|
1083
|
+
|
|
1084
|
+
case 7:
|
|
1085
|
+
queryPromise = WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid];
|
|
1086
|
+
|
|
1087
|
+
if (!queryPromise) {
|
|
1088
|
+
_context.next = 13;
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
_context.next = 11;
|
|
1093
|
+
return queryPromise;
|
|
1094
|
+
|
|
1095
|
+
case 11:
|
|
1096
|
+
_context.next = 20;
|
|
1097
|
+
break;
|
|
1098
|
+
|
|
1099
|
+
case 13:
|
|
1100
|
+
_context.prev = 13;
|
|
1101
|
+
WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = channelToWatch.watch(options);
|
|
1102
|
+
_context.next = 17;
|
|
1103
|
+
return WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid];
|
|
1104
|
+
|
|
1105
|
+
case 17:
|
|
1106
|
+
_context.prev = 17;
|
|
1107
|
+
delete WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid];
|
|
1108
|
+
return _context.finish(17);
|
|
1109
|
+
|
|
1110
|
+
case 20:
|
|
1111
|
+
return _context.abrupt("return", channelToWatch);
|
|
1112
|
+
|
|
1113
|
+
case 21:
|
|
1114
|
+
case "end":
|
|
1115
|
+
return _context.stop();
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}, _callee, null, [[13,, 17, 20]]);
|
|
1119
|
+
}));
|
|
1120
|
+
|
|
1121
|
+
return function getAndWatchChannel(_x) {
|
|
1122
|
+
return _ref12.apply(this, arguments);
|
|
1123
|
+
};
|
|
1124
|
+
}();
|
|
1125
|
+
/**
|
|
1126
|
+
* Generates a temporary channel.cid for channels created without ID, as they need to be referenced
|
|
1127
|
+
* by an identifier until the back-end generates the final ID. The cid is generated by its member IDs
|
|
1128
|
+
* which are sorted and can be recreated the same every time given the same arguments.
|
|
1129
|
+
* @param channelType
|
|
1130
|
+
* @param members
|
|
1131
|
+
*/
|
|
1132
|
+
|
|
1133
|
+
var generateChannelTempCid = function generateChannelTempCid(channelType, members) {
|
|
1134
|
+
if (!members) return;
|
|
1135
|
+
|
|
1136
|
+
var membersStr = _toConsumableArray(members).sort().join(',');
|
|
1137
|
+
|
|
1138
|
+
if (!membersStr) return;
|
|
1139
|
+
return "".concat(channelType, ":!members-").concat(membersStr);
|
|
1140
|
+
};
|
|
1141
|
+
/**
|
|
1142
|
+
* Checks if a channel is pinned or not. Will return true only if channel.state.membership.pinned_at exists.
|
|
1143
|
+
* @param channel
|
|
1144
|
+
*/
|
|
1145
|
+
|
|
1146
|
+
var isChannelPinned = function isChannelPinned(channel) {
|
|
1147
|
+
if (!channel) return false;
|
|
1148
|
+
var member = channel.state.membership;
|
|
1149
|
+
return !!(member !== null && member !== void 0 && member.pinned_at);
|
|
1150
|
+
};
|
|
1151
|
+
/**
|
|
1152
|
+
* Checks if a channel is archived or not. Will return true only if channel.state.membership.archived_at exists.
|
|
1153
|
+
* @param channel
|
|
1154
|
+
*/
|
|
1155
|
+
|
|
1156
|
+
var isChannelArchived = function isChannelArchived(channel) {
|
|
1157
|
+
if (!channel) return false;
|
|
1158
|
+
var member = channel.state.membership;
|
|
1159
|
+
return !!(member !== null && member !== void 0 && member.archived_at);
|
|
1160
|
+
};
|
|
1161
|
+
/**
|
|
1162
|
+
* A utility that tells us whether we should consider archived channels or not based
|
|
1163
|
+
* on filters. Will return true only if filters.archived exists and is a boolean value.
|
|
1164
|
+
* @param filters
|
|
1165
|
+
*/
|
|
1166
|
+
|
|
1167
|
+
var shouldConsiderArchivedChannels = function shouldConsiderArchivedChannels(filters) {
|
|
1168
|
+
if (!filters) return false;
|
|
1169
|
+
return typeof filters.archived === 'boolean';
|
|
1170
|
+
};
|
|
1171
|
+
/**
|
|
1172
|
+
* Extracts the value of the sort parameter at a given index, for a targeted key. Can
|
|
1173
|
+
* handle both array and object versions of sort. Will return null if the index/key
|
|
1174
|
+
* combination does not exist.
|
|
1175
|
+
* @param atIndex - the index at which we'll examine the sort value, if it's an array one
|
|
1176
|
+
* @param sort - the sort value - both array and object notations are accepted
|
|
1177
|
+
* @param targetKey - the target key which needs to exist for the sort at a certain index
|
|
1178
|
+
*/
|
|
1179
|
+
|
|
1180
|
+
var extractSortValue = function extractSortValue(_ref13) {
|
|
1181
|
+
var _option$targetKey, _option;
|
|
1182
|
+
|
|
1183
|
+
var atIndex = _ref13.atIndex,
|
|
1184
|
+
sort = _ref13.sort,
|
|
1185
|
+
targetKey = _ref13.targetKey;
|
|
1186
|
+
if (!sort) return null;
|
|
1187
|
+
var option = null;
|
|
1188
|
+
|
|
1189
|
+
if (Array.isArray(sort)) {
|
|
1190
|
+
var _sort$atIndex;
|
|
1191
|
+
|
|
1192
|
+
option = (_sort$atIndex = sort[atIndex]) !== null && _sort$atIndex !== void 0 ? _sort$atIndex : null;
|
|
1193
|
+
} else {
|
|
1194
|
+
var index = 0;
|
|
1195
|
+
|
|
1196
|
+
for (var _key3 in sort) {
|
|
1197
|
+
if (index !== atIndex) {
|
|
1198
|
+
index++;
|
|
1199
|
+
continue;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
if (_key3 !== targetKey) {
|
|
1203
|
+
return null;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
option = sort;
|
|
1207
|
+
break;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
return (_option$targetKey = (_option = option) === null || _option === void 0 ? void 0 : _option[targetKey]) !== null && _option$targetKey !== void 0 ? _option$targetKey : null;
|
|
1212
|
+
};
|
|
1213
|
+
/**
|
|
1214
|
+
* Returns true only if `{ pinned_at: -1 }` or `{ pinned_at: 1 }` option is first within the `sort` array.
|
|
1215
|
+
*/
|
|
1216
|
+
|
|
1217
|
+
var shouldConsiderPinnedChannels = function shouldConsiderPinnedChannels(sort) {
|
|
1218
|
+
var value = findPinnedAtSortOrder({
|
|
1219
|
+
sort: sort
|
|
1220
|
+
});
|
|
1221
|
+
if (typeof value !== 'number') return false;
|
|
1222
|
+
return Math.abs(value) === 1;
|
|
1223
|
+
};
|
|
1224
|
+
/**
|
|
1225
|
+
* Checks whether the sort value of type object contains a pinned_at value or if
|
|
1226
|
+
* an array sort value type has the first value be an object containing pinned_at.
|
|
1227
|
+
* @param sort
|
|
1228
|
+
*/
|
|
1229
|
+
|
|
1230
|
+
var findPinnedAtSortOrder = function findPinnedAtSortOrder(_ref14) {
|
|
1231
|
+
var sort = _ref14.sort;
|
|
1232
|
+
return extractSortValue({
|
|
1233
|
+
atIndex: 0,
|
|
1234
|
+
sort: sort,
|
|
1235
|
+
targetKey: 'pinned_at'
|
|
1236
|
+
});
|
|
1237
|
+
};
|
|
1238
|
+
/**
|
|
1239
|
+
* Finds the index of the last consecutively pinned channel, starting from the start of the
|
|
1240
|
+
* array. Will not consider any pinned channels after the contiguous subsequence at the
|
|
1241
|
+
* start of the array.
|
|
1242
|
+
* @param channels
|
|
1243
|
+
*/
|
|
1244
|
+
|
|
1245
|
+
var findLastPinnedChannelIndex = function findLastPinnedChannelIndex(_ref15) {
|
|
1246
|
+
var channels = _ref15.channels;
|
|
1247
|
+
var lastPinnedChannelIndex = null;
|
|
1248
|
+
|
|
1249
|
+
var _iterator2 = _createForOfIteratorHelper$5(channels),
|
|
1250
|
+
_step2;
|
|
1251
|
+
|
|
1252
|
+
try {
|
|
1253
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1254
|
+
var channel = _step2.value;
|
|
1255
|
+
if (!isChannelPinned(channel)) break;
|
|
1256
|
+
|
|
1257
|
+
if (typeof lastPinnedChannelIndex === 'number') {
|
|
1258
|
+
lastPinnedChannelIndex++;
|
|
1259
|
+
} else {
|
|
1260
|
+
lastPinnedChannelIndex = 0;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
} catch (err) {
|
|
1264
|
+
_iterator2.e(err);
|
|
1265
|
+
} finally {
|
|
1266
|
+
_iterator2.f();
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
return lastPinnedChannelIndex;
|
|
1270
|
+
};
|
|
1271
|
+
/**
|
|
1272
|
+
* A utility used to move a channel towards the beginning of a list of channels (promote it to a higher position). It
|
|
1273
|
+
* considers pinned channels in the process if needed and makes sure to only update the list reference if the list
|
|
1274
|
+
* should actually change. It will try to move the channel as high as it can within the list.
|
|
1275
|
+
* @param channels - the list of channels we want to modify
|
|
1276
|
+
* @param channelToMove - the channel we want to promote
|
|
1277
|
+
* @param channelToMoveIndexWithinChannels - optionally, the index of the channel we want to move if we know it (will skip a manual check)
|
|
1278
|
+
* @param sort - the sort value used to check for pinned channels
|
|
1279
|
+
*/
|
|
1280
|
+
|
|
1281
|
+
var promoteChannel = function promoteChannel(_ref16) {
|
|
1282
|
+
var channels = _ref16.channels,
|
|
1283
|
+
channelToMove = _ref16.channelToMove,
|
|
1284
|
+
channelToMoveIndexWithinChannels = _ref16.channelToMoveIndexWithinChannels,
|
|
1285
|
+
sort = _ref16.sort;
|
|
1286
|
+
// get index of channel to move up
|
|
1287
|
+
var targetChannelIndex = channelToMoveIndexWithinChannels !== null && channelToMoveIndexWithinChannels !== void 0 ? channelToMoveIndexWithinChannels : channels.findIndex(function (channel) {
|
|
1288
|
+
return channel.cid === channelToMove.cid;
|
|
1289
|
+
});
|
|
1290
|
+
var targetChannelExistsWithinList = targetChannelIndex >= 0;
|
|
1291
|
+
var targetChannelAlreadyAtTheTop = targetChannelIndex === 0; // pinned channels should not move within the list based on recent activity, channels which
|
|
1292
|
+
// receive messages and are not pinned should move upwards but only under the last pinned channel
|
|
1293
|
+
// in the list
|
|
1294
|
+
|
|
1295
|
+
var considerPinnedChannels = shouldConsiderPinnedChannels(sort);
|
|
1296
|
+
var isTargetChannelPinned = isChannelPinned(channelToMove);
|
|
1297
|
+
|
|
1298
|
+
if (targetChannelAlreadyAtTheTop || considerPinnedChannels && isTargetChannelPinned) {
|
|
1299
|
+
return channels;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
var newChannels = _toConsumableArray(channels); // target channel index is known, remove it from the list
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
if (targetChannelExistsWithinList) {
|
|
1306
|
+
newChannels.splice(targetChannelIndex, 1);
|
|
1307
|
+
} // as position of pinned channels has to stay unchanged, we need to
|
|
1308
|
+
// find last pinned channel in the list to move the target channel after
|
|
1309
|
+
|
|
1310
|
+
|
|
1311
|
+
var lastPinnedChannelIndex = null;
|
|
1312
|
+
|
|
1313
|
+
if (considerPinnedChannels) {
|
|
1314
|
+
lastPinnedChannelIndex = findLastPinnedChannelIndex({
|
|
1315
|
+
channels: newChannels
|
|
1316
|
+
});
|
|
1317
|
+
} // re-insert it at the new place (to specific index if pinned channels are considered)
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
newChannels.splice(typeof lastPinnedChannelIndex === 'number' ? lastPinnedChannelIndex + 1 : 0, 0, channelToMove);
|
|
1321
|
+
return newChannels;
|
|
1322
|
+
};
|
|
1013
1323
|
|
|
1014
1324
|
var DEFAULT_QUERY_CHANNELS_MESSAGE_LIST_PAGE_SIZE = 25;
|
|
1015
1325
|
var DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE = 100;
|
|
@@ -1018,9 +1328,9 @@ var DEFAULT_MESSAGE_SET_PAGINATION = {
|
|
|
1018
1328
|
hasPrev: false
|
|
1019
1329
|
};
|
|
1020
1330
|
|
|
1021
|
-
function ownKeys$
|
|
1331
|
+
function ownKeys$d(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1022
1332
|
|
|
1023
|
-
function _objectSpread$
|
|
1333
|
+
function _objectSpread$d(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$d(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$d(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1024
1334
|
|
|
1025
1335
|
/**
|
|
1026
1336
|
* ChannelState - A container class for the channel state.
|
|
@@ -1101,7 +1411,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1101
1411
|
var m = messages[i];
|
|
1102
1412
|
|
|
1103
1413
|
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
1104
|
-
messages[i] = _objectSpread$
|
|
1414
|
+
messages[i] = _objectSpread$d(_objectSpread$d({}, m), {}, {
|
|
1105
1415
|
user: user
|
|
1106
1416
|
});
|
|
1107
1417
|
}
|
|
@@ -1156,7 +1466,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1156
1466
|
user: m.user
|
|
1157
1467
|
};
|
|
1158
1468
|
} else {
|
|
1159
|
-
messages[i] = _objectSpread$
|
|
1469
|
+
messages[i] = _objectSpread$d(_objectSpread$d({}, m), {}, {
|
|
1160
1470
|
type: 'deleted',
|
|
1161
1471
|
deleted_at: user.deleted_at ? new Date(user.deleted_at) : null
|
|
1162
1472
|
});
|
|
@@ -1474,7 +1784,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1474
1784
|
var parseMessage = function parseMessage(m) {
|
|
1475
1785
|
var _m$pinned_at, _m$updated_at;
|
|
1476
1786
|
|
|
1477
|
-
return _objectSpread$
|
|
1787
|
+
return _objectSpread$d(_objectSpread$d({}, m), {}, {
|
|
1478
1788
|
created_at: m.created_at.toISOString(),
|
|
1479
1789
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toISOString(),
|
|
1480
1790
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toISOString()
|
|
@@ -1484,8 +1794,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1484
1794
|
var update = function update(messages) {
|
|
1485
1795
|
var updatedMessages = messages.reduce(function (acc, msg) {
|
|
1486
1796
|
if (msg.quoted_message_id === message.id) {
|
|
1487
|
-
acc.push(_objectSpread$
|
|
1488
|
-
quoted_message: remove ? _objectSpread$
|
|
1797
|
+
acc.push(_objectSpread$d(_objectSpread$d({}, parseMessage(msg)), {}, {
|
|
1798
|
+
quoted_message: remove ? _objectSpread$d(_objectSpread$d({}, message), {}, {
|
|
1489
1799
|
attachments: []
|
|
1490
1800
|
}) : message
|
|
1491
1801
|
}));
|
|
@@ -1974,9 +2284,9 @@ function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o
|
|
|
1974
2284
|
|
|
1975
2285
|
function _arrayLikeToArray$4(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; }
|
|
1976
2286
|
|
|
1977
|
-
function ownKeys$
|
|
2287
|
+
function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1978
2288
|
|
|
1979
|
-
function _objectSpread$
|
|
2289
|
+
function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$c(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1980
2290
|
/**
|
|
1981
2291
|
* Channel - The Channel class manages it's own state.
|
|
1982
2292
|
*/
|
|
@@ -2051,7 +2361,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2051
2361
|
while (1) {
|
|
2052
2362
|
switch (_context.prev = _context.next) {
|
|
2053
2363
|
case 0:
|
|
2054
|
-
defaultOptions = _objectSpread$
|
|
2364
|
+
defaultOptions = _objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
2055
2365
|
watch: false,
|
|
2056
2366
|
state: false,
|
|
2057
2367
|
presence: false
|
|
@@ -2123,7 +2433,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2123
2433
|
|
|
2124
2434
|
this.data = data; // this._data is used for the requests...
|
|
2125
2435
|
|
|
2126
|
-
this._data = _objectSpread$
|
|
2436
|
+
this._data = _objectSpread$c({}, data);
|
|
2127
2437
|
this.cid = "".concat(type, ":").concat(id);
|
|
2128
2438
|
this.listeners = {}; // perhaps the state variable should be private
|
|
2129
2439
|
|
|
@@ -2185,7 +2495,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2185
2495
|
switch (_context2.prev = _context2.next) {
|
|
2186
2496
|
case 0:
|
|
2187
2497
|
_context2.next = 2;
|
|
2188
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
2498
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$c({
|
|
2189
2499
|
message: message
|
|
2190
2500
|
}, options));
|
|
2191
2501
|
|
|
@@ -2301,7 +2611,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2301
2611
|
|
|
2302
2612
|
case 3:
|
|
2303
2613
|
// Return a list of channels
|
|
2304
|
-
payload = _objectSpread$
|
|
2614
|
+
payload = _objectSpread$c(_objectSpread$c({
|
|
2305
2615
|
filter_conditions: {
|
|
2306
2616
|
cid: this.cid
|
|
2307
2617
|
}
|
|
@@ -2398,7 +2708,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2398
2708
|
|
|
2399
2709
|
_context5.next = 6;
|
|
2400
2710
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
2401
|
-
payload: _objectSpread$
|
|
2711
|
+
payload: _objectSpread$c({
|
|
2402
2712
|
type: type,
|
|
2403
2713
|
id: id,
|
|
2404
2714
|
members: members,
|
|
@@ -2504,7 +2814,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2504
2814
|
|
|
2505
2815
|
case 4:
|
|
2506
2816
|
_context7.next = 6;
|
|
2507
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$
|
|
2817
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$c({
|
|
2508
2818
|
reaction: reaction
|
|
2509
2819
|
}, options));
|
|
2510
2820
|
|
|
@@ -2585,7 +2895,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2585
2895
|
delete channelData[key];
|
|
2586
2896
|
});
|
|
2587
2897
|
_context8.next = 7;
|
|
2588
|
-
return this._update(_objectSpread$
|
|
2898
|
+
return this._update(_objectSpread$c({
|
|
2589
2899
|
message: updateMessage,
|
|
2590
2900
|
data: channelData
|
|
2591
2901
|
}, options));
|
|
@@ -2757,7 +3067,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2757
3067
|
case 0:
|
|
2758
3068
|
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
2759
3069
|
_context12.next = 3;
|
|
2760
|
-
return this.getClient().delete(this._channelURL(), _objectSpread$
|
|
3070
|
+
return this.getClient().delete(this._channelURL(), _objectSpread$c({}, options));
|
|
2761
3071
|
|
|
2762
3072
|
case 3:
|
|
2763
3073
|
return _context12.abrupt("return", _context12.sent);
|
|
@@ -2833,7 +3143,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2833
3143
|
case 0:
|
|
2834
3144
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
2835
3145
|
_context14.next = 3;
|
|
2836
|
-
return this._update(_objectSpread$
|
|
3146
|
+
return this._update(_objectSpread$c({
|
|
2837
3147
|
accept_invite: true
|
|
2838
3148
|
}, options));
|
|
2839
3149
|
|
|
@@ -2874,7 +3184,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2874
3184
|
case 0:
|
|
2875
3185
|
options = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
|
|
2876
3186
|
_context15.next = 3;
|
|
2877
|
-
return this._update(_objectSpread$
|
|
3187
|
+
return this._update(_objectSpread$c({
|
|
2878
3188
|
reject_invite: true
|
|
2879
3189
|
}, options));
|
|
2880
3190
|
|
|
@@ -2916,7 +3226,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2916
3226
|
case 0:
|
|
2917
3227
|
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
2918
3228
|
_context16.next = 3;
|
|
2919
|
-
return this._update(_objectSpread$
|
|
3229
|
+
return this._update(_objectSpread$c({
|
|
2920
3230
|
add_members: members,
|
|
2921
3231
|
message: message
|
|
2922
3232
|
}, options));
|
|
@@ -2959,7 +3269,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2959
3269
|
case 0:
|
|
2960
3270
|
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
2961
3271
|
_context17.next = 3;
|
|
2962
|
-
return this._update(_objectSpread$
|
|
3272
|
+
return this._update(_objectSpread$c({
|
|
2963
3273
|
add_moderators: members,
|
|
2964
3274
|
message: message
|
|
2965
3275
|
}, options));
|
|
@@ -3002,7 +3312,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3002
3312
|
case 0:
|
|
3003
3313
|
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
3004
3314
|
_context18.next = 3;
|
|
3005
|
-
return this._update(_objectSpread$
|
|
3315
|
+
return this._update(_objectSpread$c({
|
|
3006
3316
|
assign_roles: roles,
|
|
3007
3317
|
message: message
|
|
3008
3318
|
}, options));
|
|
@@ -3045,7 +3355,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3045
3355
|
case 0:
|
|
3046
3356
|
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
3047
3357
|
_context19.next = 3;
|
|
3048
|
-
return this._update(_objectSpread$
|
|
3358
|
+
return this._update(_objectSpread$c({
|
|
3049
3359
|
invites: members,
|
|
3050
3360
|
message: message
|
|
3051
3361
|
}, options));
|
|
@@ -3088,7 +3398,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3088
3398
|
case 0:
|
|
3089
3399
|
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
3090
3400
|
_context20.next = 3;
|
|
3091
|
-
return this._update(_objectSpread$
|
|
3401
|
+
return this._update(_objectSpread$c({
|
|
3092
3402
|
remove_members: members,
|
|
3093
3403
|
message: message
|
|
3094
3404
|
}, options));
|
|
@@ -3131,7 +3441,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3131
3441
|
case 0:
|
|
3132
3442
|
options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
|
|
3133
3443
|
_context21.next = 3;
|
|
3134
|
-
return this._update(_objectSpread$
|
|
3444
|
+
return this._update(_objectSpread$c({
|
|
3135
3445
|
demote_moderators: members,
|
|
3136
3446
|
message: message
|
|
3137
3447
|
}, options));
|
|
@@ -3216,7 +3526,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3216
3526
|
case 0:
|
|
3217
3527
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
3218
3528
|
_context23.next = 3;
|
|
3219
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
3529
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$c({
|
|
3220
3530
|
channel_cid: this.cid
|
|
3221
3531
|
}, opts));
|
|
3222
3532
|
|
|
@@ -3258,7 +3568,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3258
3568
|
case 0:
|
|
3259
3569
|
opts = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
|
|
3260
3570
|
_context24.next = 3;
|
|
3261
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
3571
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$c({
|
|
3262
3572
|
channel_cid: this.cid
|
|
3263
3573
|
}, opts));
|
|
3264
3574
|
|
|
@@ -3595,7 +3905,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3595
3905
|
|
|
3596
3906
|
this.lastTypingEvent = new Date();
|
|
3597
3907
|
_context29.next = 10;
|
|
3598
|
-
return this.sendEvent(_objectSpread$
|
|
3908
|
+
return this.sendEvent(_objectSpread$c({
|
|
3599
3909
|
type: 'typing.start',
|
|
3600
3910
|
parent_id: parent_id
|
|
3601
3911
|
}, options || {}));
|
|
@@ -3635,7 +3945,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3635
3945
|
case 0:
|
|
3636
3946
|
options = _args30.length > 2 && _args30[2] !== undefined ? _args30[2] : {};
|
|
3637
3947
|
_context30.next = 3;
|
|
3638
|
-
return this.sendEvent(_objectSpread$
|
|
3948
|
+
return this.sendEvent(_objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
3639
3949
|
type: 'ai_indicator.update',
|
|
3640
3950
|
message_id: messageId,
|
|
3641
3951
|
ai_state: state
|
|
@@ -3744,7 +4054,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3744
4054
|
this.lastTypingEvent = null;
|
|
3745
4055
|
this.isTyping = false;
|
|
3746
4056
|
_context33.next = 6;
|
|
3747
|
-
return this.sendEvent(_objectSpread$
|
|
4057
|
+
return this.sendEvent(_objectSpread$c({
|
|
3748
4058
|
type: 'typing.stop',
|
|
3749
4059
|
parent_id: parent_id
|
|
3750
4060
|
}, options || {}));
|
|
@@ -3831,7 +4141,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3831
4141
|
|
|
3832
4142
|
case 4:
|
|
3833
4143
|
_context34.next = 6;
|
|
3834
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
4144
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$c({}, data));
|
|
3835
4145
|
|
|
3836
4146
|
case 6:
|
|
3837
4147
|
return _context34.abrupt("return", _context34.sent);
|
|
@@ -3878,7 +4188,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3878
4188
|
|
|
3879
4189
|
case 3:
|
|
3880
4190
|
_context35.next = 5;
|
|
3881
|
-
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$
|
|
4191
|
+
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$c({}, data));
|
|
3882
4192
|
|
|
3883
4193
|
case 5:
|
|
3884
4194
|
return _context35.abrupt("return", _context35.sent);
|
|
@@ -3946,7 +4256,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3946
4256
|
defaultOptions.watch = false;
|
|
3947
4257
|
}
|
|
3948
4258
|
|
|
3949
|
-
combined = _objectSpread$
|
|
4259
|
+
combined = _objectSpread$c(_objectSpread$c({}, defaultOptions), options);
|
|
3950
4260
|
_context36.next = 7;
|
|
3951
4261
|
return this.query(combined, 'latest');
|
|
3952
4262
|
|
|
@@ -4040,7 +4350,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4040
4350
|
case 0:
|
|
4041
4351
|
normalizedSort = sort ? normalizeQuerySort(sort) : undefined;
|
|
4042
4352
|
_context38.next = 3;
|
|
4043
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$
|
|
4353
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$c({
|
|
4044
4354
|
sort: normalizedSort
|
|
4045
4355
|
}, options));
|
|
4046
4356
|
|
|
@@ -4090,7 +4400,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4090
4400
|
sort = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : [];
|
|
4091
4401
|
_context39.next = 3;
|
|
4092
4402
|
return this.getClient().get(this._channelURL() + '/pinned_messages', {
|
|
4093
|
-
payload: _objectSpread$
|
|
4403
|
+
payload: _objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
4094
4404
|
sort: normalizeQuerySort(sort)
|
|
4095
4405
|
})
|
|
4096
4406
|
});
|
|
@@ -4124,7 +4434,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4124
4434
|
}, {
|
|
4125
4435
|
key: "getReactions",
|
|
4126
4436
|
value: function getReactions(message_id, options) {
|
|
4127
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$
|
|
4437
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$c({}, options));
|
|
4128
4438
|
}
|
|
4129
4439
|
/**
|
|
4130
4440
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -4248,7 +4558,6 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4248
4558
|
var messageSetToAddToIfDoesNotExist,
|
|
4249
4559
|
queryURL,
|
|
4250
4560
|
state,
|
|
4251
|
-
membersStr,
|
|
4252
4561
|
tempChannelCid,
|
|
4253
4562
|
_this$_initializeStat,
|
|
4254
4563
|
messageSet,
|
|
@@ -4271,7 +4580,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4271
4580
|
}
|
|
4272
4581
|
|
|
4273
4582
|
_context40.next = 7;
|
|
4274
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
4583
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$c({
|
|
4275
4584
|
data: this._data,
|
|
4276
4585
|
state: true
|
|
4277
4586
|
}, options));
|
|
@@ -4284,14 +4593,13 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4284
4593
|
this.id = state.channel.id;
|
|
4285
4594
|
this.cid = state.channel.cid; // set the channel as active...
|
|
4286
4595
|
|
|
4287
|
-
|
|
4596
|
+
tempChannelCid = generateChannelTempCid(this.type, state.members.map(function (member) {
|
|
4288
4597
|
var _member$user;
|
|
4289
4598
|
|
|
4290
|
-
return member.user_id || ((_member$user = member.user) === null || _member$user === void 0 ? void 0 : _member$user.id);
|
|
4291
|
-
})
|
|
4292
|
-
tempChannelCid = "".concat(this.type, ":!members-").concat(membersStr);
|
|
4599
|
+
return member.user_id || ((_member$user = member.user) === null || _member$user === void 0 ? void 0 : _member$user.id) || '';
|
|
4600
|
+
}));
|
|
4293
4601
|
|
|
4294
|
-
if (tempChannelCid in this.getClient().activeChannels) {
|
|
4602
|
+
if (tempChannelCid && tempChannelCid in this.getClient().activeChannels) {
|
|
4295
4603
|
// This gets set in `client.channel()` function, when channel is created
|
|
4296
4604
|
// using members, not id.
|
|
4297
4605
|
delete this.getClient().activeChannels[tempChannelCid];
|
|
@@ -4306,7 +4614,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4306
4614
|
|
|
4307
4615
|
|
|
4308
4616
|
_this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
|
|
4309
|
-
messageSet.pagination = _objectSpread$
|
|
4617
|
+
messageSet.pagination = _objectSpread$c(_objectSpread$c({}, messageSet.pagination), messageSetPagination({
|
|
4310
4618
|
parentSet: messageSet,
|
|
4311
4619
|
messagePaginationOptions: options === null || options === void 0 ? void 0 : options.messages,
|
|
4312
4620
|
requestedPageSize: (_options$messages$lim = options === null || options === void 0 ? void 0 : (_options$messages = options.messages) === null || _options$messages === void 0 ? void 0 : _options$messages.limit) !== null && _options$messages$lim !== void 0 ? _options$messages$lim : DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE,
|
|
@@ -4368,7 +4676,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4368
4676
|
this._checkInitialized();
|
|
4369
4677
|
|
|
4370
4678
|
_context41.next = 3;
|
|
4371
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
4679
|
+
return this.getClient().banUser(targetUserID, _objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
4372
4680
|
type: this.type,
|
|
4373
4681
|
id: this.id
|
|
4374
4682
|
}));
|
|
@@ -4540,7 +4848,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4540
4848
|
this._checkInitialized();
|
|
4541
4849
|
|
|
4542
4850
|
_context45.next = 3;
|
|
4543
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
4851
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
4544
4852
|
type: this.type,
|
|
4545
4853
|
id: this.id
|
|
4546
4854
|
}));
|
|
@@ -4945,7 +5253,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4945
5253
|
case 'member.added':
|
|
4946
5254
|
case 'member.updated':
|
|
4947
5255
|
if ((_event$member = event.member) !== null && _event$member !== void 0 && _event$member.user) {
|
|
4948
|
-
channelState.members = _objectSpread$
|
|
5256
|
+
channelState.members = _objectSpread$c(_objectSpread$c({}, channelState.members), {}, _defineProperty({}, event.member.user.id, event.member));
|
|
4949
5257
|
}
|
|
4950
5258
|
|
|
4951
5259
|
if (typeof ((_channelState$members = channelState.membership.user) === null || _channelState$members === void 0 ? void 0 : _channelState$members.id) === 'string' && typeof ((_event$member2 = event.member) === null || _event$member2 === void 0 ? void 0 : (_event$member2$user = _event$member2.user) === null || _event$member2$user === void 0 ? void 0 : _event$member2$user.id) === 'string' && event.member.user.id === channelState.membership.user.id) {
|
|
@@ -4956,7 +5264,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4956
5264
|
|
|
4957
5265
|
case 'member.removed':
|
|
4958
5266
|
if ((_event$user9 = event.user) !== null && _event$user9 !== void 0 && _event$user9.id) {
|
|
4959
|
-
var newMembers = _objectSpread$
|
|
5267
|
+
var newMembers = _objectSpread$c({}, channelState.members);
|
|
4960
5268
|
|
|
4961
5269
|
delete newMembers[event.user.id];
|
|
4962
5270
|
channelState.members = newMembers; // TODO?: unset membership
|
|
@@ -5001,7 +5309,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
5001
5309
|
});
|
|
5002
5310
|
}
|
|
5003
5311
|
|
|
5004
|
-
channel.data = _objectSpread$
|
|
5312
|
+
channel.data = _objectSpread$c(_objectSpread$c({}, event.channel), {}, {
|
|
5005
5313
|
hidden: (_event$channel$hidden = (_event$channel3 = event.channel) === null || _event$channel3 === void 0 ? void 0 : _event$channel3.hidden) !== null && _event$channel$hidden !== void 0 ? _event$channel$hidden : (_channel$data2 = channel.data) === null || _channel$data2 === void 0 ? void 0 : _channel$data2.hidden,
|
|
5006
5314
|
own_capabilities: (_event$channel$own_ca = (_event$channel4 = event.channel) === null || _event$channel4 === void 0 ? void 0 : _event$channel4.own_capabilities) !== null && _event$channel$own_ca !== void 0 ? _event$channel$own_ca : (_channel$data3 = channel.data) === null || _channel$data3 === void 0 ? void 0 : _channel$data3.own_capabilities
|
|
5007
5315
|
});
|
|
@@ -5032,7 +5340,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
5032
5340
|
break;
|
|
5033
5341
|
|
|
5034
5342
|
case 'channel.hidden':
|
|
5035
|
-
channel.data = _objectSpread$
|
|
5343
|
+
channel.data = _objectSpread$c(_objectSpread$c({}, channel.data), {}, {
|
|
5036
5344
|
hidden: true
|
|
5037
5345
|
});
|
|
5038
5346
|
|
|
@@ -5043,26 +5351,26 @@ var Channel = /*#__PURE__*/function () {
|
|
|
5043
5351
|
break;
|
|
5044
5352
|
|
|
5045
5353
|
case 'channel.visible':
|
|
5046
|
-
channel.data = _objectSpread$
|
|
5354
|
+
channel.data = _objectSpread$c(_objectSpread$c({}, channel.data), {}, {
|
|
5047
5355
|
hidden: false
|
|
5048
5356
|
});
|
|
5049
5357
|
break;
|
|
5050
5358
|
|
|
5051
5359
|
case 'user.banned':
|
|
5052
5360
|
if (!((_event$user11 = event.user) !== null && _event$user11 !== void 0 && _event$user11.id)) break;
|
|
5053
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
5361
|
+
channelState.members[event.user.id] = _objectSpread$c(_objectSpread$c({}, channelState.members[event.user.id] || {}), {}, {
|
|
5054
5362
|
shadow_banned: !!event.shadow,
|
|
5055
5363
|
banned: !event.shadow,
|
|
5056
|
-
user: _objectSpread$
|
|
5364
|
+
user: _objectSpread$c(_objectSpread$c({}, ((_channelState$members2 = channelState.members[event.user.id]) === null || _channelState$members2 === void 0 ? void 0 : _channelState$members2.user) || {}), event.user)
|
|
5057
5365
|
});
|
|
5058
5366
|
break;
|
|
5059
5367
|
|
|
5060
5368
|
case 'user.unbanned':
|
|
5061
5369
|
if (!((_event$user12 = event.user) !== null && _event$user12 !== void 0 && _event$user12.id)) break;
|
|
5062
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
5370
|
+
channelState.members[event.user.id] = _objectSpread$c(_objectSpread$c({}, channelState.members[event.user.id] || {}), {}, {
|
|
5063
5371
|
shadow_banned: false,
|
|
5064
5372
|
banned: false,
|
|
5065
|
-
user: _objectSpread$
|
|
5373
|
+
user: _objectSpread$c(_objectSpread$c({}, ((_channelState$members3 = channelState.members[event.user.id]) === null || _channelState$members3 === void 0 ? void 0 : _channelState$members3.user) || {}), event.user)
|
|
5066
5374
|
});
|
|
5067
5375
|
break;
|
|
5068
5376
|
} // any event can send over the online count
|
|
@@ -5236,7 +5544,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
5236
5544
|
if (overrideCurrentState) {
|
|
5237
5545
|
this.state.members = newMembersById;
|
|
5238
5546
|
} else if (!overrideCurrentState && members.length) {
|
|
5239
|
-
this.state.members = _objectSpread$
|
|
5547
|
+
this.state.members = _objectSpread$c(_objectSpread$c({}, this.state.members), newMembersById);
|
|
5240
5548
|
}
|
|
5241
5549
|
}
|
|
5242
5550
|
}, {
|
|
@@ -5335,9 +5643,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
5335
5643
|
return ClientState;
|
|
5336
5644
|
}();
|
|
5337
5645
|
|
|
5338
|
-
function ownKeys$
|
|
5646
|
+
function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5339
5647
|
|
|
5340
|
-
function _objectSpread$
|
|
5648
|
+
function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$b(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
5341
5649
|
var InsightMetrics = function InsightMetrics() {
|
|
5342
5650
|
_classCallCheck(this, InsightMetrics);
|
|
5343
5651
|
|
|
@@ -5416,7 +5724,7 @@ var postInsights = /*#__PURE__*/function () {
|
|
|
5416
5724
|
};
|
|
5417
5725
|
}();
|
|
5418
5726
|
function buildWsFatalInsight(connection, event) {
|
|
5419
|
-
return _objectSpread$
|
|
5727
|
+
return _objectSpread$b(_objectSpread$b({}, event), buildWsBaseInsight(connection));
|
|
5420
5728
|
}
|
|
5421
5729
|
|
|
5422
5730
|
function buildWsBaseInsight(connection) {
|
|
@@ -5449,9 +5757,9 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
5449
5757
|
return buildWsBaseInsight(connection);
|
|
5450
5758
|
}
|
|
5451
5759
|
|
|
5452
|
-
function ownKeys$
|
|
5760
|
+
function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5453
5761
|
|
|
5454
|
-
function _objectSpread$
|
|
5762
|
+
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$a(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
5455
5763
|
|
|
5456
5764
|
// Type guards to check WebSocket error type
|
|
5457
5765
|
var isCloseEvent = function isCloseEvent(res) {
|
|
@@ -5815,7 +6123,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
5815
6123
|
value: function _log(msg) {
|
|
5816
6124
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5817
6125
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5818
|
-
this.client.logger(level, 'connection:' + msg, _objectSpread$
|
|
6126
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$a({
|
|
5819
6127
|
tags: ['connection']
|
|
5820
6128
|
}, extra));
|
|
5821
6129
|
}
|
|
@@ -6406,9 +6714,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
6406
6714
|
return StableWSConnection;
|
|
6407
6715
|
}();
|
|
6408
6716
|
|
|
6409
|
-
function ownKeys$
|
|
6717
|
+
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6410
6718
|
|
|
6411
|
-
function _objectSpread$
|
|
6719
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6412
6720
|
|
|
6413
6721
|
/**
|
|
6414
6722
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -6429,7 +6737,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
6429
6737
|
throw new TypeError('userId should be a string');
|
|
6430
6738
|
}
|
|
6431
6739
|
|
|
6432
|
-
var payload = _objectSpread$
|
|
6740
|
+
var payload = _objectSpread$9({
|
|
6433
6741
|
user_id: userId
|
|
6434
6742
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
6435
6743
|
|
|
@@ -6841,9 +7149,9 @@ function isErrorResponse(res) {
|
|
|
6841
7149
|
return !res.status || res.status < 200 || 300 <= res.status;
|
|
6842
7150
|
}
|
|
6843
7151
|
|
|
6844
|
-
function ownKeys$
|
|
7152
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6845
7153
|
|
|
6846
|
-
function _objectSpread$
|
|
7154
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6847
7155
|
var ConnectionState;
|
|
6848
7156
|
|
|
6849
7157
|
(function (ConnectionState) {
|
|
@@ -6906,7 +7214,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6906
7214
|
_context.next = 4;
|
|
6907
7215
|
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
6908
7216
|
undefined, {
|
|
6909
|
-
config: _objectSpread$
|
|
7217
|
+
config: _objectSpread$8(_objectSpread$8({}, config), {}, {
|
|
6910
7218
|
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
6911
7219
|
}),
|
|
6912
7220
|
params: params
|
|
@@ -7184,7 +7492,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
7184
7492
|
value: function _log(msg) {
|
|
7185
7493
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7186
7494
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
7187
|
-
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$
|
|
7495
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$8({
|
|
7188
7496
|
tags: ['connection_fallback', 'connection']
|
|
7189
7497
|
}, extra));
|
|
7190
7498
|
}
|
|
@@ -7561,14 +7869,13 @@ var VotingVisibility;
|
|
|
7561
7869
|
VotingVisibility["public"] = "public";
|
|
7562
7870
|
})(VotingVisibility || (VotingVisibility = {}));
|
|
7563
7871
|
|
|
7564
|
-
function ownKeys$
|
|
7872
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7565
7873
|
|
|
7566
|
-
function _objectSpread$
|
|
7874
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7567
7875
|
|
|
7568
|
-
function isPatch(value) {
|
|
7876
|
+
var isPatch = function isPatch(value) {
|
|
7569
7877
|
return typeof value === 'function';
|
|
7570
|
-
}
|
|
7571
|
-
|
|
7878
|
+
};
|
|
7572
7879
|
var StateStore = function StateStore(value) {
|
|
7573
7880
|
var _this = this;
|
|
7574
7881
|
|
|
@@ -7593,7 +7900,7 @@ var StateStore = function StateStore(value) {
|
|
|
7593
7900
|
|
|
7594
7901
|
_defineProperty(this, "partialNext", function (partial) {
|
|
7595
7902
|
return _this.next(function (current) {
|
|
7596
|
-
return _objectSpread$
|
|
7903
|
+
return _objectSpread$7(_objectSpread$7({}, current), partial);
|
|
7597
7904
|
});
|
|
7598
7905
|
});
|
|
7599
7906
|
|
|
@@ -7645,9 +7952,9 @@ _defineProperty(StateStore, "logCount", 5);
|
|
|
7645
7952
|
|
|
7646
7953
|
var _excluded$3 = ["limit", "sort"];
|
|
7647
7954
|
|
|
7648
|
-
function ownKeys$
|
|
7955
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7649
7956
|
|
|
7650
|
-
function _objectSpread$
|
|
7957
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7651
7958
|
var DEFAULT_PAGE_LIMIT = 50;
|
|
7652
7959
|
var DEFAULT_SORT = [{
|
|
7653
7960
|
created_at: -1
|
|
@@ -7932,14 +8239,14 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7932
8239
|
if (userId === ((_event$user2 = event.user) === null || _event$user2 === void 0 ? void 0 : _event$user2.id)) {
|
|
7933
8240
|
// The user who just sent a message to the thread has no unread messages
|
|
7934
8241
|
// in that thread
|
|
7935
|
-
nextUserRead = _objectSpread$
|
|
8242
|
+
nextUserRead = _objectSpread$6(_objectSpread$6({}, nextUserRead), {}, {
|
|
7936
8243
|
lastReadAt: event.created_at ? new Date(event.created_at) : new Date(),
|
|
7937
8244
|
user: event.user,
|
|
7938
8245
|
unreadMessageCount: 0
|
|
7939
8246
|
});
|
|
7940
8247
|
} else if (active && userId === _this.client.userID) ; else {
|
|
7941
8248
|
// Increment unread count for all users except the author of the new message
|
|
7942
|
-
nextUserRead = _objectSpread$
|
|
8249
|
+
nextUserRead = _objectSpread$6(_objectSpread$6({}, nextUserRead), {}, {
|
|
7943
8250
|
unreadMessageCount: userRead.unreadMessageCount + 1
|
|
7944
8251
|
});
|
|
7945
8252
|
}
|
|
@@ -7963,8 +8270,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7963
8270
|
var user = event.user;
|
|
7964
8271
|
|
|
7965
8272
|
_this.state.next(function (current) {
|
|
7966
|
-
return _objectSpread$
|
|
7967
|
-
read: _objectSpread$
|
|
8273
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8274
|
+
read: _objectSpread$6(_objectSpread$6({}, current.read), {}, _defineProperty({}, userId, {
|
|
7968
8275
|
lastReadAt: new Date(createdAt),
|
|
7969
8276
|
user: user,
|
|
7970
8277
|
lastReadMessageId: event.last_read_message_id,
|
|
@@ -8077,7 +8384,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8077
8384
|
}
|
|
8078
8385
|
|
|
8079
8386
|
_this.state.next(function (current) {
|
|
8080
|
-
return _objectSpread$
|
|
8387
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8081
8388
|
replies: addToMessageList(current.replies, formattedMessage, timestampChanged)
|
|
8082
8389
|
});
|
|
8083
8390
|
});
|
|
@@ -8094,7 +8401,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8094
8401
|
var _message$reply_count;
|
|
8095
8402
|
|
|
8096
8403
|
var formattedMessage = formatMessage(message);
|
|
8097
|
-
return _objectSpread$
|
|
8404
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8098
8405
|
deletedAt: formattedMessage.deleted_at,
|
|
8099
8406
|
parentMessage: formattedMessage,
|
|
8100
8407
|
replyCount: (_message$reply_count = message.reply_count) !== null && _message$reply_count !== void 0 ? _message$reply_count : current.replyCount
|
|
@@ -8167,7 +8474,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8167
8474
|
sort = _ref10$sort === void 0 ? DEFAULT_SORT : _ref10$sort,
|
|
8168
8475
|
otherOptions = _objectWithoutProperties(_ref10, _excluded$3);
|
|
8169
8476
|
|
|
8170
|
-
return _this.channel.getReplies(_this.id, _objectSpread$
|
|
8477
|
+
return _this.channel.getReplies(_this.id, _objectSpread$6({
|
|
8171
8478
|
limit: limit
|
|
8172
8479
|
}, otherOptions), sort);
|
|
8173
8480
|
});
|
|
@@ -8211,12 +8518,12 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8211
8518
|
limit = Math.abs(count);
|
|
8212
8519
|
|
|
8213
8520
|
_this.state.partialNext({
|
|
8214
|
-
pagination: _objectSpread$
|
|
8521
|
+
pagination: _objectSpread$6(_objectSpread$6({}, pagination), {}, _defineProperty({}, loadingKey, true))
|
|
8215
8522
|
});
|
|
8216
8523
|
|
|
8217
8524
|
_context3.prev = 7;
|
|
8218
8525
|
_context3.next = 10;
|
|
8219
|
-
return _this.queryReplies(_objectSpread$
|
|
8526
|
+
return _this.queryReplies(_objectSpread$6(_objectSpread$6({}, queryOptions), {}, {
|
|
8220
8527
|
limit: limit
|
|
8221
8528
|
}));
|
|
8222
8529
|
|
|
@@ -8238,9 +8545,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8238
8545
|
(_nextReplies = nextReplies)[insertionMethodKey].apply(_nextReplies, _toConsumableArray(replies));
|
|
8239
8546
|
}
|
|
8240
8547
|
|
|
8241
|
-
return _objectSpread$
|
|
8548
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8242
8549
|
replies: nextReplies,
|
|
8243
|
-
pagination: _objectSpread$
|
|
8550
|
+
pagination: _objectSpread$6(_objectSpread$6({}, current.pagination), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, cursorKey, data.messages.length < limit ? null : maybeNextCursor), _defineProperty(_objectSpread4, loadingKey, false), _objectSpread4))
|
|
8244
8551
|
});
|
|
8245
8552
|
});
|
|
8246
8553
|
|
|
@@ -8254,8 +8561,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8254
8561
|
_this.client.logger('error', _context3.t0.message);
|
|
8255
8562
|
|
|
8256
8563
|
_this.state.next(function (current) {
|
|
8257
|
-
return _objectSpread$
|
|
8258
|
-
pagination: _objectSpread$
|
|
8564
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8565
|
+
pagination: _objectSpread$6(_objectSpread$6({}, current.pagination), {}, _defineProperty({}, loadingKey, false))
|
|
8259
8566
|
});
|
|
8260
8567
|
});
|
|
8261
8568
|
|
|
@@ -8368,9 +8675,9 @@ var ownUnreadCountSelector = function ownUnreadCountSelector(currentUserId) {
|
|
|
8368
8675
|
};
|
|
8369
8676
|
};
|
|
8370
8677
|
|
|
8371
|
-
function ownKeys$
|
|
8678
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8372
8679
|
|
|
8373
|
-
function _objectSpread$
|
|
8680
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8374
8681
|
var MODERATION_ENTITY_TYPES = {
|
|
8375
8682
|
user: 'stream:user',
|
|
8376
8683
|
message: 'stream:chat:v1:message'
|
|
@@ -8487,7 +8794,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8487
8794
|
case 0:
|
|
8488
8795
|
options = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : {};
|
|
8489
8796
|
_context3.next = 3;
|
|
8490
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$
|
|
8797
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$5({
|
|
8491
8798
|
entity_type: entityType,
|
|
8492
8799
|
entity_id: entityId,
|
|
8493
8800
|
entity_creator_id: entityCreatorID,
|
|
@@ -8532,7 +8839,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8532
8839
|
case 0:
|
|
8533
8840
|
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
8534
8841
|
_context4.next = 3;
|
|
8535
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$
|
|
8842
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$5({
|
|
8536
8843
|
target_ids: [targetID]
|
|
8537
8844
|
}, options));
|
|
8538
8845
|
|
|
@@ -8570,7 +8877,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8570
8877
|
switch (_context5.prev = _context5.next) {
|
|
8571
8878
|
case 0:
|
|
8572
8879
|
_context5.next = 2;
|
|
8573
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$
|
|
8880
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$5({
|
|
8574
8881
|
target_ids: [targetID]
|
|
8575
8882
|
}, options));
|
|
8576
8883
|
|
|
@@ -8612,7 +8919,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8612
8919
|
case 0:
|
|
8613
8920
|
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
8614
8921
|
_context6.next = 3;
|
|
8615
|
-
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$
|
|
8922
|
+
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$5({
|
|
8616
8923
|
user_id: userID
|
|
8617
8924
|
}, options));
|
|
8618
8925
|
|
|
@@ -8656,7 +8963,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8656
8963
|
sort = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : [];
|
|
8657
8964
|
options = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : {};
|
|
8658
8965
|
_context7.next = 5;
|
|
8659
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$
|
|
8966
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$5({
|
|
8660
8967
|
filter: filterConditions,
|
|
8661
8968
|
sort: normalizeQuerySort(sort)
|
|
8662
8969
|
}, options));
|
|
@@ -8791,7 +9098,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8791
9098
|
case 0:
|
|
8792
9099
|
options = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : {};
|
|
8793
9100
|
_context11.next = 3;
|
|
8794
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/configs', _objectSpread$
|
|
9101
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/configs', _objectSpread$5({
|
|
8795
9102
|
filter: filterConditions,
|
|
8796
9103
|
sort: sort
|
|
8797
9104
|
}, options));
|
|
@@ -8825,7 +9132,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8825
9132
|
case 0:
|
|
8826
9133
|
options = _args12.length > 2 && _args12[2] !== undefined ? _args12[2] : {};
|
|
8827
9134
|
_context12.next = 3;
|
|
8828
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$
|
|
9135
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$5({
|
|
8829
9136
|
action_type: actionType,
|
|
8830
9137
|
item_id: itemID
|
|
8831
9138
|
}, options));
|
|
@@ -8989,9 +9296,9 @@ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o
|
|
|
8989
9296
|
|
|
8990
9297
|
function _arrayLikeToArray$2(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; }
|
|
8991
9298
|
|
|
8992
|
-
function ownKeys$
|
|
9299
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8993
9300
|
|
|
8994
|
-
function _objectSpread$
|
|
9301
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8995
9302
|
var DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION = 1000;
|
|
8996
9303
|
var MAX_QUERY_THREADS_LIMIT = 25;
|
|
8997
9304
|
var THREAD_MANAGER_INITIAL_STATE = {
|
|
@@ -9172,7 +9479,7 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9172
9479
|
var unsubscribeConnectionDropped = _this.client.on('connection.changed', function (event) {
|
|
9173
9480
|
if (event.online === false) {
|
|
9174
9481
|
_this.state.next(function (current) {
|
|
9175
|
-
return current.lastConnectionDropAt ? current : _objectSpread$
|
|
9482
|
+
return current.lastConnectionDropAt ? current : _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9176
9483
|
lastConnectionDropAt: new Date()
|
|
9177
9484
|
});
|
|
9178
9485
|
});
|
|
@@ -9259,8 +9566,8 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9259
9566
|
_context.prev = 7;
|
|
9260
9567
|
|
|
9261
9568
|
_this.state.next(function (current) {
|
|
9262
|
-
return _objectSpread$
|
|
9263
|
-
pagination: _objectSpread$
|
|
9569
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9570
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9264
9571
|
isLoading: true
|
|
9265
9572
|
})
|
|
9266
9573
|
});
|
|
@@ -9302,11 +9609,11 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9302
9609
|
_this.state.next(function (current) {
|
|
9303
9610
|
var _response$next;
|
|
9304
9611
|
|
|
9305
|
-
return _objectSpread$
|
|
9612
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9306
9613
|
threads: nextThreads,
|
|
9307
9614
|
unseenThreadIds: [],
|
|
9308
9615
|
isThreadOrderStale: false,
|
|
9309
|
-
pagination: _objectSpread$
|
|
9616
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9310
9617
|
isLoading: false,
|
|
9311
9618
|
nextCursor: (_response$next = response.next) !== null && _response$next !== void 0 ? _response$next : null
|
|
9312
9619
|
}),
|
|
@@ -9324,8 +9631,8 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9324
9631
|
_this.client.logger('error', _context.t0.message);
|
|
9325
9632
|
|
|
9326
9633
|
_this.state.next(function (current) {
|
|
9327
|
-
return _objectSpread$
|
|
9328
|
-
pagination: _objectSpread$
|
|
9634
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9635
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9329
9636
|
isLoading: false
|
|
9330
9637
|
})
|
|
9331
9638
|
});
|
|
@@ -9341,7 +9648,7 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9341
9648
|
|
|
9342
9649
|
_defineProperty(this, "queryThreads", function () {
|
|
9343
9650
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9344
|
-
return _this.client.queryThreads(_objectSpread$
|
|
9651
|
+
return _this.client.queryThreads(_objectSpread$4({
|
|
9345
9652
|
limit: 25,
|
|
9346
9653
|
participant_limit: 10,
|
|
9347
9654
|
reply_limit: 10,
|
|
@@ -9374,13 +9681,13 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9374
9681
|
_context2.prev = 4;
|
|
9375
9682
|
|
|
9376
9683
|
_this.state.partialNext({
|
|
9377
|
-
pagination: _objectSpread$
|
|
9684
|
+
pagination: _objectSpread$4(_objectSpread$4({}, pagination), {}, {
|
|
9378
9685
|
isLoadingNext: true
|
|
9379
9686
|
})
|
|
9380
9687
|
});
|
|
9381
9688
|
|
|
9382
9689
|
_context2.next = 8;
|
|
9383
|
-
return _this.queryThreads(_objectSpread$
|
|
9690
|
+
return _this.queryThreads(_objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
9384
9691
|
next: pagination.nextCursor
|
|
9385
9692
|
}));
|
|
9386
9693
|
|
|
@@ -9390,9 +9697,9 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9390
9697
|
_this.state.next(function (current) {
|
|
9391
9698
|
var _response$next2;
|
|
9392
9699
|
|
|
9393
|
-
return _objectSpread$
|
|
9700
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9394
9701
|
threads: response.threads.length ? current.threads.concat(response.threads) : current.threads,
|
|
9395
|
-
pagination: _objectSpread$
|
|
9702
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9396
9703
|
nextCursor: (_response$next2 = response.next) !== null && _response$next2 !== void 0 ? _response$next2 : null,
|
|
9397
9704
|
isLoadingNext: false
|
|
9398
9705
|
})
|
|
@@ -9409,8 +9716,8 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9409
9716
|
_this.client.logger('error', _context2.t0.message);
|
|
9410
9717
|
|
|
9411
9718
|
_this.state.next(function (current) {
|
|
9412
|
-
return _objectSpread$
|
|
9413
|
-
pagination: _objectSpread$
|
|
9719
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9720
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9414
9721
|
isLoadingNext: false
|
|
9415
9722
|
})
|
|
9416
9723
|
});
|
|
@@ -9458,9 +9765,9 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9458
9765
|
var _excluded$2 = ["own_votes", "id"],
|
|
9459
9766
|
_excluded2$1 = ["id"];
|
|
9460
9767
|
|
|
9461
|
-
function ownKeys$
|
|
9768
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
9462
9769
|
|
|
9463
|
-
function _objectSpread$
|
|
9770
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9464
9771
|
|
|
9465
9772
|
var isPollUpdatedEvent = function isPollUpdatedEvent(e) {
|
|
9466
9773
|
return e.type === 'poll.updated';
|
|
@@ -9526,7 +9833,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9526
9833
|
ownAnswer = _ref2.ownAnswer,
|
|
9527
9834
|
ownVotes = _ref2.ownVotes;
|
|
9528
9835
|
|
|
9529
|
-
return _objectSpread$
|
|
9836
|
+
return _objectSpread$3(_objectSpread$3({}, pollResponseForState), {}, {
|
|
9530
9837
|
lastActivityAt: new Date(),
|
|
9531
9838
|
maxVotedOptionIds: getMaxVotedOptionIds(pollResponseForState.vote_counts_by_option),
|
|
9532
9839
|
ownAnswer: ownAnswer,
|
|
@@ -9548,7 +9855,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9548
9855
|
pollData = _objectWithoutProperties(_extractPollData, _excluded2$1); // @ts-ignore
|
|
9549
9856
|
|
|
9550
9857
|
|
|
9551
|
-
_this.state.partialNext(_objectSpread$
|
|
9858
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, pollData), {}, {
|
|
9552
9859
|
lastActivityAt: new Date(event.created_at)
|
|
9553
9860
|
}));
|
|
9554
9861
|
});
|
|
@@ -9595,7 +9902,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9595
9902
|
|
|
9596
9903
|
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9597
9904
|
|
|
9598
|
-
_this.state.partialNext(_objectSpread$
|
|
9905
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, pollEnrichData), {}, {
|
|
9599
9906
|
latest_answers: latestAnswers,
|
|
9600
9907
|
lastActivityAt: new Date(event.created_at),
|
|
9601
9908
|
ownAnswer: ownAnswer,
|
|
@@ -9660,7 +9967,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9660
9967
|
|
|
9661
9968
|
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9662
9969
|
|
|
9663
|
-
_this.state.partialNext(_objectSpread$
|
|
9970
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, pollEnrichData), {}, {
|
|
9664
9971
|
latest_answers: latestAnswers,
|
|
9665
9972
|
lastActivityAt: new Date(event.created_at),
|
|
9666
9973
|
ownAnswer: ownAnswer,
|
|
@@ -9681,7 +9988,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9681
9988
|
|
|
9682
9989
|
var ownAnswer = currentState.ownAnswer;
|
|
9683
9990
|
|
|
9684
|
-
var ownVotesByOptionId = _objectSpread$
|
|
9991
|
+
var ownVotesByOptionId = _objectSpread$3({}, currentState.ownVotesByOptionId);
|
|
9685
9992
|
|
|
9686
9993
|
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
9687
9994
|
|
|
@@ -9703,7 +10010,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9703
10010
|
|
|
9704
10011
|
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9705
10012
|
|
|
9706
|
-
_this.state.partialNext(_objectSpread$
|
|
10013
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, pollEnrichData), {}, {
|
|
9707
10014
|
latest_answers: latestAnswers,
|
|
9708
10015
|
lastActivityAt: new Date(event.created_at),
|
|
9709
10016
|
ownAnswer: ownAnswer,
|
|
@@ -9728,7 +10035,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9728
10035
|
poll = _yield$_this$client$g.poll;
|
|
9729
10036
|
|
|
9730
10037
|
// @ts-ignore
|
|
9731
|
-
_this.state.partialNext(_objectSpread$
|
|
10038
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, poll), {}, {
|
|
9732
10039
|
lastActivityAt: new Date()
|
|
9733
10040
|
}));
|
|
9734
10041
|
|
|
@@ -9754,7 +10061,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9754
10061
|
switch (_context2.prev = _context2.next) {
|
|
9755
10062
|
case 0:
|
|
9756
10063
|
_context2.next = 2;
|
|
9757
|
-
return _this.client.updatePoll(_objectSpread$
|
|
10064
|
+
return _this.client.updatePoll(_objectSpread$3(_objectSpread$3({}, data), {}, {
|
|
9758
10065
|
id: _this.id
|
|
9759
10066
|
}));
|
|
9760
10067
|
|
|
@@ -10465,6 +10772,690 @@ var PollManager = /*#__PURE__*/function () {
|
|
|
10465
10772
|
return PollManager;
|
|
10466
10773
|
}();
|
|
10467
10774
|
|
|
10775
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
10776
|
+
|
|
10777
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10778
|
+
var channelManagerEventToHandlerMapping = {
|
|
10779
|
+
'channel.deleted': 'channelDeletedHandler',
|
|
10780
|
+
'channel.hidden': 'channelHiddenHandler',
|
|
10781
|
+
'channel.truncated': 'channelTruncatedHandler',
|
|
10782
|
+
'channel.visible': 'channelVisibleHandler',
|
|
10783
|
+
'message.new': 'newMessageHandler',
|
|
10784
|
+
'member.updated': 'memberUpdatedHandler',
|
|
10785
|
+
'notification.added_to_channel': 'notificationAddedToChannelHandler',
|
|
10786
|
+
'notification.message_new': 'notificationNewMessageHandler',
|
|
10787
|
+
'notification.removed_from_channel': 'notificationRemovedFromChannelHandler'
|
|
10788
|
+
};
|
|
10789
|
+
var DEFAULT_CHANNEL_MANAGER_OPTIONS = {
|
|
10790
|
+
abortInFlightQuery: false,
|
|
10791
|
+
allowNotLoadedChannelPromotionForEvent: {
|
|
10792
|
+
'channel.visible': true,
|
|
10793
|
+
'message.new': true,
|
|
10794
|
+
'notification.added_to_channel': true,
|
|
10795
|
+
'notification.message_new': true
|
|
10796
|
+
},
|
|
10797
|
+
lockChannelOrder: false
|
|
10798
|
+
};
|
|
10799
|
+
var DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS = {
|
|
10800
|
+
limit: 10,
|
|
10801
|
+
offset: 0
|
|
10802
|
+
};
|
|
10803
|
+
/**
|
|
10804
|
+
* A class that manages a list of channels and changes it based on configuration and WS events. The
|
|
10805
|
+
* list of channels is reactive as well as the pagination and it can be subscribed to for state updates.
|
|
10806
|
+
*
|
|
10807
|
+
* @internal
|
|
10808
|
+
*/
|
|
10809
|
+
|
|
10810
|
+
var ChannelManager = function ChannelManager(_ref) {
|
|
10811
|
+
var _this = this;
|
|
10812
|
+
|
|
10813
|
+
var client = _ref.client,
|
|
10814
|
+
_ref$eventHandlerOver = _ref.eventHandlerOverrides,
|
|
10815
|
+
_eventHandlerOverrides = _ref$eventHandlerOver === void 0 ? {} : _ref$eventHandlerOver,
|
|
10816
|
+
_ref$options = _ref.options,
|
|
10817
|
+
_options = _ref$options === void 0 ? {} : _ref$options;
|
|
10818
|
+
|
|
10819
|
+
_classCallCheck(this, ChannelManager);
|
|
10820
|
+
|
|
10821
|
+
_defineProperty(this, "state", void 0);
|
|
10822
|
+
|
|
10823
|
+
_defineProperty(this, "client", void 0);
|
|
10824
|
+
|
|
10825
|
+
_defineProperty(this, "unsubscribeFunctions", new Set());
|
|
10826
|
+
|
|
10827
|
+
_defineProperty(this, "eventHandlers", new Map());
|
|
10828
|
+
|
|
10829
|
+
_defineProperty(this, "eventHandlerOverrides", new Map());
|
|
10830
|
+
|
|
10831
|
+
_defineProperty(this, "options", {});
|
|
10832
|
+
|
|
10833
|
+
_defineProperty(this, "stateOptions", {});
|
|
10834
|
+
|
|
10835
|
+
_defineProperty(this, "setChannels", function (valueOrFactory) {
|
|
10836
|
+
_this.state.next(function (current) {
|
|
10837
|
+
var currentChannels = current.channels;
|
|
10838
|
+
var newChannels = isPatch(valueOrFactory) ? valueOrFactory(currentChannels) : valueOrFactory; // If the references between the two values are the same, just return the
|
|
10839
|
+
// current state; otherwise trigger a state change.
|
|
10840
|
+
|
|
10841
|
+
if (currentChannels === newChannels) {
|
|
10842
|
+
return current;
|
|
10843
|
+
}
|
|
10844
|
+
|
|
10845
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
10846
|
+
channels: newChannels
|
|
10847
|
+
});
|
|
10848
|
+
});
|
|
10849
|
+
});
|
|
10850
|
+
|
|
10851
|
+
_defineProperty(this, "setEventHandlerOverrides", function () {
|
|
10852
|
+
var eventHandlerOverrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10853
|
+
var truthyEventHandlerOverrides = Object.entries(eventHandlerOverrides).reduce(function (acc, _ref2) {
|
|
10854
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
10855
|
+
key = _ref3[0],
|
|
10856
|
+
value = _ref3[1];
|
|
10857
|
+
|
|
10858
|
+
if (value) {
|
|
10859
|
+
acc[key] = value;
|
|
10860
|
+
}
|
|
10861
|
+
|
|
10862
|
+
return acc;
|
|
10863
|
+
}, {});
|
|
10864
|
+
_this.eventHandlerOverrides = new Map(Object.entries(truthyEventHandlerOverrides));
|
|
10865
|
+
});
|
|
10866
|
+
|
|
10867
|
+
_defineProperty(this, "setOptions", function () {
|
|
10868
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10869
|
+
_this.options = _objectSpread$2(_objectSpread$2({}, DEFAULT_CHANNEL_MANAGER_OPTIONS), options);
|
|
10870
|
+
});
|
|
10871
|
+
|
|
10872
|
+
_defineProperty(this, "queryChannels", /*#__PURE__*/function () {
|
|
10873
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(filters) {
|
|
10874
|
+
var sort,
|
|
10875
|
+
options,
|
|
10876
|
+
stateOptions,
|
|
10877
|
+
_DEFAULT_CHANNEL_MANA,
|
|
10878
|
+
offset,
|
|
10879
|
+
limit,
|
|
10880
|
+
_this$state$getLatest,
|
|
10881
|
+
isLoading,
|
|
10882
|
+
_channels$length,
|
|
10883
|
+
_channels$length2,
|
|
10884
|
+
channels,
|
|
10885
|
+
newOffset,
|
|
10886
|
+
newOptions,
|
|
10887
|
+
_this$state$getLatest2,
|
|
10888
|
+
pagination,
|
|
10889
|
+
_args = arguments;
|
|
10890
|
+
|
|
10891
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
10892
|
+
while (1) {
|
|
10893
|
+
switch (_context.prev = _context.next) {
|
|
10894
|
+
case 0:
|
|
10895
|
+
sort = _args.length > 1 && _args[1] !== undefined ? _args[1] : [];
|
|
10896
|
+
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
10897
|
+
stateOptions = _args.length > 3 && _args[3] !== undefined ? _args[3] : {};
|
|
10898
|
+
_DEFAULT_CHANNEL_MANA = _objectSpread$2(_objectSpread$2({}, DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS), options), offset = _DEFAULT_CHANNEL_MANA.offset, limit = _DEFAULT_CHANNEL_MANA.limit;
|
|
10899
|
+
_this$state$getLatest = _this.state.getLatestValue(), isLoading = _this$state$getLatest.pagination.isLoading;
|
|
10900
|
+
|
|
10901
|
+
if (!(isLoading && !_this.options.abortInFlightQuery)) {
|
|
10902
|
+
_context.next = 7;
|
|
10903
|
+
break;
|
|
10904
|
+
}
|
|
10905
|
+
|
|
10906
|
+
return _context.abrupt("return");
|
|
10907
|
+
|
|
10908
|
+
case 7:
|
|
10909
|
+
_context.prev = 7;
|
|
10910
|
+
_this.stateOptions = stateOptions;
|
|
10911
|
+
|
|
10912
|
+
_this.state.next(function (currentState) {
|
|
10913
|
+
return _objectSpread$2(_objectSpread$2({}, currentState), {}, {
|
|
10914
|
+
pagination: _objectSpread$2(_objectSpread$2({}, currentState.pagination), {}, {
|
|
10915
|
+
isLoading: true,
|
|
10916
|
+
isLoadingNext: false,
|
|
10917
|
+
filters: filters,
|
|
10918
|
+
sort: sort,
|
|
10919
|
+
options: options
|
|
10920
|
+
})
|
|
10921
|
+
});
|
|
10922
|
+
});
|
|
10923
|
+
|
|
10924
|
+
_context.next = 12;
|
|
10925
|
+
return _this.client.queryChannels(filters, sort, options, stateOptions);
|
|
10926
|
+
|
|
10927
|
+
case 12:
|
|
10928
|
+
channels = _context.sent;
|
|
10929
|
+
newOffset = offset + ((_channels$length = channels === null || channels === void 0 ? void 0 : channels.length) !== null && _channels$length !== void 0 ? _channels$length : 0);
|
|
10930
|
+
newOptions = _objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
10931
|
+
offset: newOffset
|
|
10932
|
+
});
|
|
10933
|
+
_this$state$getLatest2 = _this.state.getLatestValue(), pagination = _this$state$getLatest2.pagination;
|
|
10934
|
+
|
|
10935
|
+
_this.state.partialNext({
|
|
10936
|
+
channels: channels,
|
|
10937
|
+
pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
|
|
10938
|
+
hasNext: ((_channels$length2 = channels === null || channels === void 0 ? void 0 : channels.length) !== null && _channels$length2 !== void 0 ? _channels$length2 : 0) >= limit,
|
|
10939
|
+
isLoading: false,
|
|
10940
|
+
options: newOptions
|
|
10941
|
+
}),
|
|
10942
|
+
initialized: true
|
|
10943
|
+
});
|
|
10944
|
+
|
|
10945
|
+
_context.next = 24;
|
|
10946
|
+
break;
|
|
10947
|
+
|
|
10948
|
+
case 19:
|
|
10949
|
+
_context.prev = 19;
|
|
10950
|
+
_context.t0 = _context["catch"](7);
|
|
10951
|
+
|
|
10952
|
+
_this.client.logger('error', _context.t0.message);
|
|
10953
|
+
|
|
10954
|
+
_this.state.next(function (currentState) {
|
|
10955
|
+
return _objectSpread$2(_objectSpread$2({}, currentState), {}, {
|
|
10956
|
+
pagination: _objectSpread$2(_objectSpread$2({}, currentState.pagination), {}, {
|
|
10957
|
+
isLoading: false
|
|
10958
|
+
})
|
|
10959
|
+
});
|
|
10960
|
+
});
|
|
10961
|
+
|
|
10962
|
+
throw _context.t0;
|
|
10963
|
+
|
|
10964
|
+
case 24:
|
|
10965
|
+
case "end":
|
|
10966
|
+
return _context.stop();
|
|
10967
|
+
}
|
|
10968
|
+
}
|
|
10969
|
+
}, _callee, null, [[7, 19]]);
|
|
10970
|
+
}));
|
|
10971
|
+
|
|
10972
|
+
return function (_x) {
|
|
10973
|
+
return _ref4.apply(this, arguments);
|
|
10974
|
+
};
|
|
10975
|
+
}());
|
|
10976
|
+
|
|
10977
|
+
_defineProperty(this, "loadNext", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
10978
|
+
var _this$state$getLatest3, pagination, initialized, filters, sort, options, isLoadingNext, hasNext, _nextChannels$length, _nextChannels$length2, _DEFAULT_CHANNEL_MANA2, offset, limit, nextChannels, _this$state$getLatest4, channels, newOffset, newOptions;
|
|
10979
|
+
|
|
10980
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
10981
|
+
while (1) {
|
|
10982
|
+
switch (_context2.prev = _context2.next) {
|
|
10983
|
+
case 0:
|
|
10984
|
+
_this$state$getLatest3 = _this.state.getLatestValue(), pagination = _this$state$getLatest3.pagination, initialized = _this$state$getLatest3.initialized;
|
|
10985
|
+
filters = pagination.filters, sort = pagination.sort, options = pagination.options, isLoadingNext = pagination.isLoadingNext, hasNext = pagination.hasNext;
|
|
10986
|
+
|
|
10987
|
+
if (!(!initialized || isLoadingNext || !hasNext)) {
|
|
10988
|
+
_context2.next = 4;
|
|
10989
|
+
break;
|
|
10990
|
+
}
|
|
10991
|
+
|
|
10992
|
+
return _context2.abrupt("return");
|
|
10993
|
+
|
|
10994
|
+
case 4:
|
|
10995
|
+
_context2.prev = 4;
|
|
10996
|
+
_DEFAULT_CHANNEL_MANA2 = _objectSpread$2(_objectSpread$2({}, DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS), options), offset = _DEFAULT_CHANNEL_MANA2.offset, limit = _DEFAULT_CHANNEL_MANA2.limit;
|
|
10997
|
+
|
|
10998
|
+
_this.state.partialNext({
|
|
10999
|
+
pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
|
|
11000
|
+
isLoading: false,
|
|
11001
|
+
isLoadingNext: true
|
|
11002
|
+
})
|
|
11003
|
+
});
|
|
11004
|
+
|
|
11005
|
+
_context2.next = 9;
|
|
11006
|
+
return _this.client.queryChannels(filters, sort, options, _this.stateOptions);
|
|
11007
|
+
|
|
11008
|
+
case 9:
|
|
11009
|
+
nextChannels = _context2.sent;
|
|
11010
|
+
_this$state$getLatest4 = _this.state.getLatestValue(), channels = _this$state$getLatest4.channels;
|
|
11011
|
+
newOffset = offset + ((_nextChannels$length = nextChannels === null || nextChannels === void 0 ? void 0 : nextChannels.length) !== null && _nextChannels$length !== void 0 ? _nextChannels$length : 0);
|
|
11012
|
+
newOptions = _objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
11013
|
+
offset: newOffset
|
|
11014
|
+
});
|
|
11015
|
+
|
|
11016
|
+
_this.state.partialNext({
|
|
11017
|
+
channels: uniqBy([].concat(_toConsumableArray(channels || []), _toConsumableArray(nextChannels)), 'cid'),
|
|
11018
|
+
pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
|
|
11019
|
+
hasNext: ((_nextChannels$length2 = nextChannels === null || nextChannels === void 0 ? void 0 : nextChannels.length) !== null && _nextChannels$length2 !== void 0 ? _nextChannels$length2 : 0) >= limit,
|
|
11020
|
+
isLoading: false,
|
|
11021
|
+
isLoadingNext: false,
|
|
11022
|
+
options: newOptions
|
|
11023
|
+
})
|
|
11024
|
+
});
|
|
11025
|
+
|
|
11026
|
+
_context2.next = 21;
|
|
11027
|
+
break;
|
|
11028
|
+
|
|
11029
|
+
case 16:
|
|
11030
|
+
_context2.prev = 16;
|
|
11031
|
+
_context2.t0 = _context2["catch"](4);
|
|
11032
|
+
|
|
11033
|
+
_this.client.logger('error', _context2.t0.message);
|
|
11034
|
+
|
|
11035
|
+
_this.state.next(function (currentState) {
|
|
11036
|
+
return _objectSpread$2(_objectSpread$2({}, currentState), {}, {
|
|
11037
|
+
pagination: _objectSpread$2(_objectSpread$2({}, currentState.pagination), {}, {
|
|
11038
|
+
isLoadingNext: false
|
|
11039
|
+
})
|
|
11040
|
+
});
|
|
11041
|
+
});
|
|
11042
|
+
|
|
11043
|
+
throw _context2.t0;
|
|
11044
|
+
|
|
11045
|
+
case 21:
|
|
11046
|
+
case "end":
|
|
11047
|
+
return _context2.stop();
|
|
11048
|
+
}
|
|
11049
|
+
}
|
|
11050
|
+
}, _callee2, null, [[4, 16]]);
|
|
11051
|
+
})));
|
|
11052
|
+
|
|
11053
|
+
_defineProperty(this, "notificationAddedToChannelHandler", /*#__PURE__*/function () {
|
|
11054
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(event) {
|
|
11055
|
+
var _event$channel, _this$options$allowNo;
|
|
11056
|
+
|
|
11057
|
+
var _ref7, id, type, members, channel, _this$state$getLatest5, pagination, channels, _ref9, sort;
|
|
11058
|
+
|
|
11059
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
11060
|
+
while (1) {
|
|
11061
|
+
switch (_context3.prev = _context3.next) {
|
|
11062
|
+
case 0:
|
|
11063
|
+
_ref7 = (_event$channel = event === null || event === void 0 ? void 0 : event.channel) !== null && _event$channel !== void 0 ? _event$channel : {}, id = _ref7.id, type = _ref7.type, members = _ref7.members;
|
|
11064
|
+
|
|
11065
|
+
if (!(!type || !((_this$options$allowNo = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo !== void 0 && _this$options$allowNo['notification.added_to_channel']))) {
|
|
11066
|
+
_context3.next = 3;
|
|
11067
|
+
break;
|
|
11068
|
+
}
|
|
11069
|
+
|
|
11070
|
+
return _context3.abrupt("return");
|
|
11071
|
+
|
|
11072
|
+
case 3:
|
|
11073
|
+
_context3.next = 5;
|
|
11074
|
+
return getAndWatchChannel({
|
|
11075
|
+
client: _this.client,
|
|
11076
|
+
id: id,
|
|
11077
|
+
members: members === null || members === void 0 ? void 0 : members.reduce(function (acc, _ref8) {
|
|
11078
|
+
var user = _ref8.user,
|
|
11079
|
+
user_id = _ref8.user_id;
|
|
11080
|
+
var userId = user_id || (user === null || user === void 0 ? void 0 : user.id);
|
|
11081
|
+
|
|
11082
|
+
if (userId) {
|
|
11083
|
+
acc.push(userId);
|
|
11084
|
+
}
|
|
11085
|
+
|
|
11086
|
+
return acc;
|
|
11087
|
+
}, []),
|
|
11088
|
+
type: type
|
|
11089
|
+
});
|
|
11090
|
+
|
|
11091
|
+
case 5:
|
|
11092
|
+
channel = _context3.sent;
|
|
11093
|
+
_this$state$getLatest5 = _this.state.getLatestValue(), pagination = _this$state$getLatest5.pagination, channels = _this$state$getLatest5.channels;
|
|
11094
|
+
|
|
11095
|
+
if (channels) {
|
|
11096
|
+
_context3.next = 9;
|
|
11097
|
+
break;
|
|
11098
|
+
}
|
|
11099
|
+
|
|
11100
|
+
return _context3.abrupt("return");
|
|
11101
|
+
|
|
11102
|
+
case 9:
|
|
11103
|
+
_ref9 = pagination !== null && pagination !== void 0 ? pagination : {}, sort = _ref9.sort;
|
|
11104
|
+
|
|
11105
|
+
_this.setChannels(promoteChannel({
|
|
11106
|
+
channels: channels,
|
|
11107
|
+
channelToMove: channel,
|
|
11108
|
+
sort: sort
|
|
11109
|
+
}));
|
|
11110
|
+
|
|
11111
|
+
case 11:
|
|
11112
|
+
case "end":
|
|
11113
|
+
return _context3.stop();
|
|
11114
|
+
}
|
|
11115
|
+
}
|
|
11116
|
+
}, _callee3);
|
|
11117
|
+
}));
|
|
11118
|
+
|
|
11119
|
+
return function (_x2) {
|
|
11120
|
+
return _ref6.apply(this, arguments);
|
|
11121
|
+
};
|
|
11122
|
+
}());
|
|
11123
|
+
|
|
11124
|
+
_defineProperty(this, "channelDeletedHandler", function (event) {
|
|
11125
|
+
var _this$state$getLatest6 = _this.state.getLatestValue(),
|
|
11126
|
+
channels = _this$state$getLatest6.channels;
|
|
11127
|
+
|
|
11128
|
+
if (!channels) {
|
|
11129
|
+
return;
|
|
11130
|
+
}
|
|
11131
|
+
|
|
11132
|
+
var newChannels = _toConsumableArray(channels);
|
|
11133
|
+
|
|
11134
|
+
var channelIndex = newChannels.findIndex(function (channel) {
|
|
11135
|
+
var _event$channel2;
|
|
11136
|
+
|
|
11137
|
+
return channel.cid === (event.cid || ((_event$channel2 = event.channel) === null || _event$channel2 === void 0 ? void 0 : _event$channel2.cid));
|
|
11138
|
+
});
|
|
11139
|
+
|
|
11140
|
+
if (channelIndex < 0) {
|
|
11141
|
+
return;
|
|
11142
|
+
}
|
|
11143
|
+
|
|
11144
|
+
newChannels.splice(channelIndex, 1);
|
|
11145
|
+
|
|
11146
|
+
_this.setChannels(newChannels);
|
|
11147
|
+
});
|
|
11148
|
+
|
|
11149
|
+
_defineProperty(this, "channelHiddenHandler", this.channelDeletedHandler);
|
|
11150
|
+
|
|
11151
|
+
_defineProperty(this, "newMessageHandler", function (event) {
|
|
11152
|
+
var _this$options$allowNo2;
|
|
11153
|
+
|
|
11154
|
+
var _this$state$getLatest7 = _this.state.getLatestValue(),
|
|
11155
|
+
pagination = _this$state$getLatest7.pagination,
|
|
11156
|
+
channels = _this$state$getLatest7.channels;
|
|
11157
|
+
|
|
11158
|
+
if (!channels) {
|
|
11159
|
+
return;
|
|
11160
|
+
}
|
|
11161
|
+
|
|
11162
|
+
var _ref10 = pagination !== null && pagination !== void 0 ? pagination : {},
|
|
11163
|
+
filters = _ref10.filters,
|
|
11164
|
+
sort = _ref10.sort;
|
|
11165
|
+
|
|
11166
|
+
var channelType = event.channel_type;
|
|
11167
|
+
var channelId = event.channel_id;
|
|
11168
|
+
|
|
11169
|
+
if (!channelType || !channelId) {
|
|
11170
|
+
return;
|
|
11171
|
+
}
|
|
11172
|
+
|
|
11173
|
+
var targetChannel = _this.client.channel(channelType, channelId);
|
|
11174
|
+
|
|
11175
|
+
var targetChannelIndex = channels.indexOf(targetChannel);
|
|
11176
|
+
var targetChannelExistsWithinList = targetChannelIndex >= 0;
|
|
11177
|
+
var isTargetChannelPinned = isChannelPinned(targetChannel);
|
|
11178
|
+
var isTargetChannelArchived = isChannelArchived(targetChannel);
|
|
11179
|
+
var considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
11180
|
+
var considerPinnedChannels = shouldConsiderPinnedChannels(sort);
|
|
11181
|
+
|
|
11182
|
+
if ( // filter is defined, target channel is archived and filter option is set to false
|
|
11183
|
+
considerArchivedChannels && isTargetChannelArchived && !filters.archived || // filter is defined, target channel isn't archived and filter option is set to true
|
|
11184
|
+
considerArchivedChannels && !isTargetChannelArchived && filters.archived || // sort option is defined, target channel is pinned
|
|
11185
|
+
considerPinnedChannels && isTargetChannelPinned || // list order is locked
|
|
11186
|
+
_this.options.lockChannelOrder || // target channel is not within the loaded list and loading from cache is disallowed
|
|
11187
|
+
!targetChannelExistsWithinList && !((_this$options$allowNo2 = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo2 !== void 0 && _this$options$allowNo2['message.new'])) {
|
|
11188
|
+
return;
|
|
11189
|
+
}
|
|
11190
|
+
|
|
11191
|
+
_this.setChannels(promoteChannel({
|
|
11192
|
+
channels: channels,
|
|
11193
|
+
channelToMove: targetChannel,
|
|
11194
|
+
channelToMoveIndexWithinChannels: targetChannelIndex,
|
|
11195
|
+
sort: sort
|
|
11196
|
+
}));
|
|
11197
|
+
});
|
|
11198
|
+
|
|
11199
|
+
_defineProperty(this, "notificationNewMessageHandler", /*#__PURE__*/function () {
|
|
11200
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(event) {
|
|
11201
|
+
var _event$channel3, _this$options$allowNo3;
|
|
11202
|
+
|
|
11203
|
+
var _ref12, id, type, channel, _this$state$getLatest8, channels, pagination, _ref13, filters, sort, considerArchivedChannels, isTargetChannelArchived;
|
|
11204
|
+
|
|
11205
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
11206
|
+
while (1) {
|
|
11207
|
+
switch (_context4.prev = _context4.next) {
|
|
11208
|
+
case 0:
|
|
11209
|
+
_ref12 = (_event$channel3 = event === null || event === void 0 ? void 0 : event.channel) !== null && _event$channel3 !== void 0 ? _event$channel3 : {}, id = _ref12.id, type = _ref12.type;
|
|
11210
|
+
|
|
11211
|
+
if (!(!id || !type)) {
|
|
11212
|
+
_context4.next = 3;
|
|
11213
|
+
break;
|
|
11214
|
+
}
|
|
11215
|
+
|
|
11216
|
+
return _context4.abrupt("return");
|
|
11217
|
+
|
|
11218
|
+
case 3:
|
|
11219
|
+
_context4.next = 5;
|
|
11220
|
+
return getAndWatchChannel({
|
|
11221
|
+
client: _this.client,
|
|
11222
|
+
id: id,
|
|
11223
|
+
type: type
|
|
11224
|
+
});
|
|
11225
|
+
|
|
11226
|
+
case 5:
|
|
11227
|
+
channel = _context4.sent;
|
|
11228
|
+
_this$state$getLatest8 = _this.state.getLatestValue(), channels = _this$state$getLatest8.channels, pagination = _this$state$getLatest8.pagination;
|
|
11229
|
+
_ref13 = pagination !== null && pagination !== void 0 ? pagination : {}, filters = _ref13.filters, sort = _ref13.sort;
|
|
11230
|
+
considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
11231
|
+
isTargetChannelArchived = isChannelArchived(channel);
|
|
11232
|
+
|
|
11233
|
+
if (!(!channels || considerArchivedChannels && isTargetChannelArchived && !filters.archived || considerArchivedChannels && !isTargetChannelArchived && filters.archived || !((_this$options$allowNo3 = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo3 !== void 0 && _this$options$allowNo3['notification.message_new']))) {
|
|
11234
|
+
_context4.next = 12;
|
|
11235
|
+
break;
|
|
11236
|
+
}
|
|
11237
|
+
|
|
11238
|
+
return _context4.abrupt("return");
|
|
11239
|
+
|
|
11240
|
+
case 12:
|
|
11241
|
+
_this.setChannels(promoteChannel({
|
|
11242
|
+
channels: channels,
|
|
11243
|
+
channelToMove: channel,
|
|
11244
|
+
sort: sort
|
|
11245
|
+
}));
|
|
11246
|
+
|
|
11247
|
+
case 13:
|
|
11248
|
+
case "end":
|
|
11249
|
+
return _context4.stop();
|
|
11250
|
+
}
|
|
11251
|
+
}
|
|
11252
|
+
}, _callee4);
|
|
11253
|
+
}));
|
|
11254
|
+
|
|
11255
|
+
return function (_x3) {
|
|
11256
|
+
return _ref11.apply(this, arguments);
|
|
11257
|
+
};
|
|
11258
|
+
}());
|
|
11259
|
+
|
|
11260
|
+
_defineProperty(this, "channelVisibleHandler", /*#__PURE__*/function () {
|
|
11261
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(event) {
|
|
11262
|
+
var _this$options$allowNo4;
|
|
11263
|
+
|
|
11264
|
+
var channelType, channelId, channel, _this$state$getLatest9, channels, pagination, _ref15, sort, filters, considerArchivedChannels, isTargetChannelArchived;
|
|
11265
|
+
|
|
11266
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
11267
|
+
while (1) {
|
|
11268
|
+
switch (_context5.prev = _context5.next) {
|
|
11269
|
+
case 0:
|
|
11270
|
+
channelType = event.channel_type, channelId = event.channel_id;
|
|
11271
|
+
|
|
11272
|
+
if (!(!channelType || !channelId)) {
|
|
11273
|
+
_context5.next = 3;
|
|
11274
|
+
break;
|
|
11275
|
+
}
|
|
11276
|
+
|
|
11277
|
+
return _context5.abrupt("return");
|
|
11278
|
+
|
|
11279
|
+
case 3:
|
|
11280
|
+
_context5.next = 5;
|
|
11281
|
+
return getAndWatchChannel({
|
|
11282
|
+
client: _this.client,
|
|
11283
|
+
id: event.channel_id,
|
|
11284
|
+
type: event.channel_type
|
|
11285
|
+
});
|
|
11286
|
+
|
|
11287
|
+
case 5:
|
|
11288
|
+
channel = _context5.sent;
|
|
11289
|
+
_this$state$getLatest9 = _this.state.getLatestValue(), channels = _this$state$getLatest9.channels, pagination = _this$state$getLatest9.pagination;
|
|
11290
|
+
_ref15 = pagination !== null && pagination !== void 0 ? pagination : {}, sort = _ref15.sort, filters = _ref15.filters;
|
|
11291
|
+
considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
11292
|
+
isTargetChannelArchived = isChannelArchived(channel);
|
|
11293
|
+
|
|
11294
|
+
if (!(!channels || considerArchivedChannels && isTargetChannelArchived && !filters.archived || considerArchivedChannels && !isTargetChannelArchived && filters.archived || !((_this$options$allowNo4 = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo4 !== void 0 && _this$options$allowNo4['channel.visible']))) {
|
|
11295
|
+
_context5.next = 12;
|
|
11296
|
+
break;
|
|
11297
|
+
}
|
|
11298
|
+
|
|
11299
|
+
return _context5.abrupt("return");
|
|
11300
|
+
|
|
11301
|
+
case 12:
|
|
11302
|
+
_this.setChannels(promoteChannel({
|
|
11303
|
+
channels: channels,
|
|
11304
|
+
channelToMove: channel,
|
|
11305
|
+
sort: sort
|
|
11306
|
+
}));
|
|
11307
|
+
|
|
11308
|
+
case 13:
|
|
11309
|
+
case "end":
|
|
11310
|
+
return _context5.stop();
|
|
11311
|
+
}
|
|
11312
|
+
}
|
|
11313
|
+
}, _callee5);
|
|
11314
|
+
}));
|
|
11315
|
+
|
|
11316
|
+
return function (_x4) {
|
|
11317
|
+
return _ref14.apply(this, arguments);
|
|
11318
|
+
};
|
|
11319
|
+
}());
|
|
11320
|
+
|
|
11321
|
+
_defineProperty(this, "notificationRemovedFromChannelHandler", this.channelDeletedHandler);
|
|
11322
|
+
|
|
11323
|
+
_defineProperty(this, "memberUpdatedHandler", function (event) {
|
|
11324
|
+
var _event$member;
|
|
11325
|
+
|
|
11326
|
+
var _this$state$getLatest10 = _this.state.getLatestValue(),
|
|
11327
|
+
pagination = _this$state$getLatest10.pagination,
|
|
11328
|
+
channels = _this$state$getLatest10.channels;
|
|
11329
|
+
|
|
11330
|
+
var filters = pagination.filters,
|
|
11331
|
+
sort = pagination.sort;
|
|
11332
|
+
|
|
11333
|
+
if (!((_event$member = event.member) !== null && _event$member !== void 0 && _event$member.user) || event.member.user.id !== _this.client.userID || !event.channel_type || !event.channel_id) {
|
|
11334
|
+
return;
|
|
11335
|
+
}
|
|
11336
|
+
|
|
11337
|
+
var channelType = event.channel_type;
|
|
11338
|
+
var channelId = event.channel_id;
|
|
11339
|
+
var considerPinnedChannels = shouldConsiderPinnedChannels(sort);
|
|
11340
|
+
var considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
11341
|
+
var pinnedAtSort = extractSortValue({
|
|
11342
|
+
atIndex: 0,
|
|
11343
|
+
sort: sort,
|
|
11344
|
+
targetKey: 'pinned_at'
|
|
11345
|
+
});
|
|
11346
|
+
|
|
11347
|
+
if (!channels || !considerPinnedChannels && !considerArchivedChannels || _this.options.lockChannelOrder) {
|
|
11348
|
+
return;
|
|
11349
|
+
}
|
|
11350
|
+
|
|
11351
|
+
var targetChannel = _this.client.channel(channelType, channelId); // assumes that channel instances are not changing
|
|
11352
|
+
|
|
11353
|
+
|
|
11354
|
+
var targetChannelIndex = channels.indexOf(targetChannel);
|
|
11355
|
+
var targetChannelExistsWithinList = targetChannelIndex >= 0;
|
|
11356
|
+
var isTargetChannelPinned = isChannelPinned(targetChannel);
|
|
11357
|
+
var isTargetChannelArchived = isChannelArchived(targetChannel);
|
|
11358
|
+
|
|
11359
|
+
var newChannels = _toConsumableArray(channels);
|
|
11360
|
+
|
|
11361
|
+
if (targetChannelExistsWithinList) {
|
|
11362
|
+
newChannels.splice(targetChannelIndex, 1);
|
|
11363
|
+
} // handle archiving (remove channel)
|
|
11364
|
+
|
|
11365
|
+
|
|
11366
|
+
if ( // When archived filter true, and channel is unarchived
|
|
11367
|
+
considerArchivedChannels && !isTargetChannelArchived && filters !== null && filters !== void 0 && filters.archived || // When archived filter false, and channel is archived
|
|
11368
|
+
considerArchivedChannels && isTargetChannelArchived && !(filters !== null && filters !== void 0 && filters.archived)) {
|
|
11369
|
+
_this.setChannels(newChannels);
|
|
11370
|
+
|
|
11371
|
+
return;
|
|
11372
|
+
} // handle pinning
|
|
11373
|
+
|
|
11374
|
+
|
|
11375
|
+
var lastPinnedChannelIndex = null;
|
|
11376
|
+
|
|
11377
|
+
if (pinnedAtSort === 1 || pinnedAtSort === -1 && !isTargetChannelPinned) {
|
|
11378
|
+
lastPinnedChannelIndex = findLastPinnedChannelIndex({
|
|
11379
|
+
channels: newChannels
|
|
11380
|
+
});
|
|
11381
|
+
}
|
|
11382
|
+
|
|
11383
|
+
var newTargetChannelIndex = typeof lastPinnedChannelIndex === 'number' ? lastPinnedChannelIndex + 1 : 0; // skip state update if the position of the channel does not change
|
|
11384
|
+
|
|
11385
|
+
if (channels[newTargetChannelIndex] === targetChannel) {
|
|
11386
|
+
return;
|
|
11387
|
+
}
|
|
11388
|
+
|
|
11389
|
+
newChannels.splice(newTargetChannelIndex, 0, targetChannel);
|
|
11390
|
+
|
|
11391
|
+
_this.setChannels(newChannels);
|
|
11392
|
+
});
|
|
11393
|
+
|
|
11394
|
+
_defineProperty(this, "subscriptionOrOverride", function (event) {
|
|
11395
|
+
var handlerName = channelManagerEventToHandlerMapping[event.type];
|
|
11396
|
+
|
|
11397
|
+
var defaultEventHandler = _this.eventHandlers.get(handlerName);
|
|
11398
|
+
|
|
11399
|
+
var eventHandlerOverride = _this.eventHandlerOverrides.get(handlerName);
|
|
11400
|
+
|
|
11401
|
+
if (eventHandlerOverride && typeof eventHandlerOverride === 'function') {
|
|
11402
|
+
eventHandlerOverride(_this.setChannels, event);
|
|
11403
|
+
return;
|
|
11404
|
+
}
|
|
11405
|
+
|
|
11406
|
+
if (defaultEventHandler && typeof defaultEventHandler === 'function') {
|
|
11407
|
+
defaultEventHandler(event);
|
|
11408
|
+
}
|
|
11409
|
+
});
|
|
11410
|
+
|
|
11411
|
+
_defineProperty(this, "registerSubscriptions", function () {
|
|
11412
|
+
if (_this.unsubscribeFunctions.size) {
|
|
11413
|
+
// Already listening for events and changes
|
|
11414
|
+
return;
|
|
11415
|
+
}
|
|
11416
|
+
|
|
11417
|
+
for (var _i = 0, _Object$keys = Object.keys(channelManagerEventToHandlerMapping); _i < _Object$keys.length; _i++) {
|
|
11418
|
+
var eventType = _Object$keys[_i];
|
|
11419
|
+
|
|
11420
|
+
_this.unsubscribeFunctions.add(_this.client.on(eventType, _this.subscriptionOrOverride).unsubscribe);
|
|
11421
|
+
}
|
|
11422
|
+
});
|
|
11423
|
+
|
|
11424
|
+
_defineProperty(this, "unregisterSubscriptions", function () {
|
|
11425
|
+
_this.unsubscribeFunctions.forEach(function (cleanupFunction) {
|
|
11426
|
+
return cleanupFunction();
|
|
11427
|
+
});
|
|
11428
|
+
|
|
11429
|
+
_this.unsubscribeFunctions.clear();
|
|
11430
|
+
});
|
|
11431
|
+
|
|
11432
|
+
this.client = client;
|
|
11433
|
+
this.state = new StateStore({
|
|
11434
|
+
channels: [],
|
|
11435
|
+
pagination: {
|
|
11436
|
+
isLoading: false,
|
|
11437
|
+
isLoadingNext: false,
|
|
11438
|
+
hasNext: false,
|
|
11439
|
+
filters: {},
|
|
11440
|
+
sort: {},
|
|
11441
|
+
options: DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS
|
|
11442
|
+
},
|
|
11443
|
+
initialized: false
|
|
11444
|
+
});
|
|
11445
|
+
this.setEventHandlerOverrides(_eventHandlerOverrides);
|
|
11446
|
+
this.setOptions(_options);
|
|
11447
|
+
this.eventHandlers = new Map(Object.entries({
|
|
11448
|
+
channelDeletedHandler: this.channelDeletedHandler,
|
|
11449
|
+
channelHiddenHandler: this.channelHiddenHandler,
|
|
11450
|
+
channelVisibleHandler: this.channelVisibleHandler,
|
|
11451
|
+
memberUpdatedHandler: this.memberUpdatedHandler,
|
|
11452
|
+
newMessageHandler: this.newMessageHandler,
|
|
11453
|
+
notificationAddedToChannelHandler: this.notificationAddedToChannelHandler,
|
|
11454
|
+
notificationNewMessageHandler: this.notificationNewMessageHandler,
|
|
11455
|
+
notificationRemovedFromChannelHandler: this.notificationRemovedFromChannelHandler
|
|
11456
|
+
}));
|
|
11457
|
+
};
|
|
11458
|
+
|
|
10468
11459
|
var _excluded$1 = ["created_at", "updated_at", "last_active", "online"],
|
|
10469
11460
|
_excluded2 = ["params", "headers"];
|
|
10470
11461
|
|
|
@@ -10692,6 +11683,18 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10692
11683
|
};
|
|
10693
11684
|
}());
|
|
10694
11685
|
|
|
11686
|
+
_defineProperty(this, "createChannelManager", function (_ref3) {
|
|
11687
|
+
var _ref3$eventHandlerOve = _ref3.eventHandlerOverrides,
|
|
11688
|
+
eventHandlerOverrides = _ref3$eventHandlerOve === void 0 ? {} : _ref3$eventHandlerOve,
|
|
11689
|
+
_ref3$options = _ref3.options,
|
|
11690
|
+
options = _ref3$options === void 0 ? {} : _ref3$options;
|
|
11691
|
+
return new ChannelManager({
|
|
11692
|
+
client: _this,
|
|
11693
|
+
eventHandlerOverrides: eventHandlerOverrides,
|
|
11694
|
+
options: options
|
|
11695
|
+
});
|
|
11696
|
+
});
|
|
11697
|
+
|
|
10695
11698
|
_defineProperty(this, "openConnection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
10696
11699
|
var _this$wsConnection3, _this$wsConnection4, _this$wsFallback3;
|
|
10697
11700
|
|
|
@@ -10761,7 +11764,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10761
11764
|
});
|
|
10762
11765
|
|
|
10763
11766
|
_defineProperty(this, "disconnectUser", /*#__PURE__*/function () {
|
|
10764
|
-
var
|
|
11767
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(timeout) {
|
|
10765
11768
|
var closePromise, _i, _Object$values, _channel;
|
|
10766
11769
|
|
|
10767
11770
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
@@ -10809,7 +11812,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10809
11812
|
}));
|
|
10810
11813
|
|
|
10811
11814
|
return function (_x4) {
|
|
10812
|
-
return
|
|
11815
|
+
return _ref5.apply(this, arguments);
|
|
10813
11816
|
};
|
|
10814
11817
|
}());
|
|
10815
11818
|
|
|
@@ -10837,7 +11840,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10837
11840
|
_defineProperty(this, "setAnonymousUser", this.connectAnonymousUser);
|
|
10838
11841
|
|
|
10839
11842
|
_defineProperty(this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
10840
|
-
var
|
|
11843
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(type, url, data) {
|
|
10841
11844
|
var options,
|
|
10842
11845
|
requestConfig,
|
|
10843
11846
|
response,
|
|
@@ -10978,7 +11981,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10978
11981
|
}));
|
|
10979
11982
|
|
|
10980
11983
|
return function (_x5, _x6, _x7) {
|
|
10981
|
-
return
|
|
11984
|
+
return _ref6.apply(this, arguments);
|
|
10982
11985
|
};
|
|
10983
11986
|
}());
|
|
10984
11987
|
|
|
@@ -11199,13 +12202,19 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11199
12202
|
})));
|
|
11200
12203
|
|
|
11201
12204
|
_defineProperty(this, "getChannelByMembers", function (channelType, custom) {
|
|
12205
|
+
var _custom$members;
|
|
12206
|
+
|
|
11202
12207
|
// Check if the channel already exists.
|
|
11203
12208
|
// Only allow 1 channel object per cid
|
|
11204
|
-
var
|
|
12209
|
+
var memberIds = ((_custom$members = custom.members) !== null && _custom$members !== void 0 ? _custom$members : []).map(function (member) {
|
|
12210
|
+
var _member$user_id;
|
|
11205
12211
|
|
|
11206
|
-
|
|
12212
|
+
return typeof member === 'string' ? member : (_member$user_id = member.user_id) !== null && _member$user_id !== void 0 ? _member$user_id : '';
|
|
12213
|
+
});
|
|
12214
|
+
var membersStr = memberIds.sort().join(',');
|
|
12215
|
+
var tempCid = generateChannelTempCid(channelType, memberIds);
|
|
11207
12216
|
|
|
11208
|
-
if (!
|
|
12217
|
+
if (!tempCid) {
|
|
11209
12218
|
throw Error('Please specify atleast one member when creating unique conversation');
|
|
11210
12219
|
} // channel could exist in `activeChannels` list with either one of the following two keys:
|
|
11211
12220
|
// 1. cid - Which gets set on channel only after calling channel.query or channel.watch or channel.create
|
|
@@ -13055,13 +14064,13 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13055
14064
|
key: "getRateLimits",
|
|
13056
14065
|
value: function () {
|
|
13057
14066
|
var _getRateLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(params) {
|
|
13058
|
-
var
|
|
14067
|
+
var _ref8, serverSide, web, android, ios, endpoints;
|
|
13059
14068
|
|
|
13060
14069
|
return _regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
13061
14070
|
while (1) {
|
|
13062
14071
|
switch (_context29.prev = _context29.next) {
|
|
13063
14072
|
case 0:
|
|
13064
|
-
|
|
14073
|
+
_ref8 = params || {}, serverSide = _ref8.serverSide, web = _ref8.web, android = _ref8.android, ios = _ref8.ios, endpoints = _ref8.endpoints;
|
|
13065
14074
|
return _context29.abrupt("return", this.get(this.baseURL + '/rate_limits', {
|
|
13066
14075
|
server_side: serverSide,
|
|
13067
14076
|
web: web,
|
|
@@ -13086,9 +14095,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13086
14095
|
}()
|
|
13087
14096
|
}, {
|
|
13088
14097
|
key: "_addChannelConfig",
|
|
13089
|
-
value: function _addChannelConfig(
|
|
13090
|
-
var cid =
|
|
13091
|
-
config =
|
|
14098
|
+
value: function _addChannelConfig(_ref9) {
|
|
14099
|
+
var cid = _ref9.cid,
|
|
14100
|
+
config = _ref9.config;
|
|
13092
14101
|
|
|
13093
14102
|
if (this._cacheEnabled()) {
|
|
13094
14103
|
this.configs[cid] = config;
|
|
@@ -13112,7 +14121,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13112
14121
|
}, {
|
|
13113
14122
|
key: "channel",
|
|
13114
14123
|
value: function channel(channelType, channelIDOrCustom) {
|
|
13115
|
-
var _custom$
|
|
14124
|
+
var _custom$members2;
|
|
13116
14125
|
|
|
13117
14126
|
var custom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
13118
14127
|
|
|
@@ -13130,7 +14139,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13130
14139
|
} // // support channel("messaging", undefined, {options})
|
|
13131
14140
|
|
|
13132
14141
|
|
|
13133
|
-
if (!channelIDOrCustom && _typeof(custom) === 'object' && (_custom$
|
|
14142
|
+
if (!channelIDOrCustom && _typeof(custom) === 'object' && (_custom$members2 = custom.members) !== null && _custom$members2 !== void 0 && _custom$members2.length) {
|
|
13134
14143
|
return this.getChannelByMembers(channelType, custom);
|
|
13135
14144
|
} // support channel("messaging", null, {options})
|
|
13136
14145
|
// support channel("messaging", undefined, {options})
|
|
@@ -15076,7 +16085,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15076
16085
|
}, {
|
|
15077
16086
|
key: "getUserAgent",
|
|
15078
16087
|
value: function getUserAgent() {
|
|
15079
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.
|
|
16088
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.56.1");
|
|
15080
16089
|
}
|
|
15081
16090
|
}, {
|
|
15082
16091
|
key: "setUserAgent",
|
|
@@ -15116,10 +16125,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15116
16125
|
});
|
|
15117
16126
|
}
|
|
15118
16127
|
|
|
15119
|
-
var
|
|
15120
|
-
axiosRequestConfigParams =
|
|
15121
|
-
axiosRequestConfigHeaders =
|
|
15122
|
-
axiosRequestConfigRest = _objectWithoutProperties(
|
|
16128
|
+
var _ref10 = this.options.axiosRequestConfig || {},
|
|
16129
|
+
axiosRequestConfigParams = _ref10.params,
|
|
16130
|
+
axiosRequestConfigHeaders = _ref10.headers,
|
|
16131
|
+
axiosRequestConfigRest = _objectWithoutProperties(_ref10, _excluded2);
|
|
15123
16132
|
|
|
15124
16133
|
return _objectSpread$1(_objectSpread$1(_objectSpread$1({
|
|
15125
16134
|
params: _objectSpread$1(_objectSpread$1({
|
|
@@ -16462,13 +17471,13 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
16462
17471
|
}, {
|
|
16463
17472
|
key: "deletePushProvider",
|
|
16464
17473
|
value: function () {
|
|
16465
|
-
var _deletePushProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee97(
|
|
17474
|
+
var _deletePushProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee97(_ref11) {
|
|
16466
17475
|
var type, name;
|
|
16467
17476
|
return _regeneratorRuntime.wrap(function _callee97$(_context97) {
|
|
16468
17477
|
while (1) {
|
|
16469
17478
|
switch (_context97.prev = _context97.next) {
|
|
16470
17479
|
case 0:
|
|
16471
|
-
type =
|
|
17480
|
+
type = _ref11.type, name = _ref11.name;
|
|
16472
17481
|
_context97.next = 3;
|
|
16473
17482
|
return this.delete(this.baseURL + "/push_providers/".concat(encodeURIComponent(type), "/").concat(encodeURIComponent(name)));
|
|
16474
17483
|
|
|
@@ -18207,5 +19216,5 @@ var SearchController = /*#__PURE__*/function () {
|
|
|
18207
19216
|
return SearchController;
|
|
18208
19217
|
}();
|
|
18209
19218
|
|
|
18210
|
-
export { Allow, AllowAll, AnyResource, AnyRole, BaseSearchSource, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelSearchSource, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MODERATION_ENTITY_TYPES, MaxPriority, MessageSearchSource, MinPriority, Moderation, Permission, Poll, PollManager, SearchController, Segment, StableWSConnection, StateStore, StreamChat, THREAD_MANAGER_INITIAL_STATE, Thread, ThreadManager, TokenManager, UserFromToken, UserSearchSource, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, extractPollData, extractPollEnrichedData, formatMessage, isOwnUser, isVoteAnswer, logChatPromiseExecution, postInsights };
|
|
19219
|
+
export { Allow, AllowAll, AnyResource, AnyRole, BaseSearchSource, BuiltinPermissions, BuiltinRoles, Campaign, Channel, ChannelManager, ChannelSearchSource, ChannelState, CheckSignature, ClientState, DEFAULT_CHANNEL_MANAGER_OPTIONS, DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS, Deny, DenyAll, DevToken, EVENT_MAP, ErrorFromResponse, InsightMetrics, JWTServerToken, JWTUserToken, MODERATION_ENTITY_TYPES, MaxPriority, MessageSearchSource, MinPriority, Moderation, Permission, Poll, PollManager, SearchController, Segment, StableWSConnection, StateStore, StreamChat, THREAD_MANAGER_INITIAL_STATE, Thread, ThreadManager, TokenManager, UserFromToken, UserSearchSource, VotingVisibility, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, channelManagerEventToHandlerMapping, chatCodes, decodeBase64, encodeBase64, extractPollData, extractPollEnrichedData, formatMessage, isOwnUser, isPatch, isVoteAnswer, logChatPromiseExecution, postInsights };
|
|
18211
19220
|
//# sourceMappingURL=index.es.js.map
|