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.
package/dist/index.cjs.js CHANGED
@@ -26309,8 +26309,8 @@ var channelReducer = function (state, action) {
26309
26309
  return icons.__assign(icons.__assign({}, state), { members: icons.__assign({}, channel.state.members), messages: icons.__spreadArray([], channel.state.messages, true), pinnedMessages: icons.__spreadArray([], channel.state.pinnedMessages, true), read: icons.__assign({}, channel.state.read), watcherCount: channel.state.watcher_count, watchers: icons.__assign({}, channel.state.watchers) });
26310
26310
  }
26311
26311
  case 'initStateFromChannel': {
26312
- var channel = action.channel;
26313
- return icons.__assign(icons.__assign({}, state), { loading: false, members: icons.__assign({}, channel.state.members), messages: icons.__spreadArray([], channel.state.messages, true), pinnedMessages: icons.__spreadArray([], channel.state.pinnedMessages, true), read: icons.__assign({}, channel.state.read), watcherCount: channel.state.watcher_count, watchers: icons.__assign({}, channel.state.watchers) });
26312
+ var channel = action.channel, hasMore = action.hasMore;
26313
+ return icons.__assign(icons.__assign({}, state), { hasMore: hasMore, loading: false, members: icons.__assign({}, channel.state.members), messages: icons.__spreadArray([], channel.state.messages, true), pinnedMessages: icons.__spreadArray([], channel.state.pinnedMessages, true), read: icons.__assign({}, channel.state.read), watcherCount: channel.state.watcher_count, watchers: icons.__assign({}, channel.state.watchers) });
26314
26314
  }
26315
26315
  case 'jumpToLatestMessage': {
26316
26316
  return icons.__assign(icons.__assign({}, state), { hasMoreNewer: false, highlightedMessageId: undefined, loading: false, suppressAutoscroll: false });
@@ -29856,6 +29856,7 @@ var getGroupStyles = function (message, previousMessage, nextMessage, noGroupByU
29856
29856
  var hasMoreMessagesProbably = function (returnedCountMessages, limit) {
29857
29857
  return returnedCountMessages === limit;
29858
29858
  };
29859
+ // @deprecated
29859
29860
  var hasNotMoreMessages = function (returnedCountMessages, limit) {
29860
29861
  return returnedCountMessages < limit;
29861
29862
  };
@@ -29883,12 +29884,13 @@ var WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL = {};
29883
29884
  * Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
29884
29885
  * @param client
29885
29886
  * @param members
29887
+ * @param options
29886
29888
  * @param type
29887
29889
  * @param id
29888
29890
  * @param channel
29889
29891
  */
29890
29892
  var getChannel = function (_a) {
29891
- var channel = _a.channel, client = _a.client, id = _a.id, members = _a.members, type = _a.type;
29893
+ var channel = _a.channel, client = _a.client, id = _a.id, members = _a.members, options = _a.options, type = _a.type;
29892
29894
  return icons.__awaiter(void 0, void 0, void 0, function () {
29893
29895
  var theChannel, originalCid, queryPromise;
29894
29896
  return icons.__generator(this, function (_b) {
@@ -29913,7 +29915,7 @@ var getChannel = function (_a) {
29913
29915
  _b.sent();
29914
29916
  return [3 /*break*/, 4];
29915
29917
  case 2:
29916
- WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch();
29918
+ WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch(options);
29917
29919
  return [4 /*yield*/, WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]];
29918
29920
  case 3:
29919
29921
  _b.sent();
@@ -30045,12 +30047,11 @@ var UnMemoizedChannel = function (props) {
30045
30047
  if (!(channel === null || channel === void 0 ? void 0 : channel.cid)) {
30046
30048
  return React__default["default"].createElement("div", { className: className }, EmptyPlaceholder);
30047
30049
  }
30048
- // @ts-ignore
30049
30050
  return React__default["default"].createElement(ChannelInner, icons.__assign({}, props, { channel: channel, key: channel.cid }));
30050
30051
  };
30051
30052
  var ChannelInner = function (props) {
30052
30053
  var _a;
30053
- 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;
30054
+ 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;
30054
30055
  var _h = icons.useChatContext('Channel'), client = _h.client, customClasses = _h.customClasses, latestMessageDatesByChannels = _h.latestMessageDatesByChannels, mutes = _h.mutes, theme = _h.theme;
30055
30056
  var t = icons.useTranslationContext('Channel').t;
30056
30057
  var _j = useChannelContainerClasses({ customClasses: customClasses }), channelClass = _j.channelClass, chatClass = _j.chatClass, chatContainerClass = _j.chatContainerClass, windowsEmojiClass = _j.windowsEmojiClass;
@@ -30143,6 +30144,7 @@ var ChannelInner = function (props) {
30143
30144
  /**
30144
30145
  * 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.
30145
30146
  */
30147
+ // FIXME: we should use channelQueryOptions if they are available
30146
30148
  return [4 /*yield*/, channel.query({
30147
30149
  messages: { id_lt: oldestID, limit: DEFAULT_NEXT_CHANNEL_PAGE_SIZE },
30148
30150
  watchers: { limit: DEFAULT_NEXT_CHANNEL_PAGE_SIZE },
@@ -30151,6 +30153,7 @@ var ChannelInner = function (props) {
30151
30153
  /**
30152
30154
  * 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.
30153
30155
  */
30156
+ // FIXME: we should use channelQueryOptions if they are available
30154
30157
  _m.sent();
30155
30158
  _m.label = 2;
30156
30159
  case 2:
@@ -30169,14 +30172,14 @@ var ChannelInner = function (props) {
30169
30172
  };
30170
30173
  (function () { return icons.__awaiter(void 0, void 0, void 0, function () {
30171
30174
  var members, _i, _a, member, userId, _b, user, user_id, config, e_1;
30172
- var _c;
30173
- return icons.__generator(this, function (_d) {
30174
- switch (_d.label) {
30175
+ var _c, _d, _e;
30176
+ return icons.__generator(this, function (_f) {
30177
+ switch (_f.label) {
30175
30178
  case 0:
30176
30179
  if (!(!channel.initialized && initializeOnMount)) return [3 /*break*/, 4];
30177
- _d.label = 1;
30180
+ _f.label = 1;
30178
30181
  case 1:
30179
- _d.trys.push([1, 3, , 4]);
30182
+ _f.trys.push([1, 3, , 4]);
30180
30183
  members = [];
30181
30184
  if (!channel.id && ((_c = channel.data) === null || _c === void 0 ? void 0 : _c.members)) {
30182
30185
  for (_i = 0, _a = channel.data.members; _i < _a.length; _i++) {
@@ -30194,14 +30197,14 @@ var ChannelInner = function (props) {
30194
30197
  }
30195
30198
  }
30196
30199
  }
30197
- return [4 /*yield*/, getChannel({ channel: channel, client: client, members: members })];
30200
+ return [4 /*yield*/, getChannel({ channel: channel, client: client, members: members, options: channelQueryOptions })];
30198
30201
  case 2:
30199
- _d.sent();
30202
+ _f.sent();
30200
30203
  config = channel.getConfig();
30201
30204
  setChannelConfig(config);
30202
30205
  return [3 /*break*/, 4];
30203
30206
  case 3:
30204
- e_1 = _d.sent();
30207
+ e_1 = _f.sent();
30205
30208
  dispatch({ error: e_1, type: 'setError' });
30206
30209
  errored = true;
30207
30210
  return [3 /*break*/, 4];
@@ -30209,7 +30212,11 @@ var ChannelInner = function (props) {
30209
30212
  done = true;
30210
30213
  originalTitle.current = document.title;
30211
30214
  if (!errored) {
30212
- dispatch({ channel: channel, type: 'initStateFromChannel' });
30215
+ dispatch({
30216
+ channel: channel,
30217
+ 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),
30218
+ type: 'initStateFromChannel',
30219
+ });
30213
30220
  if (channel.countUnread() > 0)
30214
30221
  markRead();
30215
30222
  // The more complex sync logic is done in Chat
@@ -30235,7 +30242,13 @@ var ChannelInner = function (props) {
30235
30242
  client.off('user.deleted', handleEvent);
30236
30243
  notificationTimeouts.forEach(clearTimeout);
30237
30244
  };
30238
- }, [channel.cid, doMarkReadRequest, channelConfig === null || channelConfig === void 0 ? void 0 : channelConfig.read_events, initializeOnMount]);
30245
+ }, [
30246
+ channel.cid,
30247
+ channelQueryOptions,
30248
+ doMarkReadRequest,
30249
+ channelConfig === null || channelConfig === void 0 ? void 0 : channelConfig.read_events,
30250
+ initializeOnMount,
30251
+ ]);
30239
30252
  React.useEffect(function () {
30240
30253
  var _a;
30241
30254
  if (!state.thread)
@@ -30258,22 +30271,17 @@ var ChannelInner = function (props) {
30258
30271
  var loadMore = function (limit) {
30259
30272
  if (limit === void 0) { limit = DEFAULT_NEXT_CHANNEL_PAGE_SIZE; }
30260
30273
  return icons.__awaiter(void 0, void 0, void 0, function () {
30261
- var oldestMessage, notHasMore, oldestID, perPage, queryResponse, e_2, hasMoreMessages;
30274
+ var oldestMessage, oldestID, perPage, queryResponse, e_2, hasMoreMessages;
30262
30275
  var _a;
30263
30276
  return icons.__generator(this, function (_b) {
30264
30277
  switch (_b.label) {
30265
30278
  case 0:
30266
- if (!online.current || !window.navigator.onLine)
30279
+ if (!online.current || !window.navigator.onLine || !state.hasMore)
30267
30280
  return [2 /*return*/, 0];
30268
30281
  oldestMessage = (_a = state === null || state === void 0 ? void 0 : state.messages) === null || _a === void 0 ? void 0 : _a[0];
30269
30282
  if (state.loadingMore || state.loadingMoreNewer || (oldestMessage === null || oldestMessage === void 0 ? void 0 : oldestMessage.status) !== 'received') {
30270
30283
  return [2 /*return*/, 0];
30271
30284
  }
30272
- notHasMore = hasNotMoreMessages(channel.state.messages.length, DEFAULT_INITIAL_CHANNEL_PAGE_SIZE);
30273
- if (notHasMore) {
30274
- loadMoreFinished(false, channel.state.messages);
30275
- return [2 /*return*/, channel.state.messages.length];
30276
- }
30277
30285
  dispatch({ loadingMore: true, type: 'setLoadingMore' });
30278
30286
  oldestID = oldestMessage === null || oldestMessage === void 0 ? void 0 : oldestMessage.id;
30279
30287
  perPage = limit;
@@ -30553,6 +30561,7 @@ var ChannelInner = function (props) {
30553
30561
  return icons.__generator(this, function (_b) {
30554
30562
  switch (_b.label) {
30555
30563
  case 0:
30564
+ // FIXME: should prevent loading more, if state.thread.reply_count === channel.state.threads[parentID].length
30556
30565
  if (state.threadLoadingMore || !state.thread)
30557
30566
  return [2 /*return*/];
30558
30567
  dispatch({ type: 'startLoadingThread' });
@@ -31990,7 +31999,7 @@ var UnMemoizedChannelList = function (props) {
31990
31999
  */
31991
32000
  var ChannelList = React__default["default"].memo(UnMemoizedChannelList);
31992
32001
 
31993
- var version = '11.0.0-rc.7';
32002
+ var version = '11.0.0-rc.8';
31994
32003
 
31995
32004
  var useChat = function (_a) {
31996
32005
  var _b, _c;
@@ -32297,6 +32306,7 @@ var InfiniteScroll = function (props) {
32297
32306
  }
32298
32307
  if (isLoading)
32299
32308
  return;
32309
+ // FIXME: this triggers loadMore call when a user types messages in thread and the scroll container container expands
32300
32310
  if (reverseOffset < Number(threshold) &&
32301
32311
  typeof loadPreviousPageFn === 'function' &&
32302
32312
  hasPreviousPageFlag) {
@@ -33004,7 +33014,7 @@ var UnMemoizedCustomNotification = function (props) {
33004
33014
  var active = props.active, children = props.children, className = props.className, type = props.type;
33005
33015
  if (!active)
33006
33016
  return null;
33007
- 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));
33017
+ 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));
33008
33018
  };
33009
33019
  var CustomNotification = React__default["default"].memo(UnMemoizedCustomNotification);
33010
33020
 
@@ -34045,6 +34055,7 @@ var ThreadInner = function (props) {
34045
34055
  var ThreadMessageList = virtualized ? VirtualizedMessageList : MessageList;
34046
34056
  React.useEffect(function () {
34047
34057
  if ((thread === null || thread === void 0 ? void 0 : thread.id) && (thread === null || thread === void 0 ? void 0 : thread.reply_count)) {
34058
+ // FIXME: integrators can customize channel query options but cannot customize channel.getReplies() options
34048
34059
  loadMoreThread();
34049
34060
  }
34050
34061
  }, []);
@@ -1,20 +1,22 @@
1
- import type { Channel, StreamChat } from 'stream-chat';
1
+ import type { Channel, ChannelQueryOptions, StreamChat } from 'stream-chat';
2
2
  import type { DefaultStreamChatGenerics } from '../types/types';
3
3
  declare type GetChannelParams<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
4
4
  client: StreamChat<StreamChatGenerics>;
5
5
  channel?: Channel<StreamChatGenerics>;
6
6
  id?: string;
7
7
  members?: string[];
8
+ options?: ChannelQueryOptions<StreamChatGenerics>;
8
9
  type?: string;
9
10
  };
10
11
  /**
11
12
  * Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
12
13
  * @param client
13
14
  * @param members
15
+ * @param options
14
16
  * @param type
15
17
  * @param id
16
18
  * @param channel
17
19
  */
18
- export declare const getChannel: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ channel, client, id, members, type, }: GetChannelParams<StreamChatGenerics>) => Promise<Channel<StreamChatGenerics>>;
20
+ export declare const getChannel: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ channel, client, id, members, options, type, }: GetChannelParams<StreamChatGenerics>) => Promise<Channel<StreamChatGenerics>>;
19
21
  export {};
20
22
  //# sourceMappingURL=getChannel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getChannel.d.ts","sourceRoot":"","sources":["../../src/utils/getChannel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA2B,UAAU,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAWhE,aAAK,gBAAgB,CACnB,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,MAAM,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AACF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,2MAuCtB,CAAC"}
1
+ {"version":3,"file":"getChannel.d.ts","sourceRoot":"","sources":["../../src/utils/getChannel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,EAEnB,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAWhE,aAAK,gBAAgB,CACnB,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,MAAM,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AACF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,oNAwCtB,CAAC"}
@@ -8,12 +8,13 @@ var WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL = {};
8
8
  * Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
9
9
  * @param client
10
10
  * @param members
11
+ * @param options
11
12
  * @param type
12
13
  * @param id
13
14
  * @param channel
14
15
  */
15
16
  export var getChannel = function (_a) {
16
- var channel = _a.channel, client = _a.client, id = _a.id, members = _a.members, type = _a.type;
17
+ var channel = _a.channel, client = _a.client, id = _a.id, members = _a.members, options = _a.options, type = _a.type;
17
18
  return __awaiter(void 0, void 0, void 0, function () {
18
19
  var theChannel, originalCid, queryPromise;
19
20
  return __generator(this, function (_b) {
@@ -38,7 +39,7 @@ export var getChannel = function (_a) {
38
39
  _b.sent();
39
40
  return [3 /*break*/, 4];
40
41
  case 2:
41
- WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch();
42
+ WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid] = theChannel.watch(options);
42
43
  return [4 /*yield*/, WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL[originalCid]];
43
44
  case 3:
44
45
  _b.sent();
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "11.0.0-rc.7";
1
+ export declare const version = "11.0.0-rc.8";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export var version = '11.0.0-rc.7';
1
+ export var version = '11.0.0-rc.8';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat-react",
3
- "version": "11.0.0-rc.7",
3
+ "version": "11.0.0-rc.8",
4
4
  "description": "React components to create chat conversations or livestream style chat",
5
5
  "author": "GetStream",
6
6
  "homepage": "https://getstream.io/chat/",