stream-chat-react 11.0.0-rc.7 → 11.0.0-rc.8

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.
@@ -39067,8 +39067,8 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
39067
39067
  return __assign(__assign({}, state), { members: __assign({}, channel.state.members), messages: __spreadArray([], channel.state.messages, true), pinnedMessages: __spreadArray([], channel.state.pinnedMessages, true), read: __assign({}, channel.state.read), watcherCount: channel.state.watcher_count, watchers: __assign({}, channel.state.watchers) });
39068
39068
  }
39069
39069
  case 'initStateFromChannel': {
39070
- var channel = action.channel;
39071
- return __assign(__assign({}, state), { loading: false, members: __assign({}, channel.state.members), messages: __spreadArray([], channel.state.messages, true), pinnedMessages: __spreadArray([], channel.state.pinnedMessages, true), read: __assign({}, channel.state.read), watcherCount: channel.state.watcher_count, watchers: __assign({}, channel.state.watchers) });
39070
+ var channel = action.channel, hasMore = action.hasMore;
39071
+ return __assign(__assign({}, state), { hasMore: hasMore, loading: false, members: __assign({}, channel.state.members), messages: __spreadArray([], channel.state.messages, true), pinnedMessages: __spreadArray([], channel.state.pinnedMessages, true), read: __assign({}, channel.state.read), watcherCount: channel.state.watcher_count, watchers: __assign({}, channel.state.watchers) });
39072
39072
  }
39073
39073
  case 'jumpToLatestMessage': {
39074
39074
  return __assign(__assign({}, state), { hasMoreNewer: false, highlightedMessageId: undefined, loading: false, suppressAutoscroll: false });
@@ -44936,6 +44936,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
44936
44936
  var hasMoreMessagesProbably = function (returnedCountMessages, limit) {
44937
44937
  return returnedCountMessages === limit;
44938
44938
  };
44939
+ // @deprecated
44939
44940
  var hasNotMoreMessages = function (returnedCountMessages, limit) {
44940
44941
  return returnedCountMessages < limit;
44941
44942
  };
@@ -44963,12 +44964,13 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
44963
44964
  * Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
44964
44965
  * @param client
44965
44966
  * @param members
44967
+ * @param options
44966
44968
  * @param type
44967
44969
  * @param id
44968
44970
  * @param channel
44969
44971
  */
44970
44972
  var getChannel = function (_a) {
44971
- var channel = _a.channel, client = _a.client, id = _a.id, members = _a.members, type = _a.type;
44973
+ var channel = _a.channel, client = _a.client, id = _a.id, members = _a.members, options = _a.options, type = _a.type;
44972
44974
  return __awaiter(void 0, void 0, void 0, function () {
44973
44975
  var theChannel, originalCid, queryPromise;
44974
44976
  return __generator(this, function (_b) {
@@ -44993,7 +44995,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
44993
44995
  _b.sent();
44994
44996
  return [3 /*break*/, 4];
44995
44997
  case 2:
44996
- WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch();
44998
+ WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch(options);
44997
44999
  return [4 /*yield*/, WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]];
44998
45000
  case 3:
44999
45001
  _b.sent();
@@ -45125,12 +45127,11 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
45125
45127
  if (!(channel === null || channel === void 0 ? void 0 : channel.cid)) {
45126
45128
  return React__default["default"].createElement("div", { className: className }, EmptyPlaceholder);
45127
45129
  }
45128
- // @ts-ignore
45129
45130
  return React__default["default"].createElement(ChannelInner, __assign({}, props, { channel: channel, key: channel.cid }));
45130
45131
  };
45131
45132
  var ChannelInner = function (props) {
45132
45133
  var _a;
45133
- var acceptedFiles = props.acceptedFiles, activeUnreadHandler = props.activeUnreadHandler, channel = props.channel, children = props.children, doDeleteMessageRequest = props.doDeleteMessageRequest, doMarkReadRequest = props.doMarkReadRequest, doSendMessageRequest = props.doSendMessageRequest, doUpdateMessageRequest = props.doUpdateMessageRequest, _b = props.dragAndDropWindow, dragAndDropWindow = _b === void 0 ? false : _b, enrichURLForPreviewConfig = props.enrichURLForPreviewConfig, _c = props.initializeOnMount, initializeOnMount = _c === void 0 ? true : _c, _d = props.LoadingErrorIndicator, LoadingErrorIndicator$1 = _d === void 0 ? LoadingErrorIndicator : _d, _e = props.LoadingIndicator, LoadingIndicator = _e === void 0 ? LoadingChannel : _e, maxNumberOfFiles = props.maxNumberOfFiles, _f = props.multipleUploads, multipleUploads = _f === void 0 ? true : _f, onMentionsClick = props.onMentionsClick, onMentionsHover = props.onMentionsHover, _g = props.optionalMessageInputProps, optionalMessageInputProps = _g === void 0 ? {} : _g, skipMessageDataMemoization = props.skipMessageDataMemoization;
45134
+ var acceptedFiles = props.acceptedFiles, activeUnreadHandler = props.activeUnreadHandler, channel = props.channel, channelQueryOptions = props.channelQueryOptions, children = props.children, doDeleteMessageRequest = props.doDeleteMessageRequest, doMarkReadRequest = props.doMarkReadRequest, doSendMessageRequest = props.doSendMessageRequest, doUpdateMessageRequest = props.doUpdateMessageRequest, _b = props.dragAndDropWindow, dragAndDropWindow = _b === void 0 ? false : _b, enrichURLForPreviewConfig = props.enrichURLForPreviewConfig, _c = props.initializeOnMount, initializeOnMount = _c === void 0 ? true : _c, _d = props.LoadingErrorIndicator, LoadingErrorIndicator$1 = _d === void 0 ? LoadingErrorIndicator : _d, _e = props.LoadingIndicator, LoadingIndicator = _e === void 0 ? LoadingChannel : _e, maxNumberOfFiles = props.maxNumberOfFiles, _f = props.multipleUploads, multipleUploads = _f === void 0 ? true : _f, onMentionsClick = props.onMentionsClick, onMentionsHover = props.onMentionsHover, _g = props.optionalMessageInputProps, optionalMessageInputProps = _g === void 0 ? {} : _g, skipMessageDataMemoization = props.skipMessageDataMemoization;
45134
45135
  var _h = useChatContext('Channel'), client = _h.client, customClasses = _h.customClasses, latestMessageDatesByChannels = _h.latestMessageDatesByChannels, mutes = _h.mutes, theme = _h.theme;
45135
45136
  var t = useTranslationContext('Channel').t;
45136
45137
  var _j = useChannelContainerClasses({ customClasses: customClasses }), channelClass = _j.channelClass, chatClass = _j.chatClass, chatContainerClass = _j.chatContainerClass, windowsEmojiClass = _j.windowsEmojiClass;
@@ -45223,6 +45224,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
45223
45224
  /**
45224
45225
  * As the channel state is not normalized we re-fetch the channel data. Thus, we avoid having to search for user references in the channel state.
45225
45226
  */
45227
+ // FIXME: we should use channelQueryOptions if they are available
45226
45228
  return [4 /*yield*/, channel.query({
45227
45229
  messages: { id_lt: oldestID, limit: DEFAULT_NEXT_CHANNEL_PAGE_SIZE },
45228
45230
  watchers: { limit: DEFAULT_NEXT_CHANNEL_PAGE_SIZE },
@@ -45231,6 +45233,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
45231
45233
  /**
45232
45234
  * As the channel state is not normalized we re-fetch the channel data. Thus, we avoid having to search for user references in the channel state.
45233
45235
  */
45236
+ // FIXME: we should use channelQueryOptions if they are available
45234
45237
  _m.sent();
45235
45238
  _m.label = 2;
45236
45239
  case 2:
@@ -45249,14 +45252,14 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
45249
45252
  };
45250
45253
  (function () { return __awaiter(void 0, void 0, void 0, function () {
45251
45254
  var members, _i, _a, member, userId, _b, user, user_id, config, e_1;
45252
- var _c;
45253
- return __generator(this, function (_d) {
45254
- switch (_d.label) {
45255
+ var _c, _d, _e;
45256
+ return __generator(this, function (_f) {
45257
+ switch (_f.label) {
45255
45258
  case 0:
45256
45259
  if (!(!channel.initialized && initializeOnMount)) return [3 /*break*/, 4];
45257
- _d.label = 1;
45260
+ _f.label = 1;
45258
45261
  case 1:
45259
- _d.trys.push([1, 3, , 4]);
45262
+ _f.trys.push([1, 3, , 4]);
45260
45263
  members = [];
45261
45264
  if (!channel.id && ((_c = channel.data) === null || _c === void 0 ? void 0 : _c.members)) {
45262
45265
  for (_i = 0, _a = channel.data.members; _i < _a.length; _i++) {
@@ -45274,14 +45277,14 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
45274
45277
  }
45275
45278
  }
45276
45279
  }
45277
- return [4 /*yield*/, getChannel({ channel: channel, client: client, members: members })];
45280
+ return [4 /*yield*/, getChannel({ channel: channel, client: client, members: members, options: channelQueryOptions })];
45278
45281
  case 2:
45279
- _d.sent();
45282
+ _f.sent();
45280
45283
  config = channel.getConfig();
45281
45284
  setChannelConfig(config);
45282
45285
  return [3 /*break*/, 4];
45283
45286
  case 3:
45284
- e_1 = _d.sent();
45287
+ e_1 = _f.sent();
45285
45288
  dispatch({ error: e_1, type: 'setError' });
45286
45289
  errored = true;
45287
45290
  return [3 /*break*/, 4];
@@ -45289,7 +45292,11 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
45289
45292
  done = true;
45290
45293
  originalTitle.current = document.title;
45291
45294
  if (!errored) {
45292
- dispatch({ channel: channel, type: 'initStateFromChannel' });
45295
+ dispatch({
45296
+ channel: channel,
45297
+ hasMore: hasMoreMessagesProbably(channel.state.messages.length, (_e = (_d = channelQueryOptions === null || channelQueryOptions === void 0 ? void 0 : channelQueryOptions.messages) === null || _d === void 0 ? void 0 : _d.limit) !== null && _e !== void 0 ? _e : DEFAULT_INITIAL_CHANNEL_PAGE_SIZE),
45298
+ type: 'initStateFromChannel',
45299
+ });
45293
45300
  if (channel.countUnread() > 0)
45294
45301
  markRead();
45295
45302
  // The more complex sync logic is done in Chat
@@ -45315,7 +45322,13 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
45315
45322
  client.off('user.deleted', handleEvent);
45316
45323
  notificationTimeouts.forEach(clearTimeout);
45317
45324
  };
45318
- }, [channel.cid, doMarkReadRequest, channelConfig === null || channelConfig === void 0 ? void 0 : channelConfig.read_events, initializeOnMount]);
45325
+ }, [
45326
+ channel.cid,
45327
+ channelQueryOptions,
45328
+ doMarkReadRequest,
45329
+ channelConfig === null || channelConfig === void 0 ? void 0 : channelConfig.read_events,
45330
+ initializeOnMount,
45331
+ ]);
45319
45332
  React$2.useEffect(function () {
45320
45333
  var _a;
45321
45334
  if (!state.thread)
@@ -45338,22 +45351,17 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
45338
45351
  var loadMore = function (limit) {
45339
45352
  if (limit === void 0) { limit = DEFAULT_NEXT_CHANNEL_PAGE_SIZE; }
45340
45353
  return __awaiter(void 0, void 0, void 0, function () {
45341
- var oldestMessage, notHasMore, oldestID, perPage, queryResponse, e_2, hasMoreMessages;
45354
+ var oldestMessage, oldestID, perPage, queryResponse, e_2, hasMoreMessages;
45342
45355
  var _a;
45343
45356
  return __generator(this, function (_b) {
45344
45357
  switch (_b.label) {
45345
45358
  case 0:
45346
- if (!online.current || !window.navigator.onLine)
45359
+ if (!online.current || !window.navigator.onLine || !state.hasMore)
45347
45360
  return [2 /*return*/, 0];
45348
45361
  oldestMessage = (_a = state === null || state === void 0 ? void 0 : state.messages) === null || _a === void 0 ? void 0 : _a[0];
45349
45362
  if (state.loadingMore || state.loadingMoreNewer || (oldestMessage === null || oldestMessage === void 0 ? void 0 : oldestMessage.status) !== 'received') {
45350
45363
  return [2 /*return*/, 0];
45351
45364
  }
45352
- notHasMore = hasNotMoreMessages(channel.state.messages.length, DEFAULT_INITIAL_CHANNEL_PAGE_SIZE);
45353
- if (notHasMore) {
45354
- loadMoreFinished(false, channel.state.messages);
45355
- return [2 /*return*/, channel.state.messages.length];
45356
- }
45357
45365
  dispatch({ loadingMore: true, type: 'setLoadingMore' });
45358
45366
  oldestID = oldestMessage === null || oldestMessage === void 0 ? void 0 : oldestMessage.id;
45359
45367
  perPage = limit;
@@ -45633,6 +45641,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
45633
45641
  return __generator(this, function (_b) {
45634
45642
  switch (_b.label) {
45635
45643
  case 0:
45644
+ // FIXME: should prevent loading more, if state.thread.reply_count === channel.state.threads[parentID].length
45636
45645
  if (state.threadLoadingMore || !state.thread)
45637
45646
  return [2 /*return*/];
45638
45647
  dispatch({ type: 'startLoadingThread' });
@@ -47086,7 +47095,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
47086
47095
 
47087
47096
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
47088
47097
 
47089
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '11.0.0-rc.7';
47098
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version$1 = '11.0.0-rc.8';
47090
47099
 
47091
47100
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
47092
47101
  var _b, _c;
@@ -47405,6 +47414,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
47405
47414
  }
47406
47415
  if (isLoading)
47407
47416
  return;
47417
+ // FIXME: this triggers loadMore call when a user types messages in thread and the scroll container container expands
47408
47418
  if (reverseOffset < Number(threshold) &&
47409
47419
  typeof loadPreviousPageFn === 'function' &&
47410
47420
  hasPreviousPageFlag) {
@@ -48122,7 +48132,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
48122
48132
  var active = props.active, children = props.children, className = props.className, type = props.type;
48123
48133
  if (!active)
48124
48134
  return null;
48125
- return (React__default["default"].createElement("div", { "aria-live": 'polite', className: clsx("str-chat__custom-notification notification-".concat(type), "str-chat__notification", className), "data-testid": 'custom-notification' }, children));
48135
+ return (React__default["default"].createElement("div", { "aria-live": 'polite', className: clsx("str-chat__custom-notification notification-".concat(type), "str-chat__notification", "str-chat-react__notification", className), "data-testid": 'custom-notification' }, children));
48126
48136
  };
48127
48137
  var CustomNotification = React__default["default"].memo(UnMemoizedCustomNotification);
48128
48138
 
@@ -50382,6 +50392,7 @@ var StreamChatReact = (function (exports, React$2, streamChat, ReactDOM, Picker)
50382
50392
  var ThreadMessageList = virtualized ? VirtualizedMessageList : MessageList;
50383
50393
  React$2.useEffect(function () {
50384
50394
  if ((thread === null || thread === void 0 ? void 0 : thread.id) && (thread === null || thread === void 0 ? void 0 : thread.reply_count)) {
50395
+ // FIXME: integrators can customize channel query options but cannot customize channel.getReplies() options
50385
50396
  loadMoreThread();
50386
50397
  }
50387
50398
  }, []);