stream-chat-react 13.13.6 → 13.14.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/components/Channel/Channel.js +2 -6
- package/dist/components/ChannelList/ChannelList.js +2 -3
- package/dist/components/ChannelList/hooks/usePaginatedChannels.js +1 -5
- package/dist/components/ChannelList/utils.d.ts +0 -1
- package/dist/components/ChannelList/utils.js +0 -1
- package/dist/components/Chat/hooks/useChat.js +1 -1
- package/dist/components/MessageInput/SendButton.d.ts +1 -2
- package/dist/components/MessageInput/hooks/useMessageInputControls.d.ts +1 -2
- package/dist/constants/limits.d.ts +3 -5
- package/dist/constants/limits.js +3 -5
- package/dist/experimental/index.browser.cjs +6 -5
- package/dist/experimental/index.browser.cjs.map +3 -3
- package/dist/experimental/index.node.cjs +6 -5
- package/dist/experimental/index.node.cjs.map +3 -3
- package/dist/index.browser.cjs +100 -111
- package/dist/index.browser.cjs.map +4 -4
- package/dist/index.node.cjs +100 -112
- package/dist/index.node.cjs.map +4 -4
- package/package.json +1 -2
package/dist/index.node.cjs
CHANGED
|
@@ -389,7 +389,6 @@ __export(src_exports, {
|
|
|
389
389
|
LoadingIndicator: () => LoadingIndicator,
|
|
390
390
|
LoadingIndicatorIcon: () => LoadingIndicatorIcon,
|
|
391
391
|
MAX_MESSAGE_REACTIONS_TO_FETCH: () => MAX_MESSAGE_REACTIONS_TO_FETCH,
|
|
392
|
-
MAX_QUERY_CHANNELS_LIMIT: () => MAX_QUERY_CHANNELS_LIMIT,
|
|
393
392
|
MESSAGE_ACTIONS: () => MESSAGE_ACTIONS,
|
|
394
393
|
MediaContainer: () => MediaContainer,
|
|
395
394
|
MediaRecordingState: () => MediaRecordingState,
|
|
@@ -4340,16 +4339,96 @@ var useMobileNavigation = (channelListRef, navOpen, closeMobileNav) => {
|
|
|
4340
4339
|
|
|
4341
4340
|
// src/components/ChannelList/hooks/usePaginatedChannels.ts
|
|
4342
4341
|
var import_react46 = require("react");
|
|
4343
|
-
var
|
|
4342
|
+
var import_lodash3 = __toESM(require("lodash.uniqby"));
|
|
4343
|
+
var RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS = 5e3;
|
|
4344
|
+
var MIN_RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS = 2e3;
|
|
4345
|
+
var usePaginatedChannels = (client, filters, sort, options, activeChannelHandler, recoveryThrottleIntervalMs = RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS, customQueryChannels) => {
|
|
4346
|
+
const {
|
|
4347
|
+
channelsQueryState: { error, setError, setQueryInProgress }
|
|
4348
|
+
} = useChatContext("usePaginatedChannels");
|
|
4349
|
+
const [channels, setChannels] = (0, import_react46.useState)([]);
|
|
4350
|
+
const [hasNextPage, setHasNextPage] = (0, import_react46.useState)(true);
|
|
4351
|
+
const lastRecoveryTimestamp = (0, import_react46.useRef)(void 0);
|
|
4352
|
+
const recoveryThrottleInterval = recoveryThrottleIntervalMs < MIN_RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS ? MIN_RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS : recoveryThrottleIntervalMs ?? RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS;
|
|
4353
|
+
const filterString = (0, import_react46.useMemo)(() => JSON.stringify(filters), [filters]);
|
|
4354
|
+
const sortString = (0, import_react46.useMemo)(() => JSON.stringify(sort), [sort]);
|
|
4355
|
+
const queryChannels = async (queryType = "load-more") => {
|
|
4356
|
+
setError(null);
|
|
4357
|
+
if (queryType === "reload") {
|
|
4358
|
+
setChannels([]);
|
|
4359
|
+
}
|
|
4360
|
+
setQueryInProgress(queryType);
|
|
4361
|
+
try {
|
|
4362
|
+
if (customQueryChannels) {
|
|
4363
|
+
await customQueryChannels({
|
|
4364
|
+
currentChannels: channels,
|
|
4365
|
+
queryType,
|
|
4366
|
+
setChannels,
|
|
4367
|
+
setHasNextPage
|
|
4368
|
+
});
|
|
4369
|
+
} else {
|
|
4370
|
+
const offset = queryType === "reload" ? 0 : channels.length;
|
|
4371
|
+
const newOptions = {
|
|
4372
|
+
offset,
|
|
4373
|
+
...options
|
|
4374
|
+
};
|
|
4375
|
+
const channelQueryResponse = await client.queryChannels(
|
|
4376
|
+
filters,
|
|
4377
|
+
sort || {},
|
|
4378
|
+
newOptions
|
|
4379
|
+
);
|
|
4380
|
+
const newChannels = queryType === "reload" ? channelQueryResponse : (0, import_lodash3.default)([...channels, ...channelQueryResponse], "cid");
|
|
4381
|
+
setChannels(newChannels);
|
|
4382
|
+
setHasNextPage(channelQueryResponse.length >= (newOptions.limit ?? 1));
|
|
4383
|
+
if (!offset && activeChannelHandler) {
|
|
4384
|
+
activeChannelHandler(newChannels, setChannels);
|
|
4385
|
+
}
|
|
4386
|
+
}
|
|
4387
|
+
} catch (error2) {
|
|
4388
|
+
console.warn(error2);
|
|
4389
|
+
setError(error2);
|
|
4390
|
+
}
|
|
4391
|
+
setQueryInProgress(null);
|
|
4392
|
+
};
|
|
4393
|
+
const throttleRecover = (0, import_react46.useCallback)(() => {
|
|
4394
|
+
const now = Date.now();
|
|
4395
|
+
const isFirstRecovery = !lastRecoveryTimestamp.current;
|
|
4396
|
+
const timeElapsedSinceLastRecoveryMs = lastRecoveryTimestamp.current ? now - lastRecoveryTimestamp.current : 0;
|
|
4397
|
+
if (!isFirstRecovery && timeElapsedSinceLastRecoveryMs < recoveryThrottleInterval && !error) {
|
|
4398
|
+
return;
|
|
4399
|
+
}
|
|
4400
|
+
lastRecoveryTimestamp.current = now;
|
|
4401
|
+
queryChannels("reload");
|
|
4402
|
+
}, [error, queryChannels, recoveryThrottleInterval]);
|
|
4403
|
+
const loadNextPage = () => queryChannels();
|
|
4404
|
+
(0, import_react46.useEffect)(() => {
|
|
4405
|
+
if (client.recoverStateOnReconnect) return;
|
|
4406
|
+
const { unsubscribe } = client.on("connection.recovered", throttleRecover);
|
|
4407
|
+
return () => {
|
|
4408
|
+
unsubscribe();
|
|
4409
|
+
};
|
|
4410
|
+
}, [client, throttleRecover]);
|
|
4411
|
+
(0, import_react46.useEffect)(() => {
|
|
4412
|
+
queryChannels("reload");
|
|
4413
|
+
}, [filterString, sortString]);
|
|
4414
|
+
return {
|
|
4415
|
+
channels,
|
|
4416
|
+
hasNextPage,
|
|
4417
|
+
loadNextPage,
|
|
4418
|
+
setChannels
|
|
4419
|
+
};
|
|
4420
|
+
};
|
|
4421
|
+
|
|
4422
|
+
// src/components/ChannelList/hooks/useChannelListShape.ts
|
|
4423
|
+
var import_react47 = require("react");
|
|
4344
4424
|
|
|
4345
4425
|
// src/components/ChannelList/utils.ts
|
|
4346
|
-
var
|
|
4347
|
-
var MAX_QUERY_CHANNELS_LIMIT = 30;
|
|
4426
|
+
var import_lodash4 = __toESM(require("lodash.uniqby"));
|
|
4348
4427
|
var moveChannelUp = ({ activeChannel, channels, cid }) => {
|
|
4349
4428
|
const channelIndex = channels.findIndex((channel2) => channel2.cid === cid);
|
|
4350
4429
|
if (!activeChannel && channelIndex <= 0) return channels;
|
|
4351
4430
|
const channel = activeChannel || channels[channelIndex];
|
|
4352
|
-
return (0,
|
|
4431
|
+
return (0, import_lodash4.default)([channel, ...channels], "cid");
|
|
4353
4432
|
};
|
|
4354
4433
|
function findLastPinnedChannelIndex({ channels }) {
|
|
4355
4434
|
let lastPinnedChannelIndex = null;
|
|
@@ -4437,99 +4516,7 @@ var isChannelArchived = (channel) => {
|
|
|
4437
4516
|
return typeof membership.archived_at === "string";
|
|
4438
4517
|
};
|
|
4439
4518
|
|
|
4440
|
-
// src/constants/limits.ts
|
|
4441
|
-
var DEFAULT_INITIAL_CHANNEL_PAGE_SIZE = 25;
|
|
4442
|
-
var DEFAULT_NEXT_CHANNEL_PAGE_SIZE = 100;
|
|
4443
|
-
var DEFAULT_JUMP_TO_PAGE_SIZE = 100;
|
|
4444
|
-
var DEFAULT_THREAD_PAGE_SIZE = 50;
|
|
4445
|
-
var DEFAULT_LOAD_PAGE_SCROLL_THRESHOLD = 250;
|
|
4446
|
-
var DEFAULT_UPLOAD_SIZE_LIMIT_BYTES = 100 * 1024 * 1024;
|
|
4447
|
-
var DEFAULT_HIGHLIGHT_DURATION = 500;
|
|
4448
|
-
|
|
4449
|
-
// src/components/ChannelList/hooks/usePaginatedChannels.ts
|
|
4450
|
-
var RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS = 5e3;
|
|
4451
|
-
var MIN_RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS = 2e3;
|
|
4452
|
-
var usePaginatedChannels = (client, filters, sort, options, activeChannelHandler, recoveryThrottleIntervalMs = RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS, customQueryChannels) => {
|
|
4453
|
-
const {
|
|
4454
|
-
channelsQueryState: { error, setError, setQueryInProgress }
|
|
4455
|
-
} = useChatContext("usePaginatedChannels");
|
|
4456
|
-
const [channels, setChannels] = (0, import_react46.useState)([]);
|
|
4457
|
-
const [hasNextPage, setHasNextPage] = (0, import_react46.useState)(true);
|
|
4458
|
-
const lastRecoveryTimestamp = (0, import_react46.useRef)(void 0);
|
|
4459
|
-
const recoveryThrottleInterval = recoveryThrottleIntervalMs < MIN_RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS ? MIN_RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS : recoveryThrottleIntervalMs ?? RECOVER_LOADED_CHANNELS_THROTTLE_INTERVAL_IN_MS;
|
|
4460
|
-
const filterString = (0, import_react46.useMemo)(() => JSON.stringify(filters), [filters]);
|
|
4461
|
-
const sortString = (0, import_react46.useMemo)(() => JSON.stringify(sort), [sort]);
|
|
4462
|
-
const queryChannels = async (queryType = "load-more") => {
|
|
4463
|
-
setError(null);
|
|
4464
|
-
if (queryType === "reload") {
|
|
4465
|
-
setChannels([]);
|
|
4466
|
-
}
|
|
4467
|
-
setQueryInProgress(queryType);
|
|
4468
|
-
try {
|
|
4469
|
-
if (customQueryChannels) {
|
|
4470
|
-
await customQueryChannels({
|
|
4471
|
-
currentChannels: channels,
|
|
4472
|
-
queryType,
|
|
4473
|
-
setChannels,
|
|
4474
|
-
setHasNextPage
|
|
4475
|
-
});
|
|
4476
|
-
} else {
|
|
4477
|
-
const offset = queryType === "reload" ? 0 : channels.length;
|
|
4478
|
-
const newOptions = {
|
|
4479
|
-
limit: options?.limit ?? MAX_QUERY_CHANNELS_LIMIT,
|
|
4480
|
-
message_limit: options?.message_limit ?? DEFAULT_INITIAL_CHANNEL_PAGE_SIZE,
|
|
4481
|
-
offset,
|
|
4482
|
-
...options
|
|
4483
|
-
};
|
|
4484
|
-
const channelQueryResponse = await client.queryChannels(
|
|
4485
|
-
filters,
|
|
4486
|
-
sort || {},
|
|
4487
|
-
newOptions
|
|
4488
|
-
);
|
|
4489
|
-
const newChannels = queryType === "reload" ? channelQueryResponse : (0, import_lodash4.default)([...channels, ...channelQueryResponse], "cid");
|
|
4490
|
-
setChannels(newChannels);
|
|
4491
|
-
setHasNextPage(channelQueryResponse.length >= newOptions.limit);
|
|
4492
|
-
if (!offset && activeChannelHandler) {
|
|
4493
|
-
activeChannelHandler(newChannels, setChannels);
|
|
4494
|
-
}
|
|
4495
|
-
}
|
|
4496
|
-
} catch (error2) {
|
|
4497
|
-
console.warn(error2);
|
|
4498
|
-
setError(error2);
|
|
4499
|
-
}
|
|
4500
|
-
setQueryInProgress(null);
|
|
4501
|
-
};
|
|
4502
|
-
const throttleRecover = (0, import_react46.useCallback)(() => {
|
|
4503
|
-
const now = Date.now();
|
|
4504
|
-
const isFirstRecovery = !lastRecoveryTimestamp.current;
|
|
4505
|
-
const timeElapsedSinceLastRecoveryMs = lastRecoveryTimestamp.current ? now - lastRecoveryTimestamp.current : 0;
|
|
4506
|
-
if (!isFirstRecovery && timeElapsedSinceLastRecoveryMs < recoveryThrottleInterval && !error) {
|
|
4507
|
-
return;
|
|
4508
|
-
}
|
|
4509
|
-
lastRecoveryTimestamp.current = now;
|
|
4510
|
-
queryChannels("reload");
|
|
4511
|
-
}, [error, queryChannels, recoveryThrottleInterval]);
|
|
4512
|
-
const loadNextPage = () => queryChannels();
|
|
4513
|
-
(0, import_react46.useEffect)(() => {
|
|
4514
|
-
if (client.recoverStateOnReconnect) return;
|
|
4515
|
-
const { unsubscribe } = client.on("connection.recovered", throttleRecover);
|
|
4516
|
-
return () => {
|
|
4517
|
-
unsubscribe();
|
|
4518
|
-
};
|
|
4519
|
-
}, [client, throttleRecover]);
|
|
4520
|
-
(0, import_react46.useEffect)(() => {
|
|
4521
|
-
queryChannels("reload");
|
|
4522
|
-
}, [filterString, sortString]);
|
|
4523
|
-
return {
|
|
4524
|
-
channels,
|
|
4525
|
-
hasNextPage,
|
|
4526
|
-
loadNextPage,
|
|
4527
|
-
setChannels
|
|
4528
|
-
};
|
|
4529
|
-
};
|
|
4530
|
-
|
|
4531
4519
|
// src/components/ChannelList/hooks/useChannelListShape.ts
|
|
4532
|
-
var import_react47 = require("react");
|
|
4533
4520
|
var shared = ({
|
|
4534
4521
|
customHandler,
|
|
4535
4522
|
event,
|
|
@@ -5973,7 +5960,7 @@ var UnMemoizedChannelList = (props) => {
|
|
|
5973
5960
|
searchControllerStateSelector
|
|
5974
5961
|
);
|
|
5975
5962
|
const activeChannelHandler = async (channels2, setChannels2) => {
|
|
5976
|
-
if (!channels2.length
|
|
5963
|
+
if (!channels2.length) {
|
|
5977
5964
|
return;
|
|
5978
5965
|
}
|
|
5979
5966
|
if (customActiveChannel) {
|
|
@@ -24855,6 +24842,15 @@ var usePollOptionVotesPagination = ({
|
|
|
24855
24842
|
var import_clsx30 = __toESM(require("clsx"));
|
|
24856
24843
|
var import_lodash13 = __toESM(require("lodash.debounce"));
|
|
24857
24844
|
var import_react137 = __toESM(require("react"));
|
|
24845
|
+
|
|
24846
|
+
// src/constants/limits.ts
|
|
24847
|
+
var DEFAULT_NEXT_CHANNEL_PAGE_SIZE = 25;
|
|
24848
|
+
var DEFAULT_JUMP_TO_PAGE_SIZE = 25;
|
|
24849
|
+
var DEFAULT_THREAD_PAGE_SIZE = 25;
|
|
24850
|
+
var DEFAULT_LOAD_PAGE_SCROLL_THRESHOLD = 250;
|
|
24851
|
+
var DEFAULT_HIGHLIGHT_DURATION = 500;
|
|
24852
|
+
|
|
24853
|
+
// src/components/InfiniteScrollPaginator/InfiniteScrollPaginator.tsx
|
|
24858
24854
|
var mousewheelListener = (event) => {
|
|
24859
24855
|
if (event instanceof WheelEvent && event.deltaY === 1) {
|
|
24860
24856
|
event.preventDefault();
|
|
@@ -37774,8 +37770,7 @@ var useLiveLocationSharingManager = ({
|
|
|
37774
37770
|
var import_react286 = __toESM(require("react"));
|
|
37775
37771
|
var import_clsx70 = __toESM(require("clsx"));
|
|
37776
37772
|
var import_lodash19 = __toESM(require("lodash.debounce"));
|
|
37777
|
-
var import_lodash20 = __toESM(require("lodash.
|
|
37778
|
-
var import_lodash21 = __toESM(require("lodash.throttle"));
|
|
37773
|
+
var import_lodash20 = __toESM(require("lodash.throttle"));
|
|
37779
37774
|
var import_stream_chat18 = require("stream-chat");
|
|
37780
37775
|
|
|
37781
37776
|
// src/components/Channel/channelState.ts
|
|
@@ -38358,7 +38353,7 @@ var ChannelInner = (props) => {
|
|
|
38358
38353
|
activeUnreadHandler,
|
|
38359
38354
|
allowConcurrentAudioPlayback,
|
|
38360
38355
|
channel,
|
|
38361
|
-
channelQueryOptions
|
|
38356
|
+
channelQueryOptions,
|
|
38362
38357
|
children,
|
|
38363
38358
|
doDeleteMessageRequest,
|
|
38364
38359
|
doMarkReadRequest,
|
|
@@ -38372,12 +38367,6 @@ var ChannelInner = (props) => {
|
|
|
38372
38367
|
onMentionsHover,
|
|
38373
38368
|
skipMessageDataMemoization
|
|
38374
38369
|
} = props;
|
|
38375
|
-
const channelQueryOptions = (0, import_react286.useMemo)(
|
|
38376
|
-
() => (0, import_lodash20.default)(propChannelQueryOptions, {
|
|
38377
|
-
messages: { limit: DEFAULT_INITIAL_CHANNEL_PAGE_SIZE }
|
|
38378
|
-
}),
|
|
38379
|
-
[propChannelQueryOptions]
|
|
38380
|
-
);
|
|
38381
38370
|
const { client, customClasses, latestMessageDatesByChannels, mutes, searchController } = useChatContext("Channel");
|
|
38382
38371
|
const { t } = useTranslationContext("Channel");
|
|
38383
38372
|
const chatContainerClass = getChatContainerClass(customClasses?.chatContainer);
|
|
@@ -38408,7 +38397,7 @@ var ChannelInner = (props) => {
|
|
|
38408
38397
|
null
|
|
38409
38398
|
);
|
|
38410
38399
|
const channelCapabilitiesArray = channel.data?.own_capabilities;
|
|
38411
|
-
const throttledCopyStateFromChannel = (0,
|
|
38400
|
+
const throttledCopyStateFromChannel = (0, import_lodash20.default)(
|
|
38412
38401
|
() => dispatch({ channel, type: "copyStateFromChannelOnEvent" }),
|
|
38413
38402
|
500,
|
|
38414
38403
|
{
|
|
@@ -38417,14 +38406,14 @@ var ChannelInner = (props) => {
|
|
|
38417
38406
|
}
|
|
38418
38407
|
);
|
|
38419
38408
|
const setChannelUnreadUiState = (0, import_react286.useMemo)(
|
|
38420
|
-
() => (0,
|
|
38409
|
+
() => (0, import_lodash20.default)(_setChannelUnreadUiState, 200, {
|
|
38421
38410
|
leading: true,
|
|
38422
38411
|
trailing: false
|
|
38423
38412
|
}),
|
|
38424
38413
|
[]
|
|
38425
38414
|
);
|
|
38426
38415
|
const markRead = (0, import_react286.useMemo)(
|
|
38427
|
-
() => (0,
|
|
38416
|
+
() => (0, import_lodash20.default)(
|
|
38428
38417
|
async (options) => {
|
|
38429
38418
|
const { updateChannelUiUnreadState = true } = options ?? {};
|
|
38430
38419
|
if (channel.disconnected || !channelConfig?.read_events) {
|
|
@@ -39289,7 +39278,7 @@ var useChat = ({
|
|
|
39289
39278
|
};
|
|
39290
39279
|
(0, import_react289.useEffect)(() => {
|
|
39291
39280
|
if (!client) return;
|
|
39292
|
-
const version = "13.
|
|
39281
|
+
const version = "13.14.1";
|
|
39293
39282
|
const userAgent = client.getUserAgent();
|
|
39294
39283
|
if (!userAgent.includes("stream-chat-react")) {
|
|
39295
39284
|
client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
|
|
@@ -39630,7 +39619,6 @@ var Window = import_react294.default.memo(UnMemoizedWindow);
|
|
|
39630
39619
|
LoadingIndicator,
|
|
39631
39620
|
LoadingIndicatorIcon,
|
|
39632
39621
|
MAX_MESSAGE_REACTIONS_TO_FETCH,
|
|
39633
|
-
MAX_QUERY_CHANNELS_LIMIT,
|
|
39634
39622
|
MESSAGE_ACTIONS,
|
|
39635
39623
|
MediaContainer,
|
|
39636
39624
|
MediaRecordingState,
|