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/browser.es.js
CHANGED
|
@@ -299,11 +299,11 @@ var Campaign = /*#__PURE__*/function () {
|
|
|
299
299
|
|
|
300
300
|
var https = null;
|
|
301
301
|
|
|
302
|
-
function ownKeys$
|
|
302
|
+
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; }
|
|
303
303
|
|
|
304
|
-
function _objectSpread$
|
|
304
|
+
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; }
|
|
305
305
|
|
|
306
|
-
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(
|
|
306
|
+
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; } } }; }
|
|
307
307
|
|
|
308
308
|
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); }
|
|
309
309
|
|
|
@@ -398,8 +398,8 @@ function normalizeQuerySort(sort) {
|
|
|
398
398
|
|
|
399
399
|
try {
|
|
400
400
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
401
|
-
var
|
|
402
|
-
var entries = Object.entries(
|
|
401
|
+
var _item = _step.value;
|
|
402
|
+
var entries = Object.entries(_item);
|
|
403
403
|
|
|
404
404
|
if (entries.length > 1) {
|
|
405
405
|
console.warn("client._buildSort() - multiple fields in a single sort object detected. Object's field order is not guaranteed");
|
|
@@ -563,7 +563,7 @@ var axiosParamsSerializer = function axiosParamsSerializer(params) {
|
|
|
563
563
|
*/
|
|
564
564
|
|
|
565
565
|
function formatMessage(message) {
|
|
566
|
-
return _objectSpread$
|
|
566
|
+
return _objectSpread$e(_objectSpread$e({}, message), {}, {
|
|
567
567
|
/**
|
|
568
568
|
* @deprecated please use `html`
|
|
569
569
|
*/
|
|
@@ -807,6 +807,28 @@ var throttle = function throttle(fn) {
|
|
|
807
807
|
runningTimeout = setTimeout(timeoutHandler, timeout);
|
|
808
808
|
};
|
|
809
809
|
};
|
|
810
|
+
|
|
811
|
+
var get = function get(obj, path) {
|
|
812
|
+
return path.split('.').reduce(function (acc, key) {
|
|
813
|
+
if (acc && _typeof(acc) === 'object' && key in acc) {
|
|
814
|
+
return acc[key];
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
return undefined;
|
|
818
|
+
}, obj);
|
|
819
|
+
}; // works exactly the same as lodash.uniqBy
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
var uniqBy = function uniqBy(array, iteratee) {
|
|
823
|
+
if (!Array.isArray(array)) return [];
|
|
824
|
+
var seen = new Set();
|
|
825
|
+
return array.filter(function (item) {
|
|
826
|
+
var key = typeof iteratee === 'function' ? iteratee(item) : get(item, iteratee);
|
|
827
|
+
if (seen.has(key)) return false;
|
|
828
|
+
seen.add(key);
|
|
829
|
+
return true;
|
|
830
|
+
});
|
|
831
|
+
};
|
|
810
832
|
function binarySearchByDateEqualOrNearestGreater(array, targetDate) {
|
|
811
833
|
var left = 0;
|
|
812
834
|
var right = array.length - 1;
|
|
@@ -840,7 +862,7 @@ var messagePaginationCreatedAtAround = function messagePaginationCreatedAtAround
|
|
|
840
862
|
returnedPage = _ref4.returnedPage,
|
|
841
863
|
messagePaginationOptions = _ref4.messagePaginationOptions;
|
|
842
864
|
|
|
843
|
-
var newPagination = _objectSpread$
|
|
865
|
+
var newPagination = _objectSpread$e({}, parentSet.pagination);
|
|
844
866
|
|
|
845
867
|
if (!(messagePaginationOptions !== null && messagePaginationOptions !== void 0 && messagePaginationOptions.created_at_around)) return newPagination;
|
|
846
868
|
var hasPrev;
|
|
@@ -905,7 +927,7 @@ var messagePaginationIdAround = function messagePaginationIdAround(_ref6) {
|
|
|
905
927
|
returnedPage = _ref6.returnedPage,
|
|
906
928
|
messagePaginationOptions = _ref6.messagePaginationOptions;
|
|
907
929
|
|
|
908
|
-
var newPagination = _objectSpread$
|
|
930
|
+
var newPagination = _objectSpread$e({}, parentSet.pagination);
|
|
909
931
|
|
|
910
932
|
var _ref7 = messagePaginationOptions || {},
|
|
911
933
|
id_around = _ref7.id_around;
|
|
@@ -963,7 +985,7 @@ var messagePaginationLinear = function messagePaginationLinear(_ref9) {
|
|
|
963
985
|
returnedPage = _ref9.returnedPage,
|
|
964
986
|
messagePaginationOptions = _ref9.messagePaginationOptions;
|
|
965
987
|
|
|
966
|
-
var newPagination = _objectSpread$
|
|
988
|
+
var newPagination = _objectSpread$e({}, parentSet.pagination);
|
|
967
989
|
|
|
968
990
|
var hasPrev;
|
|
969
991
|
var hasNext;
|
|
@@ -1009,6 +1031,294 @@ var messageSetPagination = function messageSetPagination(params) {
|
|
|
1009
1031
|
return messagePaginationLinear(params);
|
|
1010
1032
|
}
|
|
1011
1033
|
};
|
|
1034
|
+
/**
|
|
1035
|
+
* A utility object used to prevent duplicate invocation of channel.watch() to be triggered when
|
|
1036
|
+
* 'notification.message_new' and 'notification.added_to_channel' events arrive at the same time.
|
|
1037
|
+
*/
|
|
1038
|
+
|
|
1039
|
+
var WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL = {};
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
|
|
1043
|
+
* 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.
|
|
1044
|
+
* @param client
|
|
1045
|
+
* @param members
|
|
1046
|
+
* @param options
|
|
1047
|
+
* @param type
|
|
1048
|
+
* @param id
|
|
1049
|
+
* @param channel
|
|
1050
|
+
*/
|
|
1051
|
+
var getAndWatchChannel = /*#__PURE__*/function () {
|
|
1052
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref11) {
|
|
1053
|
+
var channel, client, id, members, options, type, channelToWatch, originalCid, queryPromise;
|
|
1054
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1055
|
+
while (1) {
|
|
1056
|
+
switch (_context.prev = _context.next) {
|
|
1057
|
+
case 0:
|
|
1058
|
+
channel = _ref11.channel, client = _ref11.client, id = _ref11.id, members = _ref11.members, options = _ref11.options, type = _ref11.type;
|
|
1059
|
+
|
|
1060
|
+
if (!(!channel && !type)) {
|
|
1061
|
+
_context.next = 3;
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
throw new Error('Channel or channel type have to be provided to query a channel.');
|
|
1066
|
+
|
|
1067
|
+
case 3:
|
|
1068
|
+
// unfortunately typescript is not able to infer that if (!channel && !type) === false, then channel or type has to be truthy
|
|
1069
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1070
|
+
channelToWatch = channel || client.channel(type, id, {
|
|
1071
|
+
members: members
|
|
1072
|
+
}); // need to keep as with call to channel.watch the id can be changed from undefined to an actual ID generated server-side
|
|
1073
|
+
|
|
1074
|
+
originalCid = channelToWatch.id ? channelToWatch.cid : members && members.length ? generateChannelTempCid(channelToWatch.type, members) : undefined;
|
|
1075
|
+
|
|
1076
|
+
if (originalCid) {
|
|
1077
|
+
_context.next = 7;
|
|
1078
|
+
break;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
throw new Error('Channel ID or channel members array have to be provided to query a channel.');
|
|
1082
|
+
|
|
1083
|
+
case 7:
|
|
1084
|
+
queryPromise = WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid];
|
|
1085
|
+
|
|
1086
|
+
if (!queryPromise) {
|
|
1087
|
+
_context.next = 13;
|
|
1088
|
+
break;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
_context.next = 11;
|
|
1092
|
+
return queryPromise;
|
|
1093
|
+
|
|
1094
|
+
case 11:
|
|
1095
|
+
_context.next = 20;
|
|
1096
|
+
break;
|
|
1097
|
+
|
|
1098
|
+
case 13:
|
|
1099
|
+
_context.prev = 13;
|
|
1100
|
+
WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = channelToWatch.watch(options);
|
|
1101
|
+
_context.next = 17;
|
|
1102
|
+
return WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid];
|
|
1103
|
+
|
|
1104
|
+
case 17:
|
|
1105
|
+
_context.prev = 17;
|
|
1106
|
+
delete WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid];
|
|
1107
|
+
return _context.finish(17);
|
|
1108
|
+
|
|
1109
|
+
case 20:
|
|
1110
|
+
return _context.abrupt("return", channelToWatch);
|
|
1111
|
+
|
|
1112
|
+
case 21:
|
|
1113
|
+
case "end":
|
|
1114
|
+
return _context.stop();
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
}, _callee, null, [[13,, 17, 20]]);
|
|
1118
|
+
}));
|
|
1119
|
+
|
|
1120
|
+
return function getAndWatchChannel(_x) {
|
|
1121
|
+
return _ref12.apply(this, arguments);
|
|
1122
|
+
};
|
|
1123
|
+
}();
|
|
1124
|
+
/**
|
|
1125
|
+
* Generates a temporary channel.cid for channels created without ID, as they need to be referenced
|
|
1126
|
+
* by an identifier until the back-end generates the final ID. The cid is generated by its member IDs
|
|
1127
|
+
* which are sorted and can be recreated the same every time given the same arguments.
|
|
1128
|
+
* @param channelType
|
|
1129
|
+
* @param members
|
|
1130
|
+
*/
|
|
1131
|
+
|
|
1132
|
+
var generateChannelTempCid = function generateChannelTempCid(channelType, members) {
|
|
1133
|
+
if (!members) return;
|
|
1134
|
+
|
|
1135
|
+
var membersStr = _toConsumableArray(members).sort().join(',');
|
|
1136
|
+
|
|
1137
|
+
if (!membersStr) return;
|
|
1138
|
+
return "".concat(channelType, ":!members-").concat(membersStr);
|
|
1139
|
+
};
|
|
1140
|
+
/**
|
|
1141
|
+
* Checks if a channel is pinned or not. Will return true only if channel.state.membership.pinned_at exists.
|
|
1142
|
+
* @param channel
|
|
1143
|
+
*/
|
|
1144
|
+
|
|
1145
|
+
var isChannelPinned = function isChannelPinned(channel) {
|
|
1146
|
+
if (!channel) return false;
|
|
1147
|
+
var member = channel.state.membership;
|
|
1148
|
+
return !!(member !== null && member !== void 0 && member.pinned_at);
|
|
1149
|
+
};
|
|
1150
|
+
/**
|
|
1151
|
+
* Checks if a channel is archived or not. Will return true only if channel.state.membership.archived_at exists.
|
|
1152
|
+
* @param channel
|
|
1153
|
+
*/
|
|
1154
|
+
|
|
1155
|
+
var isChannelArchived = function isChannelArchived(channel) {
|
|
1156
|
+
if (!channel) return false;
|
|
1157
|
+
var member = channel.state.membership;
|
|
1158
|
+
return !!(member !== null && member !== void 0 && member.archived_at);
|
|
1159
|
+
};
|
|
1160
|
+
/**
|
|
1161
|
+
* A utility that tells us whether we should consider archived channels or not based
|
|
1162
|
+
* on filters. Will return true only if filters.archived exists and is a boolean value.
|
|
1163
|
+
* @param filters
|
|
1164
|
+
*/
|
|
1165
|
+
|
|
1166
|
+
var shouldConsiderArchivedChannels = function shouldConsiderArchivedChannels(filters) {
|
|
1167
|
+
if (!filters) return false;
|
|
1168
|
+
return typeof filters.archived === 'boolean';
|
|
1169
|
+
};
|
|
1170
|
+
/**
|
|
1171
|
+
* Extracts the value of the sort parameter at a given index, for a targeted key. Can
|
|
1172
|
+
* handle both array and object versions of sort. Will return null if the index/key
|
|
1173
|
+
* combination does not exist.
|
|
1174
|
+
* @param atIndex - the index at which we'll examine the sort value, if it's an array one
|
|
1175
|
+
* @param sort - the sort value - both array and object notations are accepted
|
|
1176
|
+
* @param targetKey - the target key which needs to exist for the sort at a certain index
|
|
1177
|
+
*/
|
|
1178
|
+
|
|
1179
|
+
var extractSortValue = function extractSortValue(_ref13) {
|
|
1180
|
+
var _option$targetKey, _option;
|
|
1181
|
+
|
|
1182
|
+
var atIndex = _ref13.atIndex,
|
|
1183
|
+
sort = _ref13.sort,
|
|
1184
|
+
targetKey = _ref13.targetKey;
|
|
1185
|
+
if (!sort) return null;
|
|
1186
|
+
var option = null;
|
|
1187
|
+
|
|
1188
|
+
if (Array.isArray(sort)) {
|
|
1189
|
+
var _sort$atIndex;
|
|
1190
|
+
|
|
1191
|
+
option = (_sort$atIndex = sort[atIndex]) !== null && _sort$atIndex !== void 0 ? _sort$atIndex : null;
|
|
1192
|
+
} else {
|
|
1193
|
+
var index = 0;
|
|
1194
|
+
|
|
1195
|
+
for (var _key3 in sort) {
|
|
1196
|
+
if (index !== atIndex) {
|
|
1197
|
+
index++;
|
|
1198
|
+
continue;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
if (_key3 !== targetKey) {
|
|
1202
|
+
return null;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
option = sort;
|
|
1206
|
+
break;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
return (_option$targetKey = (_option = option) === null || _option === void 0 ? void 0 : _option[targetKey]) !== null && _option$targetKey !== void 0 ? _option$targetKey : null;
|
|
1211
|
+
};
|
|
1212
|
+
/**
|
|
1213
|
+
* Returns true only if `{ pinned_at: -1 }` or `{ pinned_at: 1 }` option is first within the `sort` array.
|
|
1214
|
+
*/
|
|
1215
|
+
|
|
1216
|
+
var shouldConsiderPinnedChannels = function shouldConsiderPinnedChannels(sort) {
|
|
1217
|
+
var value = findPinnedAtSortOrder({
|
|
1218
|
+
sort: sort
|
|
1219
|
+
});
|
|
1220
|
+
if (typeof value !== 'number') return false;
|
|
1221
|
+
return Math.abs(value) === 1;
|
|
1222
|
+
};
|
|
1223
|
+
/**
|
|
1224
|
+
* Checks whether the sort value of type object contains a pinned_at value or if
|
|
1225
|
+
* an array sort value type has the first value be an object containing pinned_at.
|
|
1226
|
+
* @param sort
|
|
1227
|
+
*/
|
|
1228
|
+
|
|
1229
|
+
var findPinnedAtSortOrder = function findPinnedAtSortOrder(_ref14) {
|
|
1230
|
+
var sort = _ref14.sort;
|
|
1231
|
+
return extractSortValue({
|
|
1232
|
+
atIndex: 0,
|
|
1233
|
+
sort: sort,
|
|
1234
|
+
targetKey: 'pinned_at'
|
|
1235
|
+
});
|
|
1236
|
+
};
|
|
1237
|
+
/**
|
|
1238
|
+
* Finds the index of the last consecutively pinned channel, starting from the start of the
|
|
1239
|
+
* array. Will not consider any pinned channels after the contiguous subsequence at the
|
|
1240
|
+
* start of the array.
|
|
1241
|
+
* @param channels
|
|
1242
|
+
*/
|
|
1243
|
+
|
|
1244
|
+
var findLastPinnedChannelIndex = function findLastPinnedChannelIndex(_ref15) {
|
|
1245
|
+
var channels = _ref15.channels;
|
|
1246
|
+
var lastPinnedChannelIndex = null;
|
|
1247
|
+
|
|
1248
|
+
var _iterator2 = _createForOfIteratorHelper$5(channels),
|
|
1249
|
+
_step2;
|
|
1250
|
+
|
|
1251
|
+
try {
|
|
1252
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1253
|
+
var channel = _step2.value;
|
|
1254
|
+
if (!isChannelPinned(channel)) break;
|
|
1255
|
+
|
|
1256
|
+
if (typeof lastPinnedChannelIndex === 'number') {
|
|
1257
|
+
lastPinnedChannelIndex++;
|
|
1258
|
+
} else {
|
|
1259
|
+
lastPinnedChannelIndex = 0;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
} catch (err) {
|
|
1263
|
+
_iterator2.e(err);
|
|
1264
|
+
} finally {
|
|
1265
|
+
_iterator2.f();
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
return lastPinnedChannelIndex;
|
|
1269
|
+
};
|
|
1270
|
+
/**
|
|
1271
|
+
* A utility used to move a channel towards the beginning of a list of channels (promote it to a higher position). It
|
|
1272
|
+
* considers pinned channels in the process if needed and makes sure to only update the list reference if the list
|
|
1273
|
+
* should actually change. It will try to move the channel as high as it can within the list.
|
|
1274
|
+
* @param channels - the list of channels we want to modify
|
|
1275
|
+
* @param channelToMove - the channel we want to promote
|
|
1276
|
+
* @param channelToMoveIndexWithinChannels - optionally, the index of the channel we want to move if we know it (will skip a manual check)
|
|
1277
|
+
* @param sort - the sort value used to check for pinned channels
|
|
1278
|
+
*/
|
|
1279
|
+
|
|
1280
|
+
var promoteChannel = function promoteChannel(_ref16) {
|
|
1281
|
+
var channels = _ref16.channels,
|
|
1282
|
+
channelToMove = _ref16.channelToMove,
|
|
1283
|
+
channelToMoveIndexWithinChannels = _ref16.channelToMoveIndexWithinChannels,
|
|
1284
|
+
sort = _ref16.sort;
|
|
1285
|
+
// get index of channel to move up
|
|
1286
|
+
var targetChannelIndex = channelToMoveIndexWithinChannels !== null && channelToMoveIndexWithinChannels !== void 0 ? channelToMoveIndexWithinChannels : channels.findIndex(function (channel) {
|
|
1287
|
+
return channel.cid === channelToMove.cid;
|
|
1288
|
+
});
|
|
1289
|
+
var targetChannelExistsWithinList = targetChannelIndex >= 0;
|
|
1290
|
+
var targetChannelAlreadyAtTheTop = targetChannelIndex === 0; // pinned channels should not move within the list based on recent activity, channels which
|
|
1291
|
+
// receive messages and are not pinned should move upwards but only under the last pinned channel
|
|
1292
|
+
// in the list
|
|
1293
|
+
|
|
1294
|
+
var considerPinnedChannels = shouldConsiderPinnedChannels(sort);
|
|
1295
|
+
var isTargetChannelPinned = isChannelPinned(channelToMove);
|
|
1296
|
+
|
|
1297
|
+
if (targetChannelAlreadyAtTheTop || considerPinnedChannels && isTargetChannelPinned) {
|
|
1298
|
+
return channels;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
var newChannels = _toConsumableArray(channels); // target channel index is known, remove it from the list
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
if (targetChannelExistsWithinList) {
|
|
1305
|
+
newChannels.splice(targetChannelIndex, 1);
|
|
1306
|
+
} // as position of pinned channels has to stay unchanged, we need to
|
|
1307
|
+
// find last pinned channel in the list to move the target channel after
|
|
1308
|
+
|
|
1309
|
+
|
|
1310
|
+
var lastPinnedChannelIndex = null;
|
|
1311
|
+
|
|
1312
|
+
if (considerPinnedChannels) {
|
|
1313
|
+
lastPinnedChannelIndex = findLastPinnedChannelIndex({
|
|
1314
|
+
channels: newChannels
|
|
1315
|
+
});
|
|
1316
|
+
} // re-insert it at the new place (to specific index if pinned channels are considered)
|
|
1317
|
+
|
|
1318
|
+
|
|
1319
|
+
newChannels.splice(typeof lastPinnedChannelIndex === 'number' ? lastPinnedChannelIndex + 1 : 0, 0, channelToMove);
|
|
1320
|
+
return newChannels;
|
|
1321
|
+
};
|
|
1012
1322
|
|
|
1013
1323
|
var DEFAULT_QUERY_CHANNELS_MESSAGE_LIST_PAGE_SIZE = 25;
|
|
1014
1324
|
var DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE = 100;
|
|
@@ -1017,9 +1327,9 @@ var DEFAULT_MESSAGE_SET_PAGINATION = {
|
|
|
1017
1327
|
hasPrev: false
|
|
1018
1328
|
};
|
|
1019
1329
|
|
|
1020
|
-
function ownKeys$
|
|
1330
|
+
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; }
|
|
1021
1331
|
|
|
1022
|
-
function _objectSpread$
|
|
1332
|
+
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; }
|
|
1023
1333
|
|
|
1024
1334
|
/**
|
|
1025
1335
|
* ChannelState - A container class for the channel state.
|
|
@@ -1100,7 +1410,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1100
1410
|
var m = messages[i];
|
|
1101
1411
|
|
|
1102
1412
|
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
1103
|
-
messages[i] = _objectSpread$
|
|
1413
|
+
messages[i] = _objectSpread$d(_objectSpread$d({}, m), {}, {
|
|
1104
1414
|
user: user
|
|
1105
1415
|
});
|
|
1106
1416
|
}
|
|
@@ -1155,7 +1465,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1155
1465
|
user: m.user
|
|
1156
1466
|
};
|
|
1157
1467
|
} else {
|
|
1158
|
-
messages[i] = _objectSpread$
|
|
1468
|
+
messages[i] = _objectSpread$d(_objectSpread$d({}, m), {}, {
|
|
1159
1469
|
type: 'deleted',
|
|
1160
1470
|
deleted_at: user.deleted_at ? new Date(user.deleted_at) : null
|
|
1161
1471
|
});
|
|
@@ -1473,7 +1783,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1473
1783
|
var parseMessage = function parseMessage(m) {
|
|
1474
1784
|
var _m$pinned_at, _m$updated_at;
|
|
1475
1785
|
|
|
1476
|
-
return _objectSpread$
|
|
1786
|
+
return _objectSpread$d(_objectSpread$d({}, m), {}, {
|
|
1477
1787
|
created_at: m.created_at.toISOString(),
|
|
1478
1788
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toISOString(),
|
|
1479
1789
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toISOString()
|
|
@@ -1483,8 +1793,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
1483
1793
|
var update = function update(messages) {
|
|
1484
1794
|
var updatedMessages = messages.reduce(function (acc, msg) {
|
|
1485
1795
|
if (msg.quoted_message_id === message.id) {
|
|
1486
|
-
acc.push(_objectSpread$
|
|
1487
|
-
quoted_message: remove ? _objectSpread$
|
|
1796
|
+
acc.push(_objectSpread$d(_objectSpread$d({}, parseMessage(msg)), {}, {
|
|
1797
|
+
quoted_message: remove ? _objectSpread$d(_objectSpread$d({}, message), {}, {
|
|
1488
1798
|
attachments: []
|
|
1489
1799
|
}) : message
|
|
1490
1800
|
}));
|
|
@@ -1973,9 +2283,9 @@ function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o
|
|
|
1973
2283
|
|
|
1974
2284
|
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; }
|
|
1975
2285
|
|
|
1976
|
-
function ownKeys$
|
|
2286
|
+
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; }
|
|
1977
2287
|
|
|
1978
|
-
function _objectSpread$
|
|
2288
|
+
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; }
|
|
1979
2289
|
/**
|
|
1980
2290
|
* Channel - The Channel class manages it's own state.
|
|
1981
2291
|
*/
|
|
@@ -2050,7 +2360,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2050
2360
|
while (1) {
|
|
2051
2361
|
switch (_context.prev = _context.next) {
|
|
2052
2362
|
case 0:
|
|
2053
|
-
defaultOptions = _objectSpread$
|
|
2363
|
+
defaultOptions = _objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
2054
2364
|
watch: false,
|
|
2055
2365
|
state: false,
|
|
2056
2366
|
presence: false
|
|
@@ -2122,7 +2432,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2122
2432
|
|
|
2123
2433
|
this.data = data; // this._data is used for the requests...
|
|
2124
2434
|
|
|
2125
|
-
this._data = _objectSpread$
|
|
2435
|
+
this._data = _objectSpread$c({}, data);
|
|
2126
2436
|
this.cid = "".concat(type, ":").concat(id);
|
|
2127
2437
|
this.listeners = {}; // perhaps the state variable should be private
|
|
2128
2438
|
|
|
@@ -2184,7 +2494,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2184
2494
|
switch (_context2.prev = _context2.next) {
|
|
2185
2495
|
case 0:
|
|
2186
2496
|
_context2.next = 2;
|
|
2187
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
2497
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$c({
|
|
2188
2498
|
message: message
|
|
2189
2499
|
}, options));
|
|
2190
2500
|
|
|
@@ -2300,7 +2610,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2300
2610
|
|
|
2301
2611
|
case 3:
|
|
2302
2612
|
// Return a list of channels
|
|
2303
|
-
payload = _objectSpread$
|
|
2613
|
+
payload = _objectSpread$c(_objectSpread$c({
|
|
2304
2614
|
filter_conditions: {
|
|
2305
2615
|
cid: this.cid
|
|
2306
2616
|
}
|
|
@@ -2397,7 +2707,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2397
2707
|
|
|
2398
2708
|
_context5.next = 6;
|
|
2399
2709
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
2400
|
-
payload: _objectSpread$
|
|
2710
|
+
payload: _objectSpread$c({
|
|
2401
2711
|
type: type,
|
|
2402
2712
|
id: id,
|
|
2403
2713
|
members: members,
|
|
@@ -2503,7 +2813,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2503
2813
|
|
|
2504
2814
|
case 4:
|
|
2505
2815
|
_context7.next = 6;
|
|
2506
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$
|
|
2816
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(messageID), "/reaction"), _objectSpread$c({
|
|
2507
2817
|
reaction: reaction
|
|
2508
2818
|
}, options));
|
|
2509
2819
|
|
|
@@ -2584,7 +2894,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2584
2894
|
delete channelData[key];
|
|
2585
2895
|
});
|
|
2586
2896
|
_context8.next = 7;
|
|
2587
|
-
return this._update(_objectSpread$
|
|
2897
|
+
return this._update(_objectSpread$c({
|
|
2588
2898
|
message: updateMessage,
|
|
2589
2899
|
data: channelData
|
|
2590
2900
|
}, options));
|
|
@@ -2756,7 +3066,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2756
3066
|
case 0:
|
|
2757
3067
|
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
2758
3068
|
_context12.next = 3;
|
|
2759
|
-
return this.getClient().delete(this._channelURL(), _objectSpread$
|
|
3069
|
+
return this.getClient().delete(this._channelURL(), _objectSpread$c({}, options));
|
|
2760
3070
|
|
|
2761
3071
|
case 3:
|
|
2762
3072
|
return _context12.abrupt("return", _context12.sent);
|
|
@@ -2832,7 +3142,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2832
3142
|
case 0:
|
|
2833
3143
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
2834
3144
|
_context14.next = 3;
|
|
2835
|
-
return this._update(_objectSpread$
|
|
3145
|
+
return this._update(_objectSpread$c({
|
|
2836
3146
|
accept_invite: true
|
|
2837
3147
|
}, options));
|
|
2838
3148
|
|
|
@@ -2873,7 +3183,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2873
3183
|
case 0:
|
|
2874
3184
|
options = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
|
|
2875
3185
|
_context15.next = 3;
|
|
2876
|
-
return this._update(_objectSpread$
|
|
3186
|
+
return this._update(_objectSpread$c({
|
|
2877
3187
|
reject_invite: true
|
|
2878
3188
|
}, options));
|
|
2879
3189
|
|
|
@@ -2915,7 +3225,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2915
3225
|
case 0:
|
|
2916
3226
|
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
2917
3227
|
_context16.next = 3;
|
|
2918
|
-
return this._update(_objectSpread$
|
|
3228
|
+
return this._update(_objectSpread$c({
|
|
2919
3229
|
add_members: members,
|
|
2920
3230
|
message: message
|
|
2921
3231
|
}, options));
|
|
@@ -2958,7 +3268,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2958
3268
|
case 0:
|
|
2959
3269
|
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
2960
3270
|
_context17.next = 3;
|
|
2961
|
-
return this._update(_objectSpread$
|
|
3271
|
+
return this._update(_objectSpread$c({
|
|
2962
3272
|
add_moderators: members,
|
|
2963
3273
|
message: message
|
|
2964
3274
|
}, options));
|
|
@@ -3001,7 +3311,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3001
3311
|
case 0:
|
|
3002
3312
|
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
3003
3313
|
_context18.next = 3;
|
|
3004
|
-
return this._update(_objectSpread$
|
|
3314
|
+
return this._update(_objectSpread$c({
|
|
3005
3315
|
assign_roles: roles,
|
|
3006
3316
|
message: message
|
|
3007
3317
|
}, options));
|
|
@@ -3044,7 +3354,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3044
3354
|
case 0:
|
|
3045
3355
|
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
3046
3356
|
_context19.next = 3;
|
|
3047
|
-
return this._update(_objectSpread$
|
|
3357
|
+
return this._update(_objectSpread$c({
|
|
3048
3358
|
invites: members,
|
|
3049
3359
|
message: message
|
|
3050
3360
|
}, options));
|
|
@@ -3087,7 +3397,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3087
3397
|
case 0:
|
|
3088
3398
|
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
3089
3399
|
_context20.next = 3;
|
|
3090
|
-
return this._update(_objectSpread$
|
|
3400
|
+
return this._update(_objectSpread$c({
|
|
3091
3401
|
remove_members: members,
|
|
3092
3402
|
message: message
|
|
3093
3403
|
}, options));
|
|
@@ -3130,7 +3440,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3130
3440
|
case 0:
|
|
3131
3441
|
options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
|
|
3132
3442
|
_context21.next = 3;
|
|
3133
|
-
return this._update(_objectSpread$
|
|
3443
|
+
return this._update(_objectSpread$c({
|
|
3134
3444
|
demote_moderators: members,
|
|
3135
3445
|
message: message
|
|
3136
3446
|
}, options));
|
|
@@ -3215,7 +3525,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3215
3525
|
case 0:
|
|
3216
3526
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
3217
3527
|
_context23.next = 3;
|
|
3218
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
3528
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$c({
|
|
3219
3529
|
channel_cid: this.cid
|
|
3220
3530
|
}, opts));
|
|
3221
3531
|
|
|
@@ -3257,7 +3567,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3257
3567
|
case 0:
|
|
3258
3568
|
opts = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
|
|
3259
3569
|
_context24.next = 3;
|
|
3260
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
3570
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$c({
|
|
3261
3571
|
channel_cid: this.cid
|
|
3262
3572
|
}, opts));
|
|
3263
3573
|
|
|
@@ -3594,7 +3904,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3594
3904
|
|
|
3595
3905
|
this.lastTypingEvent = new Date();
|
|
3596
3906
|
_context29.next = 10;
|
|
3597
|
-
return this.sendEvent(_objectSpread$
|
|
3907
|
+
return this.sendEvent(_objectSpread$c({
|
|
3598
3908
|
type: 'typing.start',
|
|
3599
3909
|
parent_id: parent_id
|
|
3600
3910
|
}, options || {}));
|
|
@@ -3634,7 +3944,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3634
3944
|
case 0:
|
|
3635
3945
|
options = _args30.length > 2 && _args30[2] !== undefined ? _args30[2] : {};
|
|
3636
3946
|
_context30.next = 3;
|
|
3637
|
-
return this.sendEvent(_objectSpread$
|
|
3947
|
+
return this.sendEvent(_objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
3638
3948
|
type: 'ai_indicator.update',
|
|
3639
3949
|
message_id: messageId,
|
|
3640
3950
|
ai_state: state
|
|
@@ -3743,7 +4053,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3743
4053
|
this.lastTypingEvent = null;
|
|
3744
4054
|
this.isTyping = false;
|
|
3745
4055
|
_context33.next = 6;
|
|
3746
|
-
return this.sendEvent(_objectSpread$
|
|
4056
|
+
return this.sendEvent(_objectSpread$c({
|
|
3747
4057
|
type: 'typing.stop',
|
|
3748
4058
|
parent_id: parent_id
|
|
3749
4059
|
}, options || {}));
|
|
@@ -3830,7 +4140,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3830
4140
|
|
|
3831
4141
|
case 4:
|
|
3832
4142
|
_context34.next = 6;
|
|
3833
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
4143
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$c({}, data));
|
|
3834
4144
|
|
|
3835
4145
|
case 6:
|
|
3836
4146
|
return _context34.abrupt("return", _context34.sent);
|
|
@@ -3877,7 +4187,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3877
4187
|
|
|
3878
4188
|
case 3:
|
|
3879
4189
|
_context35.next = 5;
|
|
3880
|
-
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$
|
|
4190
|
+
return this.getClient().post(this._channelURL() + '/unread', _objectSpread$c({}, data));
|
|
3881
4191
|
|
|
3882
4192
|
case 5:
|
|
3883
4193
|
return _context35.abrupt("return", _context35.sent);
|
|
@@ -3945,7 +4255,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3945
4255
|
defaultOptions.watch = false;
|
|
3946
4256
|
}
|
|
3947
4257
|
|
|
3948
|
-
combined = _objectSpread$
|
|
4258
|
+
combined = _objectSpread$c(_objectSpread$c({}, defaultOptions), options);
|
|
3949
4259
|
_context36.next = 7;
|
|
3950
4260
|
return this.query(combined, 'latest');
|
|
3951
4261
|
|
|
@@ -4039,7 +4349,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4039
4349
|
case 0:
|
|
4040
4350
|
normalizedSort = sort ? normalizeQuerySort(sort) : undefined;
|
|
4041
4351
|
_context38.next = 3;
|
|
4042
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$
|
|
4352
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(parent_id), "/replies"), _objectSpread$c({
|
|
4043
4353
|
sort: normalizedSort
|
|
4044
4354
|
}, options));
|
|
4045
4355
|
|
|
@@ -4089,7 +4399,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4089
4399
|
sort = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : [];
|
|
4090
4400
|
_context39.next = 3;
|
|
4091
4401
|
return this.getClient().get(this._channelURL() + '/pinned_messages', {
|
|
4092
|
-
payload: _objectSpread$
|
|
4402
|
+
payload: _objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
4093
4403
|
sort: normalizeQuerySort(sort)
|
|
4094
4404
|
})
|
|
4095
4405
|
});
|
|
@@ -4123,7 +4433,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4123
4433
|
}, {
|
|
4124
4434
|
key: "getReactions",
|
|
4125
4435
|
value: function getReactions(message_id, options) {
|
|
4126
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$
|
|
4436
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(encodeURIComponent(message_id), "/reactions"), _objectSpread$c({}, options));
|
|
4127
4437
|
}
|
|
4128
4438
|
/**
|
|
4129
4439
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -4247,7 +4557,6 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4247
4557
|
var messageSetToAddToIfDoesNotExist,
|
|
4248
4558
|
queryURL,
|
|
4249
4559
|
state,
|
|
4250
|
-
membersStr,
|
|
4251
4560
|
tempChannelCid,
|
|
4252
4561
|
_this$_initializeStat,
|
|
4253
4562
|
messageSet,
|
|
@@ -4270,7 +4579,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4270
4579
|
}
|
|
4271
4580
|
|
|
4272
4581
|
_context40.next = 7;
|
|
4273
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
4582
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$c({
|
|
4274
4583
|
data: this._data,
|
|
4275
4584
|
state: true
|
|
4276
4585
|
}, options));
|
|
@@ -4283,14 +4592,13 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4283
4592
|
this.id = state.channel.id;
|
|
4284
4593
|
this.cid = state.channel.cid; // set the channel as active...
|
|
4285
4594
|
|
|
4286
|
-
|
|
4595
|
+
tempChannelCid = generateChannelTempCid(this.type, state.members.map(function (member) {
|
|
4287
4596
|
var _member$user;
|
|
4288
4597
|
|
|
4289
|
-
return member.user_id || ((_member$user = member.user) === null || _member$user === void 0 ? void 0 : _member$user.id);
|
|
4290
|
-
})
|
|
4291
|
-
tempChannelCid = "".concat(this.type, ":!members-").concat(membersStr);
|
|
4598
|
+
return member.user_id || ((_member$user = member.user) === null || _member$user === void 0 ? void 0 : _member$user.id) || '';
|
|
4599
|
+
}));
|
|
4292
4600
|
|
|
4293
|
-
if (tempChannelCid in this.getClient().activeChannels) {
|
|
4601
|
+
if (tempChannelCid && tempChannelCid in this.getClient().activeChannels) {
|
|
4294
4602
|
// This gets set in `client.channel()` function, when channel is created
|
|
4295
4603
|
// using members, not id.
|
|
4296
4604
|
delete this.getClient().activeChannels[tempChannelCid];
|
|
@@ -4305,7 +4613,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4305
4613
|
|
|
4306
4614
|
|
|
4307
4615
|
_this$_initializeStat = this._initializeState(state, messageSetToAddToIfDoesNotExist), messageSet = _this$_initializeStat.messageSet;
|
|
4308
|
-
messageSet.pagination = _objectSpread$
|
|
4616
|
+
messageSet.pagination = _objectSpread$c(_objectSpread$c({}, messageSet.pagination), messageSetPagination({
|
|
4309
4617
|
parentSet: messageSet,
|
|
4310
4618
|
messagePaginationOptions: options === null || options === void 0 ? void 0 : options.messages,
|
|
4311
4619
|
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,
|
|
@@ -4367,7 +4675,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4367
4675
|
this._checkInitialized();
|
|
4368
4676
|
|
|
4369
4677
|
_context41.next = 3;
|
|
4370
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
4678
|
+
return this.getClient().banUser(targetUserID, _objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
4371
4679
|
type: this.type,
|
|
4372
4680
|
id: this.id
|
|
4373
4681
|
}));
|
|
@@ -4539,7 +4847,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4539
4847
|
this._checkInitialized();
|
|
4540
4848
|
|
|
4541
4849
|
_context45.next = 3;
|
|
4542
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
4850
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$c(_objectSpread$c({}, options), {}, {
|
|
4543
4851
|
type: this.type,
|
|
4544
4852
|
id: this.id
|
|
4545
4853
|
}));
|
|
@@ -4944,7 +5252,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4944
5252
|
case 'member.added':
|
|
4945
5253
|
case 'member.updated':
|
|
4946
5254
|
if ((_event$member = event.member) !== null && _event$member !== void 0 && _event$member.user) {
|
|
4947
|
-
channelState.members = _objectSpread$
|
|
5255
|
+
channelState.members = _objectSpread$c(_objectSpread$c({}, channelState.members), {}, _defineProperty({}, event.member.user.id, event.member));
|
|
4948
5256
|
}
|
|
4949
5257
|
|
|
4950
5258
|
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) {
|
|
@@ -4955,7 +5263,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
4955
5263
|
|
|
4956
5264
|
case 'member.removed':
|
|
4957
5265
|
if ((_event$user9 = event.user) !== null && _event$user9 !== void 0 && _event$user9.id) {
|
|
4958
|
-
var newMembers = _objectSpread$
|
|
5266
|
+
var newMembers = _objectSpread$c({}, channelState.members);
|
|
4959
5267
|
|
|
4960
5268
|
delete newMembers[event.user.id];
|
|
4961
5269
|
channelState.members = newMembers; // TODO?: unset membership
|
|
@@ -5000,7 +5308,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
5000
5308
|
});
|
|
5001
5309
|
}
|
|
5002
5310
|
|
|
5003
|
-
channel.data = _objectSpread$
|
|
5311
|
+
channel.data = _objectSpread$c(_objectSpread$c({}, event.channel), {}, {
|
|
5004
5312
|
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,
|
|
5005
5313
|
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
|
|
5006
5314
|
});
|
|
@@ -5031,7 +5339,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
5031
5339
|
break;
|
|
5032
5340
|
|
|
5033
5341
|
case 'channel.hidden':
|
|
5034
|
-
channel.data = _objectSpread$
|
|
5342
|
+
channel.data = _objectSpread$c(_objectSpread$c({}, channel.data), {}, {
|
|
5035
5343
|
hidden: true
|
|
5036
5344
|
});
|
|
5037
5345
|
|
|
@@ -5042,26 +5350,26 @@ var Channel = /*#__PURE__*/function () {
|
|
|
5042
5350
|
break;
|
|
5043
5351
|
|
|
5044
5352
|
case 'channel.visible':
|
|
5045
|
-
channel.data = _objectSpread$
|
|
5353
|
+
channel.data = _objectSpread$c(_objectSpread$c({}, channel.data), {}, {
|
|
5046
5354
|
hidden: false
|
|
5047
5355
|
});
|
|
5048
5356
|
break;
|
|
5049
5357
|
|
|
5050
5358
|
case 'user.banned':
|
|
5051
5359
|
if (!((_event$user11 = event.user) !== null && _event$user11 !== void 0 && _event$user11.id)) break;
|
|
5052
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
5360
|
+
channelState.members[event.user.id] = _objectSpread$c(_objectSpread$c({}, channelState.members[event.user.id] || {}), {}, {
|
|
5053
5361
|
shadow_banned: !!event.shadow,
|
|
5054
5362
|
banned: !event.shadow,
|
|
5055
|
-
user: _objectSpread$
|
|
5363
|
+
user: _objectSpread$c(_objectSpread$c({}, ((_channelState$members2 = channelState.members[event.user.id]) === null || _channelState$members2 === void 0 ? void 0 : _channelState$members2.user) || {}), event.user)
|
|
5056
5364
|
});
|
|
5057
5365
|
break;
|
|
5058
5366
|
|
|
5059
5367
|
case 'user.unbanned':
|
|
5060
5368
|
if (!((_event$user12 = event.user) !== null && _event$user12 !== void 0 && _event$user12.id)) break;
|
|
5061
|
-
channelState.members[event.user.id] = _objectSpread$
|
|
5369
|
+
channelState.members[event.user.id] = _objectSpread$c(_objectSpread$c({}, channelState.members[event.user.id] || {}), {}, {
|
|
5062
5370
|
shadow_banned: false,
|
|
5063
5371
|
banned: false,
|
|
5064
|
-
user: _objectSpread$
|
|
5372
|
+
user: _objectSpread$c(_objectSpread$c({}, ((_channelState$members3 = channelState.members[event.user.id]) === null || _channelState$members3 === void 0 ? void 0 : _channelState$members3.user) || {}), event.user)
|
|
5065
5373
|
});
|
|
5066
5374
|
break;
|
|
5067
5375
|
} // any event can send over the online count
|
|
@@ -5235,7 +5543,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
5235
5543
|
if (overrideCurrentState) {
|
|
5236
5544
|
this.state.members = newMembersById;
|
|
5237
5545
|
} else if (!overrideCurrentState && members.length) {
|
|
5238
|
-
this.state.members = _objectSpread$
|
|
5546
|
+
this.state.members = _objectSpread$c(_objectSpread$c({}, this.state.members), newMembersById);
|
|
5239
5547
|
}
|
|
5240
5548
|
}
|
|
5241
5549
|
}, {
|
|
@@ -5334,9 +5642,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
5334
5642
|
return ClientState;
|
|
5335
5643
|
}();
|
|
5336
5644
|
|
|
5337
|
-
function ownKeys$
|
|
5645
|
+
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; }
|
|
5338
5646
|
|
|
5339
|
-
function _objectSpread$
|
|
5647
|
+
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; }
|
|
5340
5648
|
var InsightMetrics = function InsightMetrics() {
|
|
5341
5649
|
_classCallCheck(this, InsightMetrics);
|
|
5342
5650
|
|
|
@@ -5415,7 +5723,7 @@ var postInsights = /*#__PURE__*/function () {
|
|
|
5415
5723
|
};
|
|
5416
5724
|
}();
|
|
5417
5725
|
function buildWsFatalInsight(connection, event) {
|
|
5418
|
-
return _objectSpread$
|
|
5726
|
+
return _objectSpread$b(_objectSpread$b({}, event), buildWsBaseInsight(connection));
|
|
5419
5727
|
}
|
|
5420
5728
|
|
|
5421
5729
|
function buildWsBaseInsight(connection) {
|
|
@@ -5448,9 +5756,9 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
5448
5756
|
return buildWsBaseInsight(connection);
|
|
5449
5757
|
}
|
|
5450
5758
|
|
|
5451
|
-
function ownKeys$
|
|
5759
|
+
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; }
|
|
5452
5760
|
|
|
5453
|
-
function _objectSpread$
|
|
5761
|
+
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; }
|
|
5454
5762
|
|
|
5455
5763
|
// Type guards to check WebSocket error type
|
|
5456
5764
|
var isCloseEvent = function isCloseEvent(res) {
|
|
@@ -5814,7 +6122,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
5814
6122
|
value: function _log(msg) {
|
|
5815
6123
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5816
6124
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5817
|
-
this.client.logger(level, 'connection:' + msg, _objectSpread$
|
|
6125
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$a({
|
|
5818
6126
|
tags: ['connection']
|
|
5819
6127
|
}, extra));
|
|
5820
6128
|
}
|
|
@@ -6409,9 +6717,9 @@ var jwt = null;
|
|
|
6409
6717
|
|
|
6410
6718
|
var crypto$1 = null;
|
|
6411
6719
|
|
|
6412
|
-
function ownKeys$
|
|
6720
|
+
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; }
|
|
6413
6721
|
|
|
6414
|
-
function _objectSpread$
|
|
6722
|
+
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; }
|
|
6415
6723
|
|
|
6416
6724
|
/**
|
|
6417
6725
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -6432,7 +6740,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
6432
6740
|
throw new TypeError('userId should be a string');
|
|
6433
6741
|
}
|
|
6434
6742
|
|
|
6435
|
-
var payload = _objectSpread$
|
|
6743
|
+
var payload = _objectSpread$9({
|
|
6436
6744
|
user_id: userId
|
|
6437
6745
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
6438
6746
|
|
|
@@ -6838,9 +7146,9 @@ function isErrorResponse(res) {
|
|
|
6838
7146
|
return !res.status || res.status < 200 || 300 <= res.status;
|
|
6839
7147
|
}
|
|
6840
7148
|
|
|
6841
|
-
function ownKeys$
|
|
7149
|
+
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; }
|
|
6842
7150
|
|
|
6843
|
-
function _objectSpread$
|
|
7151
|
+
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; }
|
|
6844
7152
|
var ConnectionState;
|
|
6845
7153
|
|
|
6846
7154
|
(function (ConnectionState) {
|
|
@@ -6903,7 +7211,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
6903
7211
|
_context.next = 4;
|
|
6904
7212
|
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
6905
7213
|
undefined, {
|
|
6906
|
-
config: _objectSpread$
|
|
7214
|
+
config: _objectSpread$8(_objectSpread$8({}, config), {}, {
|
|
6907
7215
|
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
6908
7216
|
}),
|
|
6909
7217
|
params: params
|
|
@@ -7181,7 +7489,7 @@ var WSConnectionFallback = /*#__PURE__*/function () {
|
|
|
7181
7489
|
value: function _log(msg) {
|
|
7182
7490
|
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7183
7491
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
7184
|
-
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$
|
|
7492
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$8({
|
|
7185
7493
|
tags: ['connection_fallback', 'connection']
|
|
7186
7494
|
}, extra));
|
|
7187
7495
|
}
|
|
@@ -7558,14 +7866,13 @@ var VotingVisibility;
|
|
|
7558
7866
|
VotingVisibility["public"] = "public";
|
|
7559
7867
|
})(VotingVisibility || (VotingVisibility = {}));
|
|
7560
7868
|
|
|
7561
|
-
function ownKeys$
|
|
7869
|
+
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; }
|
|
7562
7870
|
|
|
7563
|
-
function _objectSpread$
|
|
7871
|
+
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; }
|
|
7564
7872
|
|
|
7565
|
-
function isPatch(value) {
|
|
7873
|
+
var isPatch = function isPatch(value) {
|
|
7566
7874
|
return typeof value === 'function';
|
|
7567
|
-
}
|
|
7568
|
-
|
|
7875
|
+
};
|
|
7569
7876
|
var StateStore = function StateStore(value) {
|
|
7570
7877
|
var _this = this;
|
|
7571
7878
|
|
|
@@ -7590,7 +7897,7 @@ var StateStore = function StateStore(value) {
|
|
|
7590
7897
|
|
|
7591
7898
|
_defineProperty(this, "partialNext", function (partial) {
|
|
7592
7899
|
return _this.next(function (current) {
|
|
7593
|
-
return _objectSpread$
|
|
7900
|
+
return _objectSpread$7(_objectSpread$7({}, current), partial);
|
|
7594
7901
|
});
|
|
7595
7902
|
});
|
|
7596
7903
|
|
|
@@ -7642,9 +7949,9 @@ _defineProperty(StateStore, "logCount", 5);
|
|
|
7642
7949
|
|
|
7643
7950
|
var _excluded$3 = ["limit", "sort"];
|
|
7644
7951
|
|
|
7645
|
-
function ownKeys$
|
|
7952
|
+
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; }
|
|
7646
7953
|
|
|
7647
|
-
function _objectSpread$
|
|
7954
|
+
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; }
|
|
7648
7955
|
var DEFAULT_PAGE_LIMIT = 50;
|
|
7649
7956
|
var DEFAULT_SORT = [{
|
|
7650
7957
|
created_at: -1
|
|
@@ -7929,14 +8236,14 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7929
8236
|
if (userId === ((_event$user2 = event.user) === null || _event$user2 === void 0 ? void 0 : _event$user2.id)) {
|
|
7930
8237
|
// The user who just sent a message to the thread has no unread messages
|
|
7931
8238
|
// in that thread
|
|
7932
|
-
nextUserRead = _objectSpread$
|
|
8239
|
+
nextUserRead = _objectSpread$6(_objectSpread$6({}, nextUserRead), {}, {
|
|
7933
8240
|
lastReadAt: event.created_at ? new Date(event.created_at) : new Date(),
|
|
7934
8241
|
user: event.user,
|
|
7935
8242
|
unreadMessageCount: 0
|
|
7936
8243
|
});
|
|
7937
8244
|
} else if (active && userId === _this.client.userID) ; else {
|
|
7938
8245
|
// Increment unread count for all users except the author of the new message
|
|
7939
|
-
nextUserRead = _objectSpread$
|
|
8246
|
+
nextUserRead = _objectSpread$6(_objectSpread$6({}, nextUserRead), {}, {
|
|
7940
8247
|
unreadMessageCount: userRead.unreadMessageCount + 1
|
|
7941
8248
|
});
|
|
7942
8249
|
}
|
|
@@ -7960,8 +8267,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
7960
8267
|
var user = event.user;
|
|
7961
8268
|
|
|
7962
8269
|
_this.state.next(function (current) {
|
|
7963
|
-
return _objectSpread$
|
|
7964
|
-
read: _objectSpread$
|
|
8270
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8271
|
+
read: _objectSpread$6(_objectSpread$6({}, current.read), {}, _defineProperty({}, userId, {
|
|
7965
8272
|
lastReadAt: new Date(createdAt),
|
|
7966
8273
|
user: user,
|
|
7967
8274
|
lastReadMessageId: event.last_read_message_id,
|
|
@@ -8074,7 +8381,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8074
8381
|
}
|
|
8075
8382
|
|
|
8076
8383
|
_this.state.next(function (current) {
|
|
8077
|
-
return _objectSpread$
|
|
8384
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8078
8385
|
replies: addToMessageList(current.replies, formattedMessage, timestampChanged)
|
|
8079
8386
|
});
|
|
8080
8387
|
});
|
|
@@ -8091,7 +8398,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8091
8398
|
var _message$reply_count;
|
|
8092
8399
|
|
|
8093
8400
|
var formattedMessage = formatMessage(message);
|
|
8094
|
-
return _objectSpread$
|
|
8401
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8095
8402
|
deletedAt: formattedMessage.deleted_at,
|
|
8096
8403
|
parentMessage: formattedMessage,
|
|
8097
8404
|
replyCount: (_message$reply_count = message.reply_count) !== null && _message$reply_count !== void 0 ? _message$reply_count : current.replyCount
|
|
@@ -8164,7 +8471,7 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8164
8471
|
sort = _ref10$sort === void 0 ? DEFAULT_SORT : _ref10$sort,
|
|
8165
8472
|
otherOptions = _objectWithoutProperties(_ref10, _excluded$3);
|
|
8166
8473
|
|
|
8167
|
-
return _this.channel.getReplies(_this.id, _objectSpread$
|
|
8474
|
+
return _this.channel.getReplies(_this.id, _objectSpread$6({
|
|
8168
8475
|
limit: limit
|
|
8169
8476
|
}, otherOptions), sort);
|
|
8170
8477
|
});
|
|
@@ -8208,12 +8515,12 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8208
8515
|
limit = Math.abs(count);
|
|
8209
8516
|
|
|
8210
8517
|
_this.state.partialNext({
|
|
8211
|
-
pagination: _objectSpread$
|
|
8518
|
+
pagination: _objectSpread$6(_objectSpread$6({}, pagination), {}, _defineProperty({}, loadingKey, true))
|
|
8212
8519
|
});
|
|
8213
8520
|
|
|
8214
8521
|
_context3.prev = 7;
|
|
8215
8522
|
_context3.next = 10;
|
|
8216
|
-
return _this.queryReplies(_objectSpread$
|
|
8523
|
+
return _this.queryReplies(_objectSpread$6(_objectSpread$6({}, queryOptions), {}, {
|
|
8217
8524
|
limit: limit
|
|
8218
8525
|
}));
|
|
8219
8526
|
|
|
@@ -8235,9 +8542,9 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8235
8542
|
(_nextReplies = nextReplies)[insertionMethodKey].apply(_nextReplies, _toConsumableArray(replies));
|
|
8236
8543
|
}
|
|
8237
8544
|
|
|
8238
|
-
return _objectSpread$
|
|
8545
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8239
8546
|
replies: nextReplies,
|
|
8240
|
-
pagination: _objectSpread$
|
|
8547
|
+
pagination: _objectSpread$6(_objectSpread$6({}, current.pagination), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, cursorKey, data.messages.length < limit ? null : maybeNextCursor), _defineProperty(_objectSpread4, loadingKey, false), _objectSpread4))
|
|
8241
8548
|
});
|
|
8242
8549
|
});
|
|
8243
8550
|
|
|
@@ -8251,8 +8558,8 @@ var Thread = /*#__PURE__*/function () {
|
|
|
8251
8558
|
_this.client.logger('error', _context3.t0.message);
|
|
8252
8559
|
|
|
8253
8560
|
_this.state.next(function (current) {
|
|
8254
|
-
return _objectSpread$
|
|
8255
|
-
pagination: _objectSpread$
|
|
8561
|
+
return _objectSpread$6(_objectSpread$6({}, current), {}, {
|
|
8562
|
+
pagination: _objectSpread$6(_objectSpread$6({}, current.pagination), {}, _defineProperty({}, loadingKey, false))
|
|
8256
8563
|
});
|
|
8257
8564
|
});
|
|
8258
8565
|
|
|
@@ -8365,9 +8672,9 @@ var ownUnreadCountSelector = function ownUnreadCountSelector(currentUserId) {
|
|
|
8365
8672
|
};
|
|
8366
8673
|
};
|
|
8367
8674
|
|
|
8368
|
-
function ownKeys$
|
|
8675
|
+
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; }
|
|
8369
8676
|
|
|
8370
|
-
function _objectSpread$
|
|
8677
|
+
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; }
|
|
8371
8678
|
var MODERATION_ENTITY_TYPES = {
|
|
8372
8679
|
user: 'stream:user',
|
|
8373
8680
|
message: 'stream:chat:v1:message'
|
|
@@ -8484,7 +8791,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8484
8791
|
case 0:
|
|
8485
8792
|
options = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : {};
|
|
8486
8793
|
_context3.next = 3;
|
|
8487
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$
|
|
8794
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/flag', _objectSpread$5({
|
|
8488
8795
|
entity_type: entityType,
|
|
8489
8796
|
entity_id: entityId,
|
|
8490
8797
|
entity_creator_id: entityCreatorID,
|
|
@@ -8529,7 +8836,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8529
8836
|
case 0:
|
|
8530
8837
|
options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
8531
8838
|
_context4.next = 3;
|
|
8532
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$
|
|
8839
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/mute', _objectSpread$5({
|
|
8533
8840
|
target_ids: [targetID]
|
|
8534
8841
|
}, options));
|
|
8535
8842
|
|
|
@@ -8567,7 +8874,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8567
8874
|
switch (_context5.prev = _context5.next) {
|
|
8568
8875
|
case 0:
|
|
8569
8876
|
_context5.next = 2;
|
|
8570
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$
|
|
8877
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/unmute', _objectSpread$5({
|
|
8571
8878
|
target_ids: [targetID]
|
|
8572
8879
|
}, options));
|
|
8573
8880
|
|
|
@@ -8609,7 +8916,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8609
8916
|
case 0:
|
|
8610
8917
|
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
8611
8918
|
_context6.next = 3;
|
|
8612
|
-
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$
|
|
8919
|
+
return this.client.get(this.client.baseURL + "/api/v2/moderation/user_report", _objectSpread$5({
|
|
8613
8920
|
user_id: userID
|
|
8614
8921
|
}, options));
|
|
8615
8922
|
|
|
@@ -8653,7 +8960,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8653
8960
|
sort = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : [];
|
|
8654
8961
|
options = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : {};
|
|
8655
8962
|
_context7.next = 5;
|
|
8656
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$
|
|
8963
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/review_queue', _objectSpread$5({
|
|
8657
8964
|
filter: filterConditions,
|
|
8658
8965
|
sort: normalizeQuerySort(sort)
|
|
8659
8966
|
}, options));
|
|
@@ -8788,7 +9095,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8788
9095
|
case 0:
|
|
8789
9096
|
options = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : {};
|
|
8790
9097
|
_context11.next = 3;
|
|
8791
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/configs', _objectSpread$
|
|
9098
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/configs', _objectSpread$5({
|
|
8792
9099
|
filter: filterConditions,
|
|
8793
9100
|
sort: sort
|
|
8794
9101
|
}, options));
|
|
@@ -8822,7 +9129,7 @@ var Moderation = /*#__PURE__*/function () {
|
|
|
8822
9129
|
case 0:
|
|
8823
9130
|
options = _args12.length > 2 && _args12[2] !== undefined ? _args12[2] : {};
|
|
8824
9131
|
_context12.next = 3;
|
|
8825
|
-
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$
|
|
9132
|
+
return this.client.post(this.client.baseURL + '/api/v2/moderation/submit_action', _objectSpread$5({
|
|
8826
9133
|
action_type: actionType,
|
|
8827
9134
|
item_id: itemID
|
|
8828
9135
|
}, options));
|
|
@@ -8986,9 +9293,9 @@ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o
|
|
|
8986
9293
|
|
|
8987
9294
|
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; }
|
|
8988
9295
|
|
|
8989
|
-
function ownKeys$
|
|
9296
|
+
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; }
|
|
8990
9297
|
|
|
8991
|
-
function _objectSpread$
|
|
9298
|
+
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; }
|
|
8992
9299
|
var DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION = 1000;
|
|
8993
9300
|
var MAX_QUERY_THREADS_LIMIT = 25;
|
|
8994
9301
|
var THREAD_MANAGER_INITIAL_STATE = {
|
|
@@ -9169,7 +9476,7 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9169
9476
|
var unsubscribeConnectionDropped = _this.client.on('connection.changed', function (event) {
|
|
9170
9477
|
if (event.online === false) {
|
|
9171
9478
|
_this.state.next(function (current) {
|
|
9172
|
-
return current.lastConnectionDropAt ? current : _objectSpread$
|
|
9479
|
+
return current.lastConnectionDropAt ? current : _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9173
9480
|
lastConnectionDropAt: new Date()
|
|
9174
9481
|
});
|
|
9175
9482
|
});
|
|
@@ -9256,8 +9563,8 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9256
9563
|
_context.prev = 7;
|
|
9257
9564
|
|
|
9258
9565
|
_this.state.next(function (current) {
|
|
9259
|
-
return _objectSpread$
|
|
9260
|
-
pagination: _objectSpread$
|
|
9566
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9567
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9261
9568
|
isLoading: true
|
|
9262
9569
|
})
|
|
9263
9570
|
});
|
|
@@ -9299,11 +9606,11 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9299
9606
|
_this.state.next(function (current) {
|
|
9300
9607
|
var _response$next;
|
|
9301
9608
|
|
|
9302
|
-
return _objectSpread$
|
|
9609
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9303
9610
|
threads: nextThreads,
|
|
9304
9611
|
unseenThreadIds: [],
|
|
9305
9612
|
isThreadOrderStale: false,
|
|
9306
|
-
pagination: _objectSpread$
|
|
9613
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9307
9614
|
isLoading: false,
|
|
9308
9615
|
nextCursor: (_response$next = response.next) !== null && _response$next !== void 0 ? _response$next : null
|
|
9309
9616
|
}),
|
|
@@ -9321,8 +9628,8 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9321
9628
|
_this.client.logger('error', _context.t0.message);
|
|
9322
9629
|
|
|
9323
9630
|
_this.state.next(function (current) {
|
|
9324
|
-
return _objectSpread$
|
|
9325
|
-
pagination: _objectSpread$
|
|
9631
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9632
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9326
9633
|
isLoading: false
|
|
9327
9634
|
})
|
|
9328
9635
|
});
|
|
@@ -9338,7 +9645,7 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9338
9645
|
|
|
9339
9646
|
_defineProperty(this, "queryThreads", function () {
|
|
9340
9647
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9341
|
-
return _this.client.queryThreads(_objectSpread$
|
|
9648
|
+
return _this.client.queryThreads(_objectSpread$4({
|
|
9342
9649
|
limit: 25,
|
|
9343
9650
|
participant_limit: 10,
|
|
9344
9651
|
reply_limit: 10,
|
|
@@ -9371,13 +9678,13 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9371
9678
|
_context2.prev = 4;
|
|
9372
9679
|
|
|
9373
9680
|
_this.state.partialNext({
|
|
9374
|
-
pagination: _objectSpread$
|
|
9681
|
+
pagination: _objectSpread$4(_objectSpread$4({}, pagination), {}, {
|
|
9375
9682
|
isLoadingNext: true
|
|
9376
9683
|
})
|
|
9377
9684
|
});
|
|
9378
9685
|
|
|
9379
9686
|
_context2.next = 8;
|
|
9380
|
-
return _this.queryThreads(_objectSpread$
|
|
9687
|
+
return _this.queryThreads(_objectSpread$4(_objectSpread$4({}, options), {}, {
|
|
9381
9688
|
next: pagination.nextCursor
|
|
9382
9689
|
}));
|
|
9383
9690
|
|
|
@@ -9387,9 +9694,9 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9387
9694
|
_this.state.next(function (current) {
|
|
9388
9695
|
var _response$next2;
|
|
9389
9696
|
|
|
9390
|
-
return _objectSpread$
|
|
9697
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9391
9698
|
threads: response.threads.length ? current.threads.concat(response.threads) : current.threads,
|
|
9392
|
-
pagination: _objectSpread$
|
|
9699
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9393
9700
|
nextCursor: (_response$next2 = response.next) !== null && _response$next2 !== void 0 ? _response$next2 : null,
|
|
9394
9701
|
isLoadingNext: false
|
|
9395
9702
|
})
|
|
@@ -9406,8 +9713,8 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9406
9713
|
_this.client.logger('error', _context2.t0.message);
|
|
9407
9714
|
|
|
9408
9715
|
_this.state.next(function (current) {
|
|
9409
|
-
return _objectSpread$
|
|
9410
|
-
pagination: _objectSpread$
|
|
9716
|
+
return _objectSpread$4(_objectSpread$4({}, current), {}, {
|
|
9717
|
+
pagination: _objectSpread$4(_objectSpread$4({}, current.pagination), {}, {
|
|
9411
9718
|
isLoadingNext: false
|
|
9412
9719
|
})
|
|
9413
9720
|
});
|
|
@@ -9455,9 +9762,9 @@ var ThreadManager = /*#__PURE__*/function () {
|
|
|
9455
9762
|
var _excluded$2 = ["own_votes", "id"],
|
|
9456
9763
|
_excluded2$1 = ["id"];
|
|
9457
9764
|
|
|
9458
|
-
function ownKeys$
|
|
9765
|
+
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; }
|
|
9459
9766
|
|
|
9460
|
-
function _objectSpread$
|
|
9767
|
+
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; }
|
|
9461
9768
|
|
|
9462
9769
|
var isPollUpdatedEvent = function isPollUpdatedEvent(e) {
|
|
9463
9770
|
return e.type === 'poll.updated';
|
|
@@ -9523,7 +9830,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9523
9830
|
ownAnswer = _ref2.ownAnswer,
|
|
9524
9831
|
ownVotes = _ref2.ownVotes;
|
|
9525
9832
|
|
|
9526
|
-
return _objectSpread$
|
|
9833
|
+
return _objectSpread$3(_objectSpread$3({}, pollResponseForState), {}, {
|
|
9527
9834
|
lastActivityAt: new Date(),
|
|
9528
9835
|
maxVotedOptionIds: getMaxVotedOptionIds(pollResponseForState.vote_counts_by_option),
|
|
9529
9836
|
ownAnswer: ownAnswer,
|
|
@@ -9545,7 +9852,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9545
9852
|
pollData = _objectWithoutProperties(_extractPollData, _excluded2$1); // @ts-ignore
|
|
9546
9853
|
|
|
9547
9854
|
|
|
9548
|
-
_this.state.partialNext(_objectSpread$
|
|
9855
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, pollData), {}, {
|
|
9549
9856
|
lastActivityAt: new Date(event.created_at)
|
|
9550
9857
|
}));
|
|
9551
9858
|
});
|
|
@@ -9592,7 +9899,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9592
9899
|
|
|
9593
9900
|
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9594
9901
|
|
|
9595
|
-
_this.state.partialNext(_objectSpread$
|
|
9902
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, pollEnrichData), {}, {
|
|
9596
9903
|
latest_answers: latestAnswers,
|
|
9597
9904
|
lastActivityAt: new Date(event.created_at),
|
|
9598
9905
|
ownAnswer: ownAnswer,
|
|
@@ -9657,7 +9964,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9657
9964
|
|
|
9658
9965
|
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9659
9966
|
|
|
9660
|
-
_this.state.partialNext(_objectSpread$
|
|
9967
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, pollEnrichData), {}, {
|
|
9661
9968
|
latest_answers: latestAnswers,
|
|
9662
9969
|
lastActivityAt: new Date(event.created_at),
|
|
9663
9970
|
ownAnswer: ownAnswer,
|
|
@@ -9678,7 +9985,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9678
9985
|
|
|
9679
9986
|
var ownAnswer = currentState.ownAnswer;
|
|
9680
9987
|
|
|
9681
|
-
var ownVotesByOptionId = _objectSpread$
|
|
9988
|
+
var ownVotesByOptionId = _objectSpread$3({}, currentState.ownVotesByOptionId);
|
|
9682
9989
|
|
|
9683
9990
|
var maxVotedOptionIds = currentState.maxVotedOptionIds;
|
|
9684
9991
|
|
|
@@ -9700,7 +10007,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9700
10007
|
|
|
9701
10008
|
var pollEnrichData = extractPollEnrichedData(event.poll); // @ts-ignore
|
|
9702
10009
|
|
|
9703
|
-
_this.state.partialNext(_objectSpread$
|
|
10010
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, pollEnrichData), {}, {
|
|
9704
10011
|
latest_answers: latestAnswers,
|
|
9705
10012
|
lastActivityAt: new Date(event.created_at),
|
|
9706
10013
|
ownAnswer: ownAnswer,
|
|
@@ -9725,7 +10032,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9725
10032
|
poll = _yield$_this$client$g.poll;
|
|
9726
10033
|
|
|
9727
10034
|
// @ts-ignore
|
|
9728
|
-
_this.state.partialNext(_objectSpread$
|
|
10035
|
+
_this.state.partialNext(_objectSpread$3(_objectSpread$3({}, poll), {}, {
|
|
9729
10036
|
lastActivityAt: new Date()
|
|
9730
10037
|
}));
|
|
9731
10038
|
|
|
@@ -9751,7 +10058,7 @@ var Poll = /*#__PURE__*/function () {
|
|
|
9751
10058
|
switch (_context2.prev = _context2.next) {
|
|
9752
10059
|
case 0:
|
|
9753
10060
|
_context2.next = 2;
|
|
9754
|
-
return _this.client.updatePoll(_objectSpread$
|
|
10061
|
+
return _this.client.updatePoll(_objectSpread$3(_objectSpread$3({}, data), {}, {
|
|
9755
10062
|
id: _this.id
|
|
9756
10063
|
}));
|
|
9757
10064
|
|
|
@@ -10462,6 +10769,690 @@ var PollManager = /*#__PURE__*/function () {
|
|
|
10462
10769
|
return PollManager;
|
|
10463
10770
|
}();
|
|
10464
10771
|
|
|
10772
|
+
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; }
|
|
10773
|
+
|
|
10774
|
+
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; }
|
|
10775
|
+
var channelManagerEventToHandlerMapping = {
|
|
10776
|
+
'channel.deleted': 'channelDeletedHandler',
|
|
10777
|
+
'channel.hidden': 'channelHiddenHandler',
|
|
10778
|
+
'channel.truncated': 'channelTruncatedHandler',
|
|
10779
|
+
'channel.visible': 'channelVisibleHandler',
|
|
10780
|
+
'message.new': 'newMessageHandler',
|
|
10781
|
+
'member.updated': 'memberUpdatedHandler',
|
|
10782
|
+
'notification.added_to_channel': 'notificationAddedToChannelHandler',
|
|
10783
|
+
'notification.message_new': 'notificationNewMessageHandler',
|
|
10784
|
+
'notification.removed_from_channel': 'notificationRemovedFromChannelHandler'
|
|
10785
|
+
};
|
|
10786
|
+
var DEFAULT_CHANNEL_MANAGER_OPTIONS = {
|
|
10787
|
+
abortInFlightQuery: false,
|
|
10788
|
+
allowNotLoadedChannelPromotionForEvent: {
|
|
10789
|
+
'channel.visible': true,
|
|
10790
|
+
'message.new': true,
|
|
10791
|
+
'notification.added_to_channel': true,
|
|
10792
|
+
'notification.message_new': true
|
|
10793
|
+
},
|
|
10794
|
+
lockChannelOrder: false
|
|
10795
|
+
};
|
|
10796
|
+
var DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS = {
|
|
10797
|
+
limit: 10,
|
|
10798
|
+
offset: 0
|
|
10799
|
+
};
|
|
10800
|
+
/**
|
|
10801
|
+
* A class that manages a list of channels and changes it based on configuration and WS events. The
|
|
10802
|
+
* list of channels is reactive as well as the pagination and it can be subscribed to for state updates.
|
|
10803
|
+
*
|
|
10804
|
+
* @internal
|
|
10805
|
+
*/
|
|
10806
|
+
|
|
10807
|
+
var ChannelManager = function ChannelManager(_ref) {
|
|
10808
|
+
var _this = this;
|
|
10809
|
+
|
|
10810
|
+
var client = _ref.client,
|
|
10811
|
+
_ref$eventHandlerOver = _ref.eventHandlerOverrides,
|
|
10812
|
+
_eventHandlerOverrides = _ref$eventHandlerOver === void 0 ? {} : _ref$eventHandlerOver,
|
|
10813
|
+
_ref$options = _ref.options,
|
|
10814
|
+
_options = _ref$options === void 0 ? {} : _ref$options;
|
|
10815
|
+
|
|
10816
|
+
_classCallCheck(this, ChannelManager);
|
|
10817
|
+
|
|
10818
|
+
_defineProperty(this, "state", void 0);
|
|
10819
|
+
|
|
10820
|
+
_defineProperty(this, "client", void 0);
|
|
10821
|
+
|
|
10822
|
+
_defineProperty(this, "unsubscribeFunctions", new Set());
|
|
10823
|
+
|
|
10824
|
+
_defineProperty(this, "eventHandlers", new Map());
|
|
10825
|
+
|
|
10826
|
+
_defineProperty(this, "eventHandlerOverrides", new Map());
|
|
10827
|
+
|
|
10828
|
+
_defineProperty(this, "options", {});
|
|
10829
|
+
|
|
10830
|
+
_defineProperty(this, "stateOptions", {});
|
|
10831
|
+
|
|
10832
|
+
_defineProperty(this, "setChannels", function (valueOrFactory) {
|
|
10833
|
+
_this.state.next(function (current) {
|
|
10834
|
+
var currentChannels = current.channels;
|
|
10835
|
+
var newChannels = isPatch(valueOrFactory) ? valueOrFactory(currentChannels) : valueOrFactory; // If the references between the two values are the same, just return the
|
|
10836
|
+
// current state; otherwise trigger a state change.
|
|
10837
|
+
|
|
10838
|
+
if (currentChannels === newChannels) {
|
|
10839
|
+
return current;
|
|
10840
|
+
}
|
|
10841
|
+
|
|
10842
|
+
return _objectSpread$2(_objectSpread$2({}, current), {}, {
|
|
10843
|
+
channels: newChannels
|
|
10844
|
+
});
|
|
10845
|
+
});
|
|
10846
|
+
});
|
|
10847
|
+
|
|
10848
|
+
_defineProperty(this, "setEventHandlerOverrides", function () {
|
|
10849
|
+
var eventHandlerOverrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10850
|
+
var truthyEventHandlerOverrides = Object.entries(eventHandlerOverrides).reduce(function (acc, _ref2) {
|
|
10851
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
10852
|
+
key = _ref3[0],
|
|
10853
|
+
value = _ref3[1];
|
|
10854
|
+
|
|
10855
|
+
if (value) {
|
|
10856
|
+
acc[key] = value;
|
|
10857
|
+
}
|
|
10858
|
+
|
|
10859
|
+
return acc;
|
|
10860
|
+
}, {});
|
|
10861
|
+
_this.eventHandlerOverrides = new Map(Object.entries(truthyEventHandlerOverrides));
|
|
10862
|
+
});
|
|
10863
|
+
|
|
10864
|
+
_defineProperty(this, "setOptions", function () {
|
|
10865
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10866
|
+
_this.options = _objectSpread$2(_objectSpread$2({}, DEFAULT_CHANNEL_MANAGER_OPTIONS), options);
|
|
10867
|
+
});
|
|
10868
|
+
|
|
10869
|
+
_defineProperty(this, "queryChannels", /*#__PURE__*/function () {
|
|
10870
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(filters) {
|
|
10871
|
+
var sort,
|
|
10872
|
+
options,
|
|
10873
|
+
stateOptions,
|
|
10874
|
+
_DEFAULT_CHANNEL_MANA,
|
|
10875
|
+
offset,
|
|
10876
|
+
limit,
|
|
10877
|
+
_this$state$getLatest,
|
|
10878
|
+
isLoading,
|
|
10879
|
+
_channels$length,
|
|
10880
|
+
_channels$length2,
|
|
10881
|
+
channels,
|
|
10882
|
+
newOffset,
|
|
10883
|
+
newOptions,
|
|
10884
|
+
_this$state$getLatest2,
|
|
10885
|
+
pagination,
|
|
10886
|
+
_args = arguments;
|
|
10887
|
+
|
|
10888
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
10889
|
+
while (1) {
|
|
10890
|
+
switch (_context.prev = _context.next) {
|
|
10891
|
+
case 0:
|
|
10892
|
+
sort = _args.length > 1 && _args[1] !== undefined ? _args[1] : [];
|
|
10893
|
+
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
10894
|
+
stateOptions = _args.length > 3 && _args[3] !== undefined ? _args[3] : {};
|
|
10895
|
+
_DEFAULT_CHANNEL_MANA = _objectSpread$2(_objectSpread$2({}, DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS), options), offset = _DEFAULT_CHANNEL_MANA.offset, limit = _DEFAULT_CHANNEL_MANA.limit;
|
|
10896
|
+
_this$state$getLatest = _this.state.getLatestValue(), isLoading = _this$state$getLatest.pagination.isLoading;
|
|
10897
|
+
|
|
10898
|
+
if (!(isLoading && !_this.options.abortInFlightQuery)) {
|
|
10899
|
+
_context.next = 7;
|
|
10900
|
+
break;
|
|
10901
|
+
}
|
|
10902
|
+
|
|
10903
|
+
return _context.abrupt("return");
|
|
10904
|
+
|
|
10905
|
+
case 7:
|
|
10906
|
+
_context.prev = 7;
|
|
10907
|
+
_this.stateOptions = stateOptions;
|
|
10908
|
+
|
|
10909
|
+
_this.state.next(function (currentState) {
|
|
10910
|
+
return _objectSpread$2(_objectSpread$2({}, currentState), {}, {
|
|
10911
|
+
pagination: _objectSpread$2(_objectSpread$2({}, currentState.pagination), {}, {
|
|
10912
|
+
isLoading: true,
|
|
10913
|
+
isLoadingNext: false,
|
|
10914
|
+
filters: filters,
|
|
10915
|
+
sort: sort,
|
|
10916
|
+
options: options
|
|
10917
|
+
})
|
|
10918
|
+
});
|
|
10919
|
+
});
|
|
10920
|
+
|
|
10921
|
+
_context.next = 12;
|
|
10922
|
+
return _this.client.queryChannels(filters, sort, options, stateOptions);
|
|
10923
|
+
|
|
10924
|
+
case 12:
|
|
10925
|
+
channels = _context.sent;
|
|
10926
|
+
newOffset = offset + ((_channels$length = channels === null || channels === void 0 ? void 0 : channels.length) !== null && _channels$length !== void 0 ? _channels$length : 0);
|
|
10927
|
+
newOptions = _objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
10928
|
+
offset: newOffset
|
|
10929
|
+
});
|
|
10930
|
+
_this$state$getLatest2 = _this.state.getLatestValue(), pagination = _this$state$getLatest2.pagination;
|
|
10931
|
+
|
|
10932
|
+
_this.state.partialNext({
|
|
10933
|
+
channels: channels,
|
|
10934
|
+
pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
|
|
10935
|
+
hasNext: ((_channels$length2 = channels === null || channels === void 0 ? void 0 : channels.length) !== null && _channels$length2 !== void 0 ? _channels$length2 : 0) >= limit,
|
|
10936
|
+
isLoading: false,
|
|
10937
|
+
options: newOptions
|
|
10938
|
+
}),
|
|
10939
|
+
initialized: true
|
|
10940
|
+
});
|
|
10941
|
+
|
|
10942
|
+
_context.next = 24;
|
|
10943
|
+
break;
|
|
10944
|
+
|
|
10945
|
+
case 19:
|
|
10946
|
+
_context.prev = 19;
|
|
10947
|
+
_context.t0 = _context["catch"](7);
|
|
10948
|
+
|
|
10949
|
+
_this.client.logger('error', _context.t0.message);
|
|
10950
|
+
|
|
10951
|
+
_this.state.next(function (currentState) {
|
|
10952
|
+
return _objectSpread$2(_objectSpread$2({}, currentState), {}, {
|
|
10953
|
+
pagination: _objectSpread$2(_objectSpread$2({}, currentState.pagination), {}, {
|
|
10954
|
+
isLoading: false
|
|
10955
|
+
})
|
|
10956
|
+
});
|
|
10957
|
+
});
|
|
10958
|
+
|
|
10959
|
+
throw _context.t0;
|
|
10960
|
+
|
|
10961
|
+
case 24:
|
|
10962
|
+
case "end":
|
|
10963
|
+
return _context.stop();
|
|
10964
|
+
}
|
|
10965
|
+
}
|
|
10966
|
+
}, _callee, null, [[7, 19]]);
|
|
10967
|
+
}));
|
|
10968
|
+
|
|
10969
|
+
return function (_x) {
|
|
10970
|
+
return _ref4.apply(this, arguments);
|
|
10971
|
+
};
|
|
10972
|
+
}());
|
|
10973
|
+
|
|
10974
|
+
_defineProperty(this, "loadNext", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
10975
|
+
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;
|
|
10976
|
+
|
|
10977
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
10978
|
+
while (1) {
|
|
10979
|
+
switch (_context2.prev = _context2.next) {
|
|
10980
|
+
case 0:
|
|
10981
|
+
_this$state$getLatest3 = _this.state.getLatestValue(), pagination = _this$state$getLatest3.pagination, initialized = _this$state$getLatest3.initialized;
|
|
10982
|
+
filters = pagination.filters, sort = pagination.sort, options = pagination.options, isLoadingNext = pagination.isLoadingNext, hasNext = pagination.hasNext;
|
|
10983
|
+
|
|
10984
|
+
if (!(!initialized || isLoadingNext || !hasNext)) {
|
|
10985
|
+
_context2.next = 4;
|
|
10986
|
+
break;
|
|
10987
|
+
}
|
|
10988
|
+
|
|
10989
|
+
return _context2.abrupt("return");
|
|
10990
|
+
|
|
10991
|
+
case 4:
|
|
10992
|
+
_context2.prev = 4;
|
|
10993
|
+
_DEFAULT_CHANNEL_MANA2 = _objectSpread$2(_objectSpread$2({}, DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS), options), offset = _DEFAULT_CHANNEL_MANA2.offset, limit = _DEFAULT_CHANNEL_MANA2.limit;
|
|
10994
|
+
|
|
10995
|
+
_this.state.partialNext({
|
|
10996
|
+
pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
|
|
10997
|
+
isLoading: false,
|
|
10998
|
+
isLoadingNext: true
|
|
10999
|
+
})
|
|
11000
|
+
});
|
|
11001
|
+
|
|
11002
|
+
_context2.next = 9;
|
|
11003
|
+
return _this.client.queryChannels(filters, sort, options, _this.stateOptions);
|
|
11004
|
+
|
|
11005
|
+
case 9:
|
|
11006
|
+
nextChannels = _context2.sent;
|
|
11007
|
+
_this$state$getLatest4 = _this.state.getLatestValue(), channels = _this$state$getLatest4.channels;
|
|
11008
|
+
newOffset = offset + ((_nextChannels$length = nextChannels === null || nextChannels === void 0 ? void 0 : nextChannels.length) !== null && _nextChannels$length !== void 0 ? _nextChannels$length : 0);
|
|
11009
|
+
newOptions = _objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
11010
|
+
offset: newOffset
|
|
11011
|
+
});
|
|
11012
|
+
|
|
11013
|
+
_this.state.partialNext({
|
|
11014
|
+
channels: uniqBy([].concat(_toConsumableArray(channels || []), _toConsumableArray(nextChannels)), 'cid'),
|
|
11015
|
+
pagination: _objectSpread$2(_objectSpread$2({}, pagination), {}, {
|
|
11016
|
+
hasNext: ((_nextChannels$length2 = nextChannels === null || nextChannels === void 0 ? void 0 : nextChannels.length) !== null && _nextChannels$length2 !== void 0 ? _nextChannels$length2 : 0) >= limit,
|
|
11017
|
+
isLoading: false,
|
|
11018
|
+
isLoadingNext: false,
|
|
11019
|
+
options: newOptions
|
|
11020
|
+
})
|
|
11021
|
+
});
|
|
11022
|
+
|
|
11023
|
+
_context2.next = 21;
|
|
11024
|
+
break;
|
|
11025
|
+
|
|
11026
|
+
case 16:
|
|
11027
|
+
_context2.prev = 16;
|
|
11028
|
+
_context2.t0 = _context2["catch"](4);
|
|
11029
|
+
|
|
11030
|
+
_this.client.logger('error', _context2.t0.message);
|
|
11031
|
+
|
|
11032
|
+
_this.state.next(function (currentState) {
|
|
11033
|
+
return _objectSpread$2(_objectSpread$2({}, currentState), {}, {
|
|
11034
|
+
pagination: _objectSpread$2(_objectSpread$2({}, currentState.pagination), {}, {
|
|
11035
|
+
isLoadingNext: false
|
|
11036
|
+
})
|
|
11037
|
+
});
|
|
11038
|
+
});
|
|
11039
|
+
|
|
11040
|
+
throw _context2.t0;
|
|
11041
|
+
|
|
11042
|
+
case 21:
|
|
11043
|
+
case "end":
|
|
11044
|
+
return _context2.stop();
|
|
11045
|
+
}
|
|
11046
|
+
}
|
|
11047
|
+
}, _callee2, null, [[4, 16]]);
|
|
11048
|
+
})));
|
|
11049
|
+
|
|
11050
|
+
_defineProperty(this, "notificationAddedToChannelHandler", /*#__PURE__*/function () {
|
|
11051
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(event) {
|
|
11052
|
+
var _event$channel, _this$options$allowNo;
|
|
11053
|
+
|
|
11054
|
+
var _ref7, id, type, members, channel, _this$state$getLatest5, pagination, channels, _ref9, sort;
|
|
11055
|
+
|
|
11056
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
11057
|
+
while (1) {
|
|
11058
|
+
switch (_context3.prev = _context3.next) {
|
|
11059
|
+
case 0:
|
|
11060
|
+
_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;
|
|
11061
|
+
|
|
11062
|
+
if (!(!type || !((_this$options$allowNo = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo !== void 0 && _this$options$allowNo['notification.added_to_channel']))) {
|
|
11063
|
+
_context3.next = 3;
|
|
11064
|
+
break;
|
|
11065
|
+
}
|
|
11066
|
+
|
|
11067
|
+
return _context3.abrupt("return");
|
|
11068
|
+
|
|
11069
|
+
case 3:
|
|
11070
|
+
_context3.next = 5;
|
|
11071
|
+
return getAndWatchChannel({
|
|
11072
|
+
client: _this.client,
|
|
11073
|
+
id: id,
|
|
11074
|
+
members: members === null || members === void 0 ? void 0 : members.reduce(function (acc, _ref8) {
|
|
11075
|
+
var user = _ref8.user,
|
|
11076
|
+
user_id = _ref8.user_id;
|
|
11077
|
+
var userId = user_id || (user === null || user === void 0 ? void 0 : user.id);
|
|
11078
|
+
|
|
11079
|
+
if (userId) {
|
|
11080
|
+
acc.push(userId);
|
|
11081
|
+
}
|
|
11082
|
+
|
|
11083
|
+
return acc;
|
|
11084
|
+
}, []),
|
|
11085
|
+
type: type
|
|
11086
|
+
});
|
|
11087
|
+
|
|
11088
|
+
case 5:
|
|
11089
|
+
channel = _context3.sent;
|
|
11090
|
+
_this$state$getLatest5 = _this.state.getLatestValue(), pagination = _this$state$getLatest5.pagination, channels = _this$state$getLatest5.channels;
|
|
11091
|
+
|
|
11092
|
+
if (channels) {
|
|
11093
|
+
_context3.next = 9;
|
|
11094
|
+
break;
|
|
11095
|
+
}
|
|
11096
|
+
|
|
11097
|
+
return _context3.abrupt("return");
|
|
11098
|
+
|
|
11099
|
+
case 9:
|
|
11100
|
+
_ref9 = pagination !== null && pagination !== void 0 ? pagination : {}, sort = _ref9.sort;
|
|
11101
|
+
|
|
11102
|
+
_this.setChannels(promoteChannel({
|
|
11103
|
+
channels: channels,
|
|
11104
|
+
channelToMove: channel,
|
|
11105
|
+
sort: sort
|
|
11106
|
+
}));
|
|
11107
|
+
|
|
11108
|
+
case 11:
|
|
11109
|
+
case "end":
|
|
11110
|
+
return _context3.stop();
|
|
11111
|
+
}
|
|
11112
|
+
}
|
|
11113
|
+
}, _callee3);
|
|
11114
|
+
}));
|
|
11115
|
+
|
|
11116
|
+
return function (_x2) {
|
|
11117
|
+
return _ref6.apply(this, arguments);
|
|
11118
|
+
};
|
|
11119
|
+
}());
|
|
11120
|
+
|
|
11121
|
+
_defineProperty(this, "channelDeletedHandler", function (event) {
|
|
11122
|
+
var _this$state$getLatest6 = _this.state.getLatestValue(),
|
|
11123
|
+
channels = _this$state$getLatest6.channels;
|
|
11124
|
+
|
|
11125
|
+
if (!channels) {
|
|
11126
|
+
return;
|
|
11127
|
+
}
|
|
11128
|
+
|
|
11129
|
+
var newChannels = _toConsumableArray(channels);
|
|
11130
|
+
|
|
11131
|
+
var channelIndex = newChannels.findIndex(function (channel) {
|
|
11132
|
+
var _event$channel2;
|
|
11133
|
+
|
|
11134
|
+
return channel.cid === (event.cid || ((_event$channel2 = event.channel) === null || _event$channel2 === void 0 ? void 0 : _event$channel2.cid));
|
|
11135
|
+
});
|
|
11136
|
+
|
|
11137
|
+
if (channelIndex < 0) {
|
|
11138
|
+
return;
|
|
11139
|
+
}
|
|
11140
|
+
|
|
11141
|
+
newChannels.splice(channelIndex, 1);
|
|
11142
|
+
|
|
11143
|
+
_this.setChannels(newChannels);
|
|
11144
|
+
});
|
|
11145
|
+
|
|
11146
|
+
_defineProperty(this, "channelHiddenHandler", this.channelDeletedHandler);
|
|
11147
|
+
|
|
11148
|
+
_defineProperty(this, "newMessageHandler", function (event) {
|
|
11149
|
+
var _this$options$allowNo2;
|
|
11150
|
+
|
|
11151
|
+
var _this$state$getLatest7 = _this.state.getLatestValue(),
|
|
11152
|
+
pagination = _this$state$getLatest7.pagination,
|
|
11153
|
+
channels = _this$state$getLatest7.channels;
|
|
11154
|
+
|
|
11155
|
+
if (!channels) {
|
|
11156
|
+
return;
|
|
11157
|
+
}
|
|
11158
|
+
|
|
11159
|
+
var _ref10 = pagination !== null && pagination !== void 0 ? pagination : {},
|
|
11160
|
+
filters = _ref10.filters,
|
|
11161
|
+
sort = _ref10.sort;
|
|
11162
|
+
|
|
11163
|
+
var channelType = event.channel_type;
|
|
11164
|
+
var channelId = event.channel_id;
|
|
11165
|
+
|
|
11166
|
+
if (!channelType || !channelId) {
|
|
11167
|
+
return;
|
|
11168
|
+
}
|
|
11169
|
+
|
|
11170
|
+
var targetChannel = _this.client.channel(channelType, channelId);
|
|
11171
|
+
|
|
11172
|
+
var targetChannelIndex = channels.indexOf(targetChannel);
|
|
11173
|
+
var targetChannelExistsWithinList = targetChannelIndex >= 0;
|
|
11174
|
+
var isTargetChannelPinned = isChannelPinned(targetChannel);
|
|
11175
|
+
var isTargetChannelArchived = isChannelArchived(targetChannel);
|
|
11176
|
+
var considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
11177
|
+
var considerPinnedChannels = shouldConsiderPinnedChannels(sort);
|
|
11178
|
+
|
|
11179
|
+
if ( // filter is defined, target channel is archived and filter option is set to false
|
|
11180
|
+
considerArchivedChannels && isTargetChannelArchived && !filters.archived || // filter is defined, target channel isn't archived and filter option is set to true
|
|
11181
|
+
considerArchivedChannels && !isTargetChannelArchived && filters.archived || // sort option is defined, target channel is pinned
|
|
11182
|
+
considerPinnedChannels && isTargetChannelPinned || // list order is locked
|
|
11183
|
+
_this.options.lockChannelOrder || // target channel is not within the loaded list and loading from cache is disallowed
|
|
11184
|
+
!targetChannelExistsWithinList && !((_this$options$allowNo2 = _this.options.allowNotLoadedChannelPromotionForEvent) !== null && _this$options$allowNo2 !== void 0 && _this$options$allowNo2['message.new'])) {
|
|
11185
|
+
return;
|
|
11186
|
+
}
|
|
11187
|
+
|
|
11188
|
+
_this.setChannels(promoteChannel({
|
|
11189
|
+
channels: channels,
|
|
11190
|
+
channelToMove: targetChannel,
|
|
11191
|
+
channelToMoveIndexWithinChannels: targetChannelIndex,
|
|
11192
|
+
sort: sort
|
|
11193
|
+
}));
|
|
11194
|
+
});
|
|
11195
|
+
|
|
11196
|
+
_defineProperty(this, "notificationNewMessageHandler", /*#__PURE__*/function () {
|
|
11197
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(event) {
|
|
11198
|
+
var _event$channel3, _this$options$allowNo3;
|
|
11199
|
+
|
|
11200
|
+
var _ref12, id, type, channel, _this$state$getLatest8, channels, pagination, _ref13, filters, sort, considerArchivedChannels, isTargetChannelArchived;
|
|
11201
|
+
|
|
11202
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
11203
|
+
while (1) {
|
|
11204
|
+
switch (_context4.prev = _context4.next) {
|
|
11205
|
+
case 0:
|
|
11206
|
+
_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;
|
|
11207
|
+
|
|
11208
|
+
if (!(!id || !type)) {
|
|
11209
|
+
_context4.next = 3;
|
|
11210
|
+
break;
|
|
11211
|
+
}
|
|
11212
|
+
|
|
11213
|
+
return _context4.abrupt("return");
|
|
11214
|
+
|
|
11215
|
+
case 3:
|
|
11216
|
+
_context4.next = 5;
|
|
11217
|
+
return getAndWatchChannel({
|
|
11218
|
+
client: _this.client,
|
|
11219
|
+
id: id,
|
|
11220
|
+
type: type
|
|
11221
|
+
});
|
|
11222
|
+
|
|
11223
|
+
case 5:
|
|
11224
|
+
channel = _context4.sent;
|
|
11225
|
+
_this$state$getLatest8 = _this.state.getLatestValue(), channels = _this$state$getLatest8.channels, pagination = _this$state$getLatest8.pagination;
|
|
11226
|
+
_ref13 = pagination !== null && pagination !== void 0 ? pagination : {}, filters = _ref13.filters, sort = _ref13.sort;
|
|
11227
|
+
considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
11228
|
+
isTargetChannelArchived = isChannelArchived(channel);
|
|
11229
|
+
|
|
11230
|
+
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']))) {
|
|
11231
|
+
_context4.next = 12;
|
|
11232
|
+
break;
|
|
11233
|
+
}
|
|
11234
|
+
|
|
11235
|
+
return _context4.abrupt("return");
|
|
11236
|
+
|
|
11237
|
+
case 12:
|
|
11238
|
+
_this.setChannels(promoteChannel({
|
|
11239
|
+
channels: channels,
|
|
11240
|
+
channelToMove: channel,
|
|
11241
|
+
sort: sort
|
|
11242
|
+
}));
|
|
11243
|
+
|
|
11244
|
+
case 13:
|
|
11245
|
+
case "end":
|
|
11246
|
+
return _context4.stop();
|
|
11247
|
+
}
|
|
11248
|
+
}
|
|
11249
|
+
}, _callee4);
|
|
11250
|
+
}));
|
|
11251
|
+
|
|
11252
|
+
return function (_x3) {
|
|
11253
|
+
return _ref11.apply(this, arguments);
|
|
11254
|
+
};
|
|
11255
|
+
}());
|
|
11256
|
+
|
|
11257
|
+
_defineProperty(this, "channelVisibleHandler", /*#__PURE__*/function () {
|
|
11258
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(event) {
|
|
11259
|
+
var _this$options$allowNo4;
|
|
11260
|
+
|
|
11261
|
+
var channelType, channelId, channel, _this$state$getLatest9, channels, pagination, _ref15, sort, filters, considerArchivedChannels, isTargetChannelArchived;
|
|
11262
|
+
|
|
11263
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
11264
|
+
while (1) {
|
|
11265
|
+
switch (_context5.prev = _context5.next) {
|
|
11266
|
+
case 0:
|
|
11267
|
+
channelType = event.channel_type, channelId = event.channel_id;
|
|
11268
|
+
|
|
11269
|
+
if (!(!channelType || !channelId)) {
|
|
11270
|
+
_context5.next = 3;
|
|
11271
|
+
break;
|
|
11272
|
+
}
|
|
11273
|
+
|
|
11274
|
+
return _context5.abrupt("return");
|
|
11275
|
+
|
|
11276
|
+
case 3:
|
|
11277
|
+
_context5.next = 5;
|
|
11278
|
+
return getAndWatchChannel({
|
|
11279
|
+
client: _this.client,
|
|
11280
|
+
id: event.channel_id,
|
|
11281
|
+
type: event.channel_type
|
|
11282
|
+
});
|
|
11283
|
+
|
|
11284
|
+
case 5:
|
|
11285
|
+
channel = _context5.sent;
|
|
11286
|
+
_this$state$getLatest9 = _this.state.getLatestValue(), channels = _this$state$getLatest9.channels, pagination = _this$state$getLatest9.pagination;
|
|
11287
|
+
_ref15 = pagination !== null && pagination !== void 0 ? pagination : {}, sort = _ref15.sort, filters = _ref15.filters;
|
|
11288
|
+
considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
11289
|
+
isTargetChannelArchived = isChannelArchived(channel);
|
|
11290
|
+
|
|
11291
|
+
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']))) {
|
|
11292
|
+
_context5.next = 12;
|
|
11293
|
+
break;
|
|
11294
|
+
}
|
|
11295
|
+
|
|
11296
|
+
return _context5.abrupt("return");
|
|
11297
|
+
|
|
11298
|
+
case 12:
|
|
11299
|
+
_this.setChannels(promoteChannel({
|
|
11300
|
+
channels: channels,
|
|
11301
|
+
channelToMove: channel,
|
|
11302
|
+
sort: sort
|
|
11303
|
+
}));
|
|
11304
|
+
|
|
11305
|
+
case 13:
|
|
11306
|
+
case "end":
|
|
11307
|
+
return _context5.stop();
|
|
11308
|
+
}
|
|
11309
|
+
}
|
|
11310
|
+
}, _callee5);
|
|
11311
|
+
}));
|
|
11312
|
+
|
|
11313
|
+
return function (_x4) {
|
|
11314
|
+
return _ref14.apply(this, arguments);
|
|
11315
|
+
};
|
|
11316
|
+
}());
|
|
11317
|
+
|
|
11318
|
+
_defineProperty(this, "notificationRemovedFromChannelHandler", this.channelDeletedHandler);
|
|
11319
|
+
|
|
11320
|
+
_defineProperty(this, "memberUpdatedHandler", function (event) {
|
|
11321
|
+
var _event$member;
|
|
11322
|
+
|
|
11323
|
+
var _this$state$getLatest10 = _this.state.getLatestValue(),
|
|
11324
|
+
pagination = _this$state$getLatest10.pagination,
|
|
11325
|
+
channels = _this$state$getLatest10.channels;
|
|
11326
|
+
|
|
11327
|
+
var filters = pagination.filters,
|
|
11328
|
+
sort = pagination.sort;
|
|
11329
|
+
|
|
11330
|
+
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) {
|
|
11331
|
+
return;
|
|
11332
|
+
}
|
|
11333
|
+
|
|
11334
|
+
var channelType = event.channel_type;
|
|
11335
|
+
var channelId = event.channel_id;
|
|
11336
|
+
var considerPinnedChannels = shouldConsiderPinnedChannels(sort);
|
|
11337
|
+
var considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
11338
|
+
var pinnedAtSort = extractSortValue({
|
|
11339
|
+
atIndex: 0,
|
|
11340
|
+
sort: sort,
|
|
11341
|
+
targetKey: 'pinned_at'
|
|
11342
|
+
});
|
|
11343
|
+
|
|
11344
|
+
if (!channels || !considerPinnedChannels && !considerArchivedChannels || _this.options.lockChannelOrder) {
|
|
11345
|
+
return;
|
|
11346
|
+
}
|
|
11347
|
+
|
|
11348
|
+
var targetChannel = _this.client.channel(channelType, channelId); // assumes that channel instances are not changing
|
|
11349
|
+
|
|
11350
|
+
|
|
11351
|
+
var targetChannelIndex = channels.indexOf(targetChannel);
|
|
11352
|
+
var targetChannelExistsWithinList = targetChannelIndex >= 0;
|
|
11353
|
+
var isTargetChannelPinned = isChannelPinned(targetChannel);
|
|
11354
|
+
var isTargetChannelArchived = isChannelArchived(targetChannel);
|
|
11355
|
+
|
|
11356
|
+
var newChannels = _toConsumableArray(channels);
|
|
11357
|
+
|
|
11358
|
+
if (targetChannelExistsWithinList) {
|
|
11359
|
+
newChannels.splice(targetChannelIndex, 1);
|
|
11360
|
+
} // handle archiving (remove channel)
|
|
11361
|
+
|
|
11362
|
+
|
|
11363
|
+
if ( // When archived filter true, and channel is unarchived
|
|
11364
|
+
considerArchivedChannels && !isTargetChannelArchived && filters !== null && filters !== void 0 && filters.archived || // When archived filter false, and channel is archived
|
|
11365
|
+
considerArchivedChannels && isTargetChannelArchived && !(filters !== null && filters !== void 0 && filters.archived)) {
|
|
11366
|
+
_this.setChannels(newChannels);
|
|
11367
|
+
|
|
11368
|
+
return;
|
|
11369
|
+
} // handle pinning
|
|
11370
|
+
|
|
11371
|
+
|
|
11372
|
+
var lastPinnedChannelIndex = null;
|
|
11373
|
+
|
|
11374
|
+
if (pinnedAtSort === 1 || pinnedAtSort === -1 && !isTargetChannelPinned) {
|
|
11375
|
+
lastPinnedChannelIndex = findLastPinnedChannelIndex({
|
|
11376
|
+
channels: newChannels
|
|
11377
|
+
});
|
|
11378
|
+
}
|
|
11379
|
+
|
|
11380
|
+
var newTargetChannelIndex = typeof lastPinnedChannelIndex === 'number' ? lastPinnedChannelIndex + 1 : 0; // skip state update if the position of the channel does not change
|
|
11381
|
+
|
|
11382
|
+
if (channels[newTargetChannelIndex] === targetChannel) {
|
|
11383
|
+
return;
|
|
11384
|
+
}
|
|
11385
|
+
|
|
11386
|
+
newChannels.splice(newTargetChannelIndex, 0, targetChannel);
|
|
11387
|
+
|
|
11388
|
+
_this.setChannels(newChannels);
|
|
11389
|
+
});
|
|
11390
|
+
|
|
11391
|
+
_defineProperty(this, "subscriptionOrOverride", function (event) {
|
|
11392
|
+
var handlerName = channelManagerEventToHandlerMapping[event.type];
|
|
11393
|
+
|
|
11394
|
+
var defaultEventHandler = _this.eventHandlers.get(handlerName);
|
|
11395
|
+
|
|
11396
|
+
var eventHandlerOverride = _this.eventHandlerOverrides.get(handlerName);
|
|
11397
|
+
|
|
11398
|
+
if (eventHandlerOverride && typeof eventHandlerOverride === 'function') {
|
|
11399
|
+
eventHandlerOverride(_this.setChannels, event);
|
|
11400
|
+
return;
|
|
11401
|
+
}
|
|
11402
|
+
|
|
11403
|
+
if (defaultEventHandler && typeof defaultEventHandler === 'function') {
|
|
11404
|
+
defaultEventHandler(event);
|
|
11405
|
+
}
|
|
11406
|
+
});
|
|
11407
|
+
|
|
11408
|
+
_defineProperty(this, "registerSubscriptions", function () {
|
|
11409
|
+
if (_this.unsubscribeFunctions.size) {
|
|
11410
|
+
// Already listening for events and changes
|
|
11411
|
+
return;
|
|
11412
|
+
}
|
|
11413
|
+
|
|
11414
|
+
for (var _i = 0, _Object$keys = Object.keys(channelManagerEventToHandlerMapping); _i < _Object$keys.length; _i++) {
|
|
11415
|
+
var eventType = _Object$keys[_i];
|
|
11416
|
+
|
|
11417
|
+
_this.unsubscribeFunctions.add(_this.client.on(eventType, _this.subscriptionOrOverride).unsubscribe);
|
|
11418
|
+
}
|
|
11419
|
+
});
|
|
11420
|
+
|
|
11421
|
+
_defineProperty(this, "unregisterSubscriptions", function () {
|
|
11422
|
+
_this.unsubscribeFunctions.forEach(function (cleanupFunction) {
|
|
11423
|
+
return cleanupFunction();
|
|
11424
|
+
});
|
|
11425
|
+
|
|
11426
|
+
_this.unsubscribeFunctions.clear();
|
|
11427
|
+
});
|
|
11428
|
+
|
|
11429
|
+
this.client = client;
|
|
11430
|
+
this.state = new StateStore({
|
|
11431
|
+
channels: [],
|
|
11432
|
+
pagination: {
|
|
11433
|
+
isLoading: false,
|
|
11434
|
+
isLoadingNext: false,
|
|
11435
|
+
hasNext: false,
|
|
11436
|
+
filters: {},
|
|
11437
|
+
sort: {},
|
|
11438
|
+
options: DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS
|
|
11439
|
+
},
|
|
11440
|
+
initialized: false
|
|
11441
|
+
});
|
|
11442
|
+
this.setEventHandlerOverrides(_eventHandlerOverrides);
|
|
11443
|
+
this.setOptions(_options);
|
|
11444
|
+
this.eventHandlers = new Map(Object.entries({
|
|
11445
|
+
channelDeletedHandler: this.channelDeletedHandler,
|
|
11446
|
+
channelHiddenHandler: this.channelHiddenHandler,
|
|
11447
|
+
channelVisibleHandler: this.channelVisibleHandler,
|
|
11448
|
+
memberUpdatedHandler: this.memberUpdatedHandler,
|
|
11449
|
+
newMessageHandler: this.newMessageHandler,
|
|
11450
|
+
notificationAddedToChannelHandler: this.notificationAddedToChannelHandler,
|
|
11451
|
+
notificationNewMessageHandler: this.notificationNewMessageHandler,
|
|
11452
|
+
notificationRemovedFromChannelHandler: this.notificationRemovedFromChannelHandler
|
|
11453
|
+
}));
|
|
11454
|
+
};
|
|
11455
|
+
|
|
10465
11456
|
var _excluded$1 = ["created_at", "updated_at", "last_active", "online"],
|
|
10466
11457
|
_excluded2 = ["params", "headers"];
|
|
10467
11458
|
|
|
@@ -10689,6 +11680,18 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10689
11680
|
};
|
|
10690
11681
|
}());
|
|
10691
11682
|
|
|
11683
|
+
_defineProperty(this, "createChannelManager", function (_ref3) {
|
|
11684
|
+
var _ref3$eventHandlerOve = _ref3.eventHandlerOverrides,
|
|
11685
|
+
eventHandlerOverrides = _ref3$eventHandlerOve === void 0 ? {} : _ref3$eventHandlerOve,
|
|
11686
|
+
_ref3$options = _ref3.options,
|
|
11687
|
+
options = _ref3$options === void 0 ? {} : _ref3$options;
|
|
11688
|
+
return new ChannelManager({
|
|
11689
|
+
client: _this,
|
|
11690
|
+
eventHandlerOverrides: eventHandlerOverrides,
|
|
11691
|
+
options: options
|
|
11692
|
+
});
|
|
11693
|
+
});
|
|
11694
|
+
|
|
10692
11695
|
_defineProperty(this, "openConnection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
10693
11696
|
var _this$wsConnection3, _this$wsConnection4, _this$wsFallback3;
|
|
10694
11697
|
|
|
@@ -10758,7 +11761,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10758
11761
|
});
|
|
10759
11762
|
|
|
10760
11763
|
_defineProperty(this, "disconnectUser", /*#__PURE__*/function () {
|
|
10761
|
-
var
|
|
11764
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(timeout) {
|
|
10762
11765
|
var closePromise, _i, _Object$values, _channel;
|
|
10763
11766
|
|
|
10764
11767
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
@@ -10806,7 +11809,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10806
11809
|
}));
|
|
10807
11810
|
|
|
10808
11811
|
return function (_x4) {
|
|
10809
|
-
return
|
|
11812
|
+
return _ref5.apply(this, arguments);
|
|
10810
11813
|
};
|
|
10811
11814
|
}());
|
|
10812
11815
|
|
|
@@ -10834,7 +11837,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10834
11837
|
_defineProperty(this, "setAnonymousUser", this.connectAnonymousUser);
|
|
10835
11838
|
|
|
10836
11839
|
_defineProperty(this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
10837
|
-
var
|
|
11840
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(type, url, data) {
|
|
10838
11841
|
var options,
|
|
10839
11842
|
requestConfig,
|
|
10840
11843
|
response,
|
|
@@ -10975,7 +11978,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
10975
11978
|
}));
|
|
10976
11979
|
|
|
10977
11980
|
return function (_x5, _x6, _x7) {
|
|
10978
|
-
return
|
|
11981
|
+
return _ref6.apply(this, arguments);
|
|
10979
11982
|
};
|
|
10980
11983
|
}());
|
|
10981
11984
|
|
|
@@ -11196,13 +12199,19 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
11196
12199
|
})));
|
|
11197
12200
|
|
|
11198
12201
|
_defineProperty(this, "getChannelByMembers", function (channelType, custom) {
|
|
12202
|
+
var _custom$members;
|
|
12203
|
+
|
|
11199
12204
|
// Check if the channel already exists.
|
|
11200
12205
|
// Only allow 1 channel object per cid
|
|
11201
|
-
var
|
|
12206
|
+
var memberIds = ((_custom$members = custom.members) !== null && _custom$members !== void 0 ? _custom$members : []).map(function (member) {
|
|
12207
|
+
var _member$user_id;
|
|
11202
12208
|
|
|
11203
|
-
|
|
12209
|
+
return typeof member === 'string' ? member : (_member$user_id = member.user_id) !== null && _member$user_id !== void 0 ? _member$user_id : '';
|
|
12210
|
+
});
|
|
12211
|
+
var membersStr = memberIds.sort().join(',');
|
|
12212
|
+
var tempCid = generateChannelTempCid(channelType, memberIds);
|
|
11204
12213
|
|
|
11205
|
-
if (!
|
|
12214
|
+
if (!tempCid) {
|
|
11206
12215
|
throw Error('Please specify atleast one member when creating unique conversation');
|
|
11207
12216
|
} // channel could exist in `activeChannels` list with either one of the following two keys:
|
|
11208
12217
|
// 1. cid - Which gets set on channel only after calling channel.query or channel.watch or channel.create
|
|
@@ -13052,13 +14061,13 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13052
14061
|
key: "getRateLimits",
|
|
13053
14062
|
value: function () {
|
|
13054
14063
|
var _getRateLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(params) {
|
|
13055
|
-
var
|
|
14064
|
+
var _ref8, serverSide, web, android, ios, endpoints;
|
|
13056
14065
|
|
|
13057
14066
|
return _regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
13058
14067
|
while (1) {
|
|
13059
14068
|
switch (_context29.prev = _context29.next) {
|
|
13060
14069
|
case 0:
|
|
13061
|
-
|
|
14070
|
+
_ref8 = params || {}, serverSide = _ref8.serverSide, web = _ref8.web, android = _ref8.android, ios = _ref8.ios, endpoints = _ref8.endpoints;
|
|
13062
14071
|
return _context29.abrupt("return", this.get(this.baseURL + '/rate_limits', {
|
|
13063
14072
|
server_side: serverSide,
|
|
13064
14073
|
web: web,
|
|
@@ -13083,9 +14092,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13083
14092
|
}()
|
|
13084
14093
|
}, {
|
|
13085
14094
|
key: "_addChannelConfig",
|
|
13086
|
-
value: function _addChannelConfig(
|
|
13087
|
-
var cid =
|
|
13088
|
-
config =
|
|
14095
|
+
value: function _addChannelConfig(_ref9) {
|
|
14096
|
+
var cid = _ref9.cid,
|
|
14097
|
+
config = _ref9.config;
|
|
13089
14098
|
|
|
13090
14099
|
if (this._cacheEnabled()) {
|
|
13091
14100
|
this.configs[cid] = config;
|
|
@@ -13109,7 +14118,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13109
14118
|
}, {
|
|
13110
14119
|
key: "channel",
|
|
13111
14120
|
value: function channel(channelType, channelIDOrCustom) {
|
|
13112
|
-
var _custom$
|
|
14121
|
+
var _custom$members2;
|
|
13113
14122
|
|
|
13114
14123
|
var custom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
13115
14124
|
|
|
@@ -13127,7 +14136,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
13127
14136
|
} // // support channel("messaging", undefined, {options})
|
|
13128
14137
|
|
|
13129
14138
|
|
|
13130
|
-
if (!channelIDOrCustom && _typeof(custom) === 'object' && (_custom$
|
|
14139
|
+
if (!channelIDOrCustom && _typeof(custom) === 'object' && (_custom$members2 = custom.members) !== null && _custom$members2 !== void 0 && _custom$members2.length) {
|
|
13131
14140
|
return this.getChannelByMembers(channelType, custom);
|
|
13132
14141
|
} // support channel("messaging", null, {options})
|
|
13133
14142
|
// support channel("messaging", undefined, {options})
|
|
@@ -15073,7 +16082,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15073
16082
|
}, {
|
|
15074
16083
|
key: "getUserAgent",
|
|
15075
16084
|
value: function getUserAgent() {
|
|
15076
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.
|
|
16085
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.56.1");
|
|
15077
16086
|
}
|
|
15078
16087
|
}, {
|
|
15079
16088
|
key: "setUserAgent",
|
|
@@ -15113,10 +16122,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
15113
16122
|
});
|
|
15114
16123
|
}
|
|
15115
16124
|
|
|
15116
|
-
var
|
|
15117
|
-
axiosRequestConfigParams =
|
|
15118
|
-
axiosRequestConfigHeaders =
|
|
15119
|
-
axiosRequestConfigRest = _objectWithoutProperties(
|
|
16125
|
+
var _ref10 = this.options.axiosRequestConfig || {},
|
|
16126
|
+
axiosRequestConfigParams = _ref10.params,
|
|
16127
|
+
axiosRequestConfigHeaders = _ref10.headers,
|
|
16128
|
+
axiosRequestConfigRest = _objectWithoutProperties(_ref10, _excluded2);
|
|
15120
16129
|
|
|
15121
16130
|
return _objectSpread$1(_objectSpread$1(_objectSpread$1({
|
|
15122
16131
|
params: _objectSpread$1(_objectSpread$1({
|
|
@@ -16459,13 +17468,13 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
16459
17468
|
}, {
|
|
16460
17469
|
key: "deletePushProvider",
|
|
16461
17470
|
value: function () {
|
|
16462
|
-
var _deletePushProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee97(
|
|
17471
|
+
var _deletePushProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee97(_ref11) {
|
|
16463
17472
|
var type, name;
|
|
16464
17473
|
return _regeneratorRuntime.wrap(function _callee97$(_context97) {
|
|
16465
17474
|
while (1) {
|
|
16466
17475
|
switch (_context97.prev = _context97.next) {
|
|
16467
17476
|
case 0:
|
|
16468
|
-
type =
|
|
17477
|
+
type = _ref11.type, name = _ref11.name;
|
|
16469
17478
|
_context97.next = 3;
|
|
16470
17479
|
return this.delete(this.baseURL + "/push_providers/".concat(encodeURIComponent(type), "/").concat(encodeURIComponent(name)));
|
|
16471
17480
|
|
|
@@ -18204,5 +19213,5 @@ var SearchController = /*#__PURE__*/function () {
|
|
|
18204
19213
|
return SearchController;
|
|
18205
19214
|
}();
|
|
18206
19215
|
|
|
18207
|
-
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 };
|
|
19216
|
+
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 };
|
|
18208
19217
|
//# sourceMappingURL=browser.es.js.map
|