stream-chat-react 10.10.1 → 10.10.2
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.full-bundle.js +125 -63
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +3 -3
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/Channel/Channel.d.ts.map +1 -1
- package/dist/components/Channel/Channel.js +27 -8
- package/dist/components/ChannelList/hooks/useChannelVisibleListener.d.ts.map +1 -1
- package/dist/components/ChannelList/hooks/useChannelVisibleListener.js +6 -2
- package/dist/components/ChannelList/hooks/useNotificationAddedToChannelListener.d.ts.map +1 -1
- package/dist/components/ChannelList/hooks/useNotificationAddedToChannelListener.js +19 -7
- package/dist/components/ChannelList/hooks/useNotificationMessageNewListener.d.ts.map +1 -1
- package/dist/components/ChannelList/hooks/useNotificationMessageNewListener.js +6 -2
- package/dist/components/ChannelList/utils.d.ts +1 -8
- package/dist/components/ChannelList/utils.d.ts.map +1 -1
- package/dist/components/ChannelList/utils.js +1 -35
- package/dist/index.cjs.js +125 -63
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/utils/getChannel.d.ts +20 -0
- package/dist/utils/getChannel.d.ts.map +1 -0
- package/dist/utils/getChannel.js +58 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -45406,6 +45406,64 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
45406
45406
|
notificationTimeouts.push(timeout);
|
|
45407
45407
|
}; };
|
|
45408
45408
|
|
|
45409
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};/**
|
|
45410
|
+
* prevent from duplicate invocation of channel.watch()
|
|
45411
|
+
* when events 'notification.message_new' and 'notification.added_to_channel' arrive at the same time
|
|
45412
|
+
*/
|
|
45413
|
+
var WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL = {};
|
|
45414
|
+
/**
|
|
45415
|
+
* Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
|
|
45416
|
+
* @param client
|
|
45417
|
+
* @param members
|
|
45418
|
+
* @param type
|
|
45419
|
+
* @param id
|
|
45420
|
+
* @param channel
|
|
45421
|
+
*/
|
|
45422
|
+
var getChannel = function (_a) {
|
|
45423
|
+
var channel = _a.channel, client = _a.client, id = _a.id, members = _a.members, type = _a.type;
|
|
45424
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
45425
|
+
var theChannel, originalCid, queryPromise;
|
|
45426
|
+
return __generator(this, function (_b) {
|
|
45427
|
+
switch (_b.label) {
|
|
45428
|
+
case 0:
|
|
45429
|
+
if (!channel && !type) {
|
|
45430
|
+
throw new Error('Channel or channel type have to be provided to query a channel.');
|
|
45431
|
+
}
|
|
45432
|
+
theChannel = channel || client.channel(type, id, { members: members });
|
|
45433
|
+
originalCid = (theChannel === null || theChannel === void 0 ? void 0 : theChannel.id)
|
|
45434
|
+
? theChannel.cid
|
|
45435
|
+
: members && members.length
|
|
45436
|
+
? generateChannelTempCid(theChannel.type, members)
|
|
45437
|
+
: undefined;
|
|
45438
|
+
if (!originalCid) {
|
|
45439
|
+
throw new Error('Channel ID or channel members array have to be provided to query a channel.');
|
|
45440
|
+
}
|
|
45441
|
+
queryPromise = WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid];
|
|
45442
|
+
if (!queryPromise) return [3 /*break*/, 2];
|
|
45443
|
+
return [4 /*yield*/, queryPromise];
|
|
45444
|
+
case 1:
|
|
45445
|
+
_b.sent();
|
|
45446
|
+
return [3 /*break*/, 4];
|
|
45447
|
+
case 2:
|
|
45448
|
+
WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch();
|
|
45449
|
+
return [4 /*yield*/, WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]];
|
|
45450
|
+
case 3:
|
|
45451
|
+
_b.sent();
|
|
45452
|
+
delete WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid];
|
|
45453
|
+
_b.label = 4;
|
|
45454
|
+
case 4: return [2 /*return*/, theChannel];
|
|
45455
|
+
}
|
|
45456
|
+
});
|
|
45457
|
+
});
|
|
45458
|
+
};
|
|
45459
|
+
// Channels created without ID need to be referenced by an identifier until the back-end generates the final ID.
|
|
45460
|
+
var generateChannelTempCid = function (channelType, members) {
|
|
45461
|
+
if (!members)
|
|
45462
|
+
return;
|
|
45463
|
+
var membersStr = __spreadArray([], members, true).sort().join(',');
|
|
45464
|
+
return "".concat(channelType, ":!members-").concat(membersStr);
|
|
45465
|
+
};
|
|
45466
|
+
|
|
45409
45467
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChannelContainerClasses = function (_a) {
|
|
45410
45468
|
var _b, _c, _d;
|
|
45411
45469
|
var customClasses = _a.customClasses;
|
|
@@ -45648,22 +45706,40 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
45648
45706
|
markRead();
|
|
45649
45707
|
};
|
|
45650
45708
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
45651
|
-
var config, e_1;
|
|
45652
|
-
|
|
45653
|
-
|
|
45709
|
+
var members, _i, _a, member, userId, _b, user, user_id, config, e_1;
|
|
45710
|
+
var _c;
|
|
45711
|
+
return __generator(this, function (_d) {
|
|
45712
|
+
switch (_d.label) {
|
|
45654
45713
|
case 0:
|
|
45655
45714
|
if (!!channel.initialized) return [3 /*break*/, 4];
|
|
45656
|
-
|
|
45715
|
+
_d.label = 1;
|
|
45657
45716
|
case 1:
|
|
45658
|
-
|
|
45659
|
-
|
|
45717
|
+
_d.trys.push([1, 3, , 4]);
|
|
45718
|
+
members = [];
|
|
45719
|
+
if (!channel.id && ((_c = channel.data) === null || _c === void 0 ? void 0 : _c.members)) {
|
|
45720
|
+
for (_i = 0, _a = channel.data.members; _i < _a.length; _i++) {
|
|
45721
|
+
member = _a[_i];
|
|
45722
|
+
userId = void 0;
|
|
45723
|
+
if (typeof member === 'string') {
|
|
45724
|
+
userId = member;
|
|
45725
|
+
}
|
|
45726
|
+
else if (typeof member === 'object') {
|
|
45727
|
+
_b = member, user = _b.user, user_id = _b.user_id;
|
|
45728
|
+
userId = user_id || (user === null || user === void 0 ? void 0 : user.id);
|
|
45729
|
+
}
|
|
45730
|
+
if (userId) {
|
|
45731
|
+
members.push(userId);
|
|
45732
|
+
}
|
|
45733
|
+
}
|
|
45734
|
+
}
|
|
45735
|
+
return [4 /*yield*/, getChannel({ channel: channel, client: client, members: members })];
|
|
45660
45736
|
case 2:
|
|
45661
|
-
|
|
45737
|
+
_d.sent();
|
|
45662
45738
|
config = channel.getConfig();
|
|
45663
45739
|
setChannelConfig(config);
|
|
45664
45740
|
return [3 /*break*/, 4];
|
|
45665
45741
|
case 3:
|
|
45666
|
-
e_1 =
|
|
45742
|
+
e_1 = _d.sent();
|
|
45667
45743
|
dispatch({ error: e_1, type: 'setError' });
|
|
45668
45744
|
errored = true;
|
|
45669
45745
|
return [3 /*break*/, 4];
|
|
@@ -46399,52 +46475,6 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
46399
46475
|
}, [customHandler]);
|
|
46400
46476
|
};
|
|
46401
46477
|
|
|
46402
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};/**
|
|
46403
|
-
* prevent from duplicate invocation of channel.watch()
|
|
46404
|
-
* when events 'notification.message_new' and 'notification.added_to_channel' arrive at the same time
|
|
46405
|
-
*/
|
|
46406
|
-
var WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL = {};
|
|
46407
|
-
/**
|
|
46408
|
-
* Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
|
|
46409
|
-
* @param client
|
|
46410
|
-
* @param type
|
|
46411
|
-
* @param id
|
|
46412
|
-
*/
|
|
46413
|
-
var getChannel = function (client, type, id) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46414
|
-
var channel, queryPromise;
|
|
46415
|
-
return __generator(this, function (_a) {
|
|
46416
|
-
switch (_a.label) {
|
|
46417
|
-
case 0:
|
|
46418
|
-
channel = client.channel(type, id);
|
|
46419
|
-
queryPromise = WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[channel.cid];
|
|
46420
|
-
if (!queryPromise) return [3 /*break*/, 2];
|
|
46421
|
-
return [4 /*yield*/, queryPromise];
|
|
46422
|
-
case 1:
|
|
46423
|
-
_a.sent();
|
|
46424
|
-
return [3 /*break*/, 4];
|
|
46425
|
-
case 2:
|
|
46426
|
-
WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[channel.cid] = channel.watch();
|
|
46427
|
-
return [4 /*yield*/, WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[channel.cid]];
|
|
46428
|
-
case 3:
|
|
46429
|
-
_a.sent();
|
|
46430
|
-
WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[channel.cid] = undefined;
|
|
46431
|
-
_a.label = 4;
|
|
46432
|
-
case 4: return [2 /*return*/, channel];
|
|
46433
|
-
}
|
|
46434
|
-
});
|
|
46435
|
-
}); };
|
|
46436
|
-
var MAX_QUERY_CHANNELS_LIMIT = 30;
|
|
46437
|
-
var moveChannelUp = function (_a) {
|
|
46438
|
-
var activeChannel = _a.activeChannel, channels = _a.channels, cid = _a.cid;
|
|
46439
|
-
// get index of channel to move up
|
|
46440
|
-
var channelIndex = channels.findIndex(function (channel) { return channel.cid === cid; });
|
|
46441
|
-
if (!activeChannel && channelIndex <= 0)
|
|
46442
|
-
return channels;
|
|
46443
|
-
// get channel to move up
|
|
46444
|
-
var channel = activeChannel || channels[channelIndex];
|
|
46445
|
-
return uniqBy(__spreadArray([channel], channels, true), 'cid');
|
|
46446
|
-
};
|
|
46447
|
-
|
|
46448
46478
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChannelVisibleListener = function (setChannels, customHandler) {
|
|
46449
46479
|
var client = useChatContext('useChannelVisibleListener').client;
|
|
46450
46480
|
React$2.useEffect(function () {
|
|
@@ -46458,7 +46488,11 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
46458
46488
|
return [3 /*break*/, 3];
|
|
46459
46489
|
case 1:
|
|
46460
46490
|
if (!(event.type && event.channel_type && event.channel_id)) return [3 /*break*/, 3];
|
|
46461
|
-
return [4 /*yield*/, getChannel(
|
|
46491
|
+
return [4 /*yield*/, getChannel({
|
|
46492
|
+
client: client,
|
|
46493
|
+
id: event.channel_id,
|
|
46494
|
+
type: event.channel_type,
|
|
46495
|
+
})];
|
|
46462
46496
|
case 2:
|
|
46463
46497
|
channel_1 = _a.sent();
|
|
46464
46498
|
setChannels(function (channels) { return uniqBy(__spreadArray([channel_1], channels, true), 'cid'); });
|
|
@@ -46489,6 +46523,18 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
46489
46523
|
}, []);
|
|
46490
46524
|
};
|
|
46491
46525
|
|
|
46526
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var MAX_QUERY_CHANNELS_LIMIT = 30;
|
|
46527
|
+
var moveChannelUp = function (_a) {
|
|
46528
|
+
var activeChannel = _a.activeChannel, channels = _a.channels, cid = _a.cid;
|
|
46529
|
+
// get index of channel to move up
|
|
46530
|
+
var channelIndex = channels.findIndex(function (channel) { return channel.cid === cid; });
|
|
46531
|
+
if (!activeChannel && channelIndex <= 0)
|
|
46532
|
+
return channels;
|
|
46533
|
+
// get channel to move up
|
|
46534
|
+
var channel = activeChannel || channels[channelIndex];
|
|
46535
|
+
return uniqBy(__spreadArray([channel], channels, true), 'cid');
|
|
46536
|
+
};
|
|
46537
|
+
|
|
46492
46538
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useMessageNewListener = function (setChannels, lockChannelOrder, allowNewMessagesFromUnfilteredChannels) {
|
|
46493
46539
|
if (lockChannelOrder === void 0) { lockChannelOrder = false; }
|
|
46494
46540
|
if (allowNewMessagesFromUnfilteredChannels === void 0) { allowNewMessagesFromUnfilteredChannels = true; }
|
|
@@ -46536,20 +46582,32 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
46536
46582
|
React$2.useEffect(function () {
|
|
46537
46583
|
var handleEvent = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46538
46584
|
var channel_1;
|
|
46539
|
-
var _a;
|
|
46540
|
-
return __generator(this, function (
|
|
46541
|
-
switch (
|
|
46585
|
+
var _a, _b;
|
|
46586
|
+
return __generator(this, function (_c) {
|
|
46587
|
+
switch (_c.label) {
|
|
46542
46588
|
case 0:
|
|
46543
46589
|
if (!(customHandler && typeof customHandler === 'function')) return [3 /*break*/, 1];
|
|
46544
46590
|
customHandler(setChannels, event);
|
|
46545
46591
|
return [3 /*break*/, 3];
|
|
46546
46592
|
case 1:
|
|
46547
46593
|
if (!(allowNewMessagesFromUnfilteredChannels && ((_a = event.channel) === null || _a === void 0 ? void 0 : _a.type))) return [3 /*break*/, 3];
|
|
46548
|
-
return [4 /*yield*/, getChannel(
|
|
46594
|
+
return [4 /*yield*/, getChannel({
|
|
46595
|
+
client: client,
|
|
46596
|
+
id: event.channel.id,
|
|
46597
|
+
members: (_b = event.channel.members) === null || _b === void 0 ? void 0 : _b.reduce(function (acc, _a) {
|
|
46598
|
+
var user = _a.user, user_id = _a.user_id;
|
|
46599
|
+
var userId = user_id || (user === null || user === void 0 ? void 0 : user.id);
|
|
46600
|
+
if (userId) {
|
|
46601
|
+
acc.push(userId);
|
|
46602
|
+
}
|
|
46603
|
+
return acc;
|
|
46604
|
+
}, []),
|
|
46605
|
+
type: event.channel.type,
|
|
46606
|
+
})];
|
|
46549
46607
|
case 2:
|
|
46550
|
-
channel_1 =
|
|
46608
|
+
channel_1 = _c.sent();
|
|
46551
46609
|
setChannels(function (channels) { return uniqBy(__spreadArray([channel_1], channels, true), 'cid'); });
|
|
46552
|
-
|
|
46610
|
+
_c.label = 3;
|
|
46553
46611
|
case 3: return [2 /*return*/];
|
|
46554
46612
|
}
|
|
46555
46613
|
});
|
|
@@ -46576,7 +46634,11 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
46576
46634
|
return [3 /*break*/, 3];
|
|
46577
46635
|
case 1:
|
|
46578
46636
|
if (!(allowNewMessagesFromUnfilteredChannels && ((_a = event.channel) === null || _a === void 0 ? void 0 : _a.type))) return [3 /*break*/, 3];
|
|
46579
|
-
return [4 /*yield*/, getChannel(
|
|
46637
|
+
return [4 /*yield*/, getChannel({
|
|
46638
|
+
client: client,
|
|
46639
|
+
id: event.channel.id,
|
|
46640
|
+
type: event.channel.type,
|
|
46641
|
+
})];
|
|
46580
46642
|
case 2:
|
|
46581
46643
|
channel_1 = _b.sent();
|
|
46582
46644
|
setChannels(function (channels) { return uniqBy(__spreadArray([channel_1], channels, true), 'cid'); });
|
|
@@ -47345,7 +47407,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM) {
|
|
|
47345
47407
|
|
|
47346
47408
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
|
|
47347
47409
|
|
|
47348
|
-
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.10.
|
|
47410
|
+
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '10.10.2';
|
|
47349
47411
|
|
|
47350
47412
|
window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
|
|
47351
47413
|
var _b, _c;
|