stream-chat-react-native-core 6.0.2 → 6.1.0-beta.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.
Files changed (216) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/components/Channel/Channel.js +371 -279
  3. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  4. package/lib/commonjs/components/Channel/hooks/useChannelDataState.js +8 -0
  5. package/lib/commonjs/components/Channel/hooks/useChannelDataState.js.map +1 -1
  6. package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js +10 -1
  7. package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
  8. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +4 -0
  9. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  10. package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js +161 -69
  11. package/lib/commonjs/components/Channel/hooks/useMessageListPagination.js.map +1 -1
  12. package/lib/commonjs/components/Channel/hooks/useTargetedMessage.js +10 -0
  13. package/lib/commonjs/components/Channel/hooks/useTargetedMessage.js.map +1 -1
  14. package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js +81 -54
  15. package/lib/commonjs/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
  16. package/lib/commonjs/components/Message/Message.js +6 -0
  17. package/lib/commonjs/components/Message/Message.js.map +1 -1
  18. package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js +117 -79
  19. package/lib/commonjs/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
  20. package/lib/commonjs/components/Message/hooks/useMessageActions.js +32 -14
  21. package/lib/commonjs/components/Message/hooks/useMessageActions.js.map +1 -1
  22. package/lib/commonjs/components/Message/utils/messageActions.js +4 -0
  23. package/lib/commonjs/components/Message/utils/messageActions.js.map +1 -1
  24. package/lib/commonjs/components/MessageList/InlineUnreadIndicator.js +19 -55
  25. package/lib/commonjs/components/MessageList/InlineUnreadIndicator.js.map +1 -1
  26. package/lib/commonjs/components/MessageList/MessageList.js +249 -211
  27. package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
  28. package/lib/commonjs/components/MessageList/UnreadMessagesNotification.js +148 -0
  29. package/lib/commonjs/components/MessageList/UnreadMessagesNotification.js.map +1 -0
  30. package/lib/commonjs/components/MessageMenu/MessageActionListItem.js.map +1 -1
  31. package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
  32. package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
  33. package/lib/commonjs/contexts/themeContext/utils/theme.js +7 -1
  34. package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
  35. package/lib/commonjs/i18n/en.json +2 -0
  36. package/lib/commonjs/i18n/es.json +2 -0
  37. package/lib/commonjs/i18n/fr.json +2 -0
  38. package/lib/commonjs/i18n/he.json +2 -0
  39. package/lib/commonjs/i18n/hi.json +2 -0
  40. package/lib/commonjs/i18n/it.json +2 -0
  41. package/lib/commonjs/i18n/ja.json +2 -0
  42. package/lib/commonjs/i18n/ko.json +2 -0
  43. package/lib/commonjs/i18n/nl.json +2 -0
  44. package/lib/commonjs/i18n/pt-br.json +2 -0
  45. package/lib/commonjs/i18n/ru.json +2 -0
  46. package/lib/commonjs/i18n/tr.json +2 -0
  47. package/lib/commonjs/icons/UnreadIndicator.js +30 -0
  48. package/lib/commonjs/icons/UnreadIndicator.js.map +1 -0
  49. package/lib/commonjs/icons/index.js +11 -0
  50. package/lib/commonjs/icons/index.js.map +1 -1
  51. package/lib/commonjs/store/SqliteClient.js +1 -1
  52. package/lib/commonjs/store/schema.js +1 -0
  53. package/lib/commonjs/store/schema.js.map +1 -1
  54. package/lib/commonjs/types/types.js.map +1 -1
  55. package/lib/commonjs/utils/utils.js +35 -1
  56. package/lib/commonjs/utils/utils.js.map +1 -1
  57. package/lib/commonjs/version.json +1 -1
  58. package/lib/module/components/Channel/Channel.js +371 -279
  59. package/lib/module/components/Channel/Channel.js.map +1 -1
  60. package/lib/module/components/Channel/hooks/useChannelDataState.js +8 -0
  61. package/lib/module/components/Channel/hooks/useChannelDataState.js.map +1 -1
  62. package/lib/module/components/Channel/hooks/useCreateChannelContext.js +10 -1
  63. package/lib/module/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
  64. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +4 -0
  65. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  66. package/lib/module/components/Channel/hooks/useMessageListPagination.js +161 -69
  67. package/lib/module/components/Channel/hooks/useMessageListPagination.js.map +1 -1
  68. package/lib/module/components/Channel/hooks/useTargetedMessage.js +10 -0
  69. package/lib/module/components/Channel/hooks/useTargetedMessage.js.map +1 -1
  70. package/lib/module/components/Chat/hooks/handleEventToSyncDB.js +81 -54
  71. package/lib/module/components/Chat/hooks/handleEventToSyncDB.js.map +1 -1
  72. package/lib/module/components/Message/Message.js +6 -0
  73. package/lib/module/components/Message/Message.js.map +1 -1
  74. package/lib/module/components/Message/hooks/useMessageActionHandlers.js +117 -79
  75. package/lib/module/components/Message/hooks/useMessageActionHandlers.js.map +1 -1
  76. package/lib/module/components/Message/hooks/useMessageActions.js +32 -14
  77. package/lib/module/components/Message/hooks/useMessageActions.js.map +1 -1
  78. package/lib/module/components/Message/utils/messageActions.js +4 -0
  79. package/lib/module/components/Message/utils/messageActions.js.map +1 -1
  80. package/lib/module/components/MessageList/InlineUnreadIndicator.js +19 -55
  81. package/lib/module/components/MessageList/InlineUnreadIndicator.js.map +1 -1
  82. package/lib/module/components/MessageList/MessageList.js +249 -211
  83. package/lib/module/components/MessageList/MessageList.js.map +1 -1
  84. package/lib/module/components/MessageList/UnreadMessagesNotification.js +148 -0
  85. package/lib/module/components/MessageList/UnreadMessagesNotification.js.map +1 -0
  86. package/lib/module/components/MessageMenu/MessageActionListItem.js.map +1 -1
  87. package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
  88. package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
  89. package/lib/module/contexts/themeContext/utils/theme.js +7 -1
  90. package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
  91. package/lib/module/i18n/en.json +2 -0
  92. package/lib/module/i18n/es.json +2 -0
  93. package/lib/module/i18n/fr.json +2 -0
  94. package/lib/module/i18n/he.json +2 -0
  95. package/lib/module/i18n/hi.json +2 -0
  96. package/lib/module/i18n/it.json +2 -0
  97. package/lib/module/i18n/ja.json +2 -0
  98. package/lib/module/i18n/ko.json +2 -0
  99. package/lib/module/i18n/nl.json +2 -0
  100. package/lib/module/i18n/pt-br.json +2 -0
  101. package/lib/module/i18n/ru.json +2 -0
  102. package/lib/module/i18n/tr.json +2 -0
  103. package/lib/module/icons/UnreadIndicator.js +30 -0
  104. package/lib/module/icons/UnreadIndicator.js.map +1 -0
  105. package/lib/module/icons/index.js +11 -0
  106. package/lib/module/icons/index.js.map +1 -1
  107. package/lib/module/store/SqliteClient.js +1 -1
  108. package/lib/module/store/schema.js +1 -0
  109. package/lib/module/store/schema.js.map +1 -1
  110. package/lib/module/types/types.js.map +1 -1
  111. package/lib/module/utils/utils.js +35 -1
  112. package/lib/module/utils/utils.js.map +1 -1
  113. package/lib/module/version.json +1 -1
  114. package/lib/typescript/components/Channel/Channel.d.ts +15 -3
  115. package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
  116. package/lib/typescript/components/Channel/hooks/useChannelDataState.d.ts +1 -0
  117. package/lib/typescript/components/Channel/hooks/useChannelDataState.d.ts.map +1 -1
  118. package/lib/typescript/components/Channel/hooks/useCreateChannelContext.d.ts +1 -1
  119. package/lib/typescript/components/Channel/hooks/useCreateChannelContext.d.ts.map +1 -1
  120. package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +4 -2
  121. package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts.map +1 -1
  122. package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts +4 -1
  123. package/lib/typescript/components/Channel/hooks/useMessageListPagination.d.ts.map +1 -1
  124. package/lib/typescript/components/Channel/hooks/useTargetedMessage.d.ts +2 -1
  125. package/lib/typescript/components/Channel/hooks/useTargetedMessage.d.ts.map +1 -1
  126. package/lib/typescript/components/Chat/hooks/handleEventToSyncDB.d.ts.map +1 -1
  127. package/lib/typescript/components/Message/Message.d.ts +2 -1
  128. package/lib/typescript/components/Message/Message.d.ts.map +1 -1
  129. package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts +2 -1
  130. package/lib/typescript/components/Message/hooks/useMessageActionHandlers.d.ts.map +1 -1
  131. package/lib/typescript/components/Message/hooks/useMessageActions.d.ts +3 -2
  132. package/lib/typescript/components/Message/hooks/useMessageActions.d.ts.map +1 -1
  133. package/lib/typescript/components/Message/hooks/useMessageData.d.ts +1 -1
  134. package/lib/typescript/components/Message/utils/messageActions.d.ts +2 -1
  135. package/lib/typescript/components/Message/utils/messageActions.d.ts.map +1 -1
  136. package/lib/typescript/components/MessageList/InlineUnreadIndicator.d.ts.map +1 -1
  137. package/lib/typescript/components/MessageList/MessageList.d.ts +1 -1
  138. package/lib/typescript/components/MessageList/MessageList.d.ts.map +1 -1
  139. package/lib/typescript/components/MessageList/UnreadMessagesNotification.d.ts +13 -0
  140. package/lib/typescript/components/MessageList/UnreadMessagesNotification.d.ts.map +1 -0
  141. package/lib/typescript/components/MessageMenu/MessageActionListItem.d.ts +2 -2
  142. package/lib/typescript/components/MessageMenu/MessageActionListItem.d.ts.map +1 -1
  143. package/lib/typescript/contexts/channelContext/ChannelContext.d.ts +25 -8
  144. package/lib/typescript/contexts/channelContext/ChannelContext.d.ts.map +1 -1
  145. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +5 -0
  146. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts.map +1 -1
  147. package/lib/typescript/contexts/themeContext/utils/theme.d.ts +6 -0
  148. package/lib/typescript/contexts/themeContext/utils/theme.d.ts.map +1 -1
  149. package/lib/typescript/i18n/en.json +2 -0
  150. package/lib/typescript/i18n/es.json +2 -0
  151. package/lib/typescript/i18n/fr.json +2 -0
  152. package/lib/typescript/i18n/he.json +2 -0
  153. package/lib/typescript/i18n/hi.json +2 -0
  154. package/lib/typescript/i18n/it.json +2 -0
  155. package/lib/typescript/i18n/ja.json +2 -0
  156. package/lib/typescript/i18n/ko.json +2 -0
  157. package/lib/typescript/i18n/nl.json +2 -0
  158. package/lib/typescript/i18n/pt-br.json +2 -0
  159. package/lib/typescript/i18n/ru.json +2 -0
  160. package/lib/typescript/i18n/tr.json +2 -0
  161. package/lib/typescript/icons/UnreadIndicator.d.ts +8 -0
  162. package/lib/typescript/icons/UnreadIndicator.d.ts.map +1 -0
  163. package/lib/typescript/icons/index.d.ts +1 -0
  164. package/lib/typescript/icons/index.d.ts.map +1 -1
  165. package/lib/typescript/store/mappers/mapStorableToChannel.d.ts +1 -1
  166. package/lib/typescript/store/schema.d.ts +1 -0
  167. package/lib/typescript/store/schema.d.ts.map +1 -1
  168. package/lib/typescript/types/types.d.ts +2 -1
  169. package/lib/typescript/types/types.d.ts.map +1 -1
  170. package/lib/typescript/utils/i18n/Streami18n.d.ts +2 -0
  171. package/lib/typescript/utils/i18n/Streami18n.d.ts.map +1 -1
  172. package/lib/typescript/utils/utils.d.ts +21 -1
  173. package/lib/typescript/utils/utils.d.ts.map +1 -1
  174. package/package.json +1 -1
  175. package/src/components/Channel/Channel.tsx +102 -24
  176. package/src/components/Channel/__tests__/Channel.test.js +109 -58
  177. package/src/components/Channel/__tests__/ownCapabilities.test.js +26 -0
  178. package/src/components/Channel/__tests__/useMessageListPagination.test.js +234 -37
  179. package/src/components/Channel/hooks/useChannelDataState.ts +8 -0
  180. package/src/components/Channel/hooks/useCreateChannelContext.ts +11 -0
  181. package/src/components/Channel/hooks/useCreateMessagesContext.ts +4 -0
  182. package/src/components/Channel/hooks/useMessageListPagination.tsx +134 -64
  183. package/src/components/Channel/hooks/useTargetedMessage.ts +9 -2
  184. package/src/components/Chat/hooks/handleEventToSyncDB.ts +23 -1
  185. package/src/components/Message/Message.tsx +8 -0
  186. package/src/components/Message/hooks/useMessageActionHandlers.ts +54 -40
  187. package/src/components/Message/hooks/useMessageActions.tsx +31 -14
  188. package/src/components/Message/utils/messageActions.ts +6 -0
  189. package/src/components/MessageList/InlineUnreadIndicator.tsx +17 -26
  190. package/src/components/MessageList/MessageList.tsx +197 -231
  191. package/src/components/MessageList/UnreadMessagesNotification.tsx +107 -0
  192. package/src/components/MessageList/__tests__/MessageList.test.js +213 -0
  193. package/src/components/MessageMenu/MessageActionListItem.tsx +2 -1
  194. package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +669 -679
  195. package/src/contexts/channelContext/ChannelContext.tsx +35 -9
  196. package/src/contexts/messagesContext/MessagesContext.tsx +7 -2
  197. package/src/contexts/themeContext/utils/theme.ts +12 -0
  198. package/src/i18n/en.json +2 -0
  199. package/src/i18n/es.json +2 -0
  200. package/src/i18n/fr.json +2 -0
  201. package/src/i18n/he.json +2 -0
  202. package/src/i18n/hi.json +2 -0
  203. package/src/i18n/it.json +2 -0
  204. package/src/i18n/ja.json +2 -0
  205. package/src/i18n/ko.json +2 -0
  206. package/src/i18n/nl.json +2 -0
  207. package/src/i18n/pt-br.json +2 -0
  208. package/src/i18n/ru.json +2 -0
  209. package/src/i18n/tr.json +2 -0
  210. package/src/icons/UnreadIndicator.tsx +18 -0
  211. package/src/icons/index.ts +1 -0
  212. package/src/store/SqliteClient.ts +1 -1
  213. package/src/store/schema.ts +2 -0
  214. package/src/types/types.ts +5 -2
  215. package/src/utils/utils.ts +61 -1
  216. package/src/version.json +1 -1
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.reactionData = exports.Channel = void 0;
7
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
8
7
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
12
  var _react = _interopRequireWildcard(require("react"));
@@ -15,7 +15,6 @@ var _debounce = _interopRequireDefault(require("lodash/debounce"));
15
15
  var _omit = _interopRequireDefault(require("lodash/omit"));
16
16
  var _throttle = _interopRequireDefault(require("lodash/throttle"));
17
17
  var _mimeTypes = require("mime-types");
18
- var _streamChat = require("stream-chat");
19
18
  var _useChannelDataState2 = require("./hooks/useChannelDataState");
20
19
  var _useCreateChannelContext = require("./hooks/useCreateChannelContext");
21
20
  var _useCreateInputMessageInputContext = require("./hooks/useCreateInputMessageInputContext");
@@ -117,6 +116,7 @@ var _ScrollToBottomButton = require("../MessageList/ScrollToBottomButton");
117
116
  var _StickyHeader = require("../MessageList/StickyHeader");
118
117
  var _TypingIndicator = require("../MessageList/TypingIndicator");
119
118
  var _TypingIndicatorContainer = require("../MessageList/TypingIndicatorContainer");
119
+ var _UnreadMessagesNotification = require("../MessageList/UnreadMessagesNotification");
120
120
  var _MessageActionList = require("../MessageMenu/MessageActionList");
121
121
  var _MessageActionListItem = require("../MessageMenu/MessageActionListItem");
122
122
  var _MessageMenu = require("../MessageMenu/MessageMenu");
@@ -126,8 +126,10 @@ var _MessageUserReactionsAvatar = require("../MessageMenu/MessageUserReactionsAv
126
126
  var _MessageUserReactionsItem = require("../MessageMenu/MessageUserReactionsItem");
127
127
  var _Reply = require("../Reply/Reply");
128
128
  var _jsxRuntime = require("react/jsx-runtime");
129
- var _excluded = ["attachments", "mentioned_users", "parent_id", "poll", "poll_id", "text"],
130
- _excluded2 = ["channel_mutes", "devices", "mutes"];
129
+ var _excluded = ["user"],
130
+ _excluded2 = ["user"],
131
+ _excluded3 = ["attachments", "mentioned_users", "parent_id", "poll", "poll_id", "text"],
132
+ _excluded4 = ["channel_mutes", "devices", "mutes"];
131
133
  var _this = this,
132
134
  _jsxFileName = "/home/runner/work/stream-chat-react-native/stream-chat-react-native/package/src/components/Channel/Channel.tsx";
133
135
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -167,7 +169,7 @@ var debounceOptions = {
167
169
  trailing: true
168
170
  };
169
171
  var ChannelWithContext = function ChannelWithContext(props) {
170
- var _channel$getConfig, _channel$data, _ref17, _channelState$members, _channelState$read, _ref18, _channelMessagesState3, _channelState$typing, _channelMessagesState4;
172
+ var _channel$getConfig, _channel$data, _ref19, _channelState$members, _channelState$read, _ref20, _channelMessagesState3, _channelState$typing, _channelMessagesState4;
171
173
  var additionalKeyboardAvoidingViewProps = props.additionalKeyboardAvoidingViewProps,
172
174
  additionalPressableProps = props.additionalPressableProps,
173
175
  additionalTextInputProps = props.additionalTextInputProps,
@@ -273,6 +275,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
273
275
  handleDelete = props.handleDelete,
274
276
  handleEdit = props.handleEdit,
275
277
  handleFlag = props.handleFlag,
278
+ handleMarkUnread = props.handleMarkUnread,
276
279
  handleMute = props.handleMute,
277
280
  handlePinMessage = props.handlePinMessage,
278
281
  handleQuotedReply = props.handleQuotedReply,
@@ -332,6 +335,8 @@ var ChannelWithContext = function ChannelWithContext(props) {
332
335
  loadingMoreProp = props.loadingMore,
333
336
  loadingMoreRecentProp = props.loadingMoreRecent,
334
337
  markdownRules = props.markdownRules,
338
+ _props$markReadOnMoun = props.markReadOnMount,
339
+ markReadOnMount = _props$markReadOnMoun === void 0 ? true : _props$markReadOnMoun,
335
340
  maxMessageLengthProp = props.maxMessageLength,
336
341
  _props$maxNumberOfFil = props.maxNumberOfFiles,
337
342
  maxNumberOfFiles = _props$maxNumberOfFil === void 0 ? 10 : _props$maxNumberOfFil,
@@ -451,6 +456,8 @@ var ChannelWithContext = function ChannelWithContext(props) {
451
456
  TypingIndicator = _props$TypingIndicato === void 0 ? _TypingIndicator.TypingIndicator : _props$TypingIndicato,
452
457
  _props$TypingIndicato2 = props.TypingIndicatorContainer,
453
458
  TypingIndicatorContainer = _props$TypingIndicato2 === void 0 ? _TypingIndicatorContainer.TypingIndicatorContainer : _props$TypingIndicato2,
459
+ _props$UnreadMessages = props.UnreadMessagesNotification,
460
+ UnreadMessagesNotification = _props$UnreadMessages === void 0 ? _UnreadMessagesNotification.UnreadMessagesNotification : _props$UnreadMessages,
454
461
  _props$UploadProgress = props.UploadProgressIndicator,
455
462
  UploadProgressIndicator = _props$UploadProgress === void 0 ? _UploadProgressIndicator.UploadProgressIndicator : _props$UploadProgress,
456
463
  _props$UrlPreview = props.UrlPreview,
@@ -496,8 +503,13 @@ var ChannelWithContext = function ChannelWithContext(props) {
496
503
  _useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
497
504
  threadLoadingMore = _useState16[0],
498
505
  setThreadLoadingMore = _useState16[1];
506
+ var _useState17 = (0, _react.useState)(undefined),
507
+ _useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
508
+ channelUnreadState = _useState18[0],
509
+ setChannelUnreadState = _useState18[1];
499
510
  var syncingChannelRef = (0, _react.useRef)(false);
500
511
  var _useTargetedMessage = (0, _useTargetedMessage2.useTargetedMessage)(),
512
+ highlightedMessageId = _useTargetedMessage.highlightedMessageId,
501
513
  setTargetedMessage = _useTargetedMessage.setTargetedMessage,
502
514
  targetedMessage = _useTargetedMessage.targetedMessage;
503
515
  var uploadAbortControllerRef = (0, _react.useRef)(new Map());
@@ -506,6 +518,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
506
518
  var _useChannelDataState = (0, _useChannelDataState2.useChannelDataState)(channel),
507
519
  copyStateFromChannel = _useChannelDataState.copyStateFromChannel,
508
520
  initStateFromChannel = _useChannelDataState.initStateFromChannel,
521
+ setRead = _useChannelDataState.setRead,
509
522
  setTyping = _useChannelDataState.setTyping,
510
523
  channelState = _useChannelDataState.state;
511
524
  var _useMessageListPagina = (0, _useMessageListPagination.useMessageListPagination)({
@@ -544,6 +557,21 @@ var ChannelWithContext = function ChannelWithContext(props) {
544
557
  }
545
558
  }
546
559
  }
560
+ if (event.type === 'notification.mark_unread') {
561
+ setChannelUnreadState(function (prev) {
562
+ var _event$unread_message;
563
+ if (!(event.last_read_at && event.user)) return prev;
564
+ return {
565
+ first_unread_message_id: event.first_unread_message_id,
566
+ last_read: new Date(event.last_read_at),
567
+ last_read_message_id: event.last_read_message_id,
568
+ unread_messages: (_event$unread_message = event.unread_messages) != null ? _event$unread_message : 0
569
+ };
570
+ });
571
+ }
572
+ if (event.type === 'channel.truncated' && event.cid === channel.cid) {
573
+ setChannelUnreadState(undefined);
574
+ }
547
575
  if (channel && channel.initialized) {
548
576
  copyChannelState();
549
577
  }
@@ -553,66 +581,85 @@ var ChannelWithContext = function ChannelWithContext(props) {
553
581
  var listener;
554
582
  var initChannel = function () {
555
583
  var _ref = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
556
- var errored;
584
+ var _client$user;
585
+ var unreadCount, errored, _channel$state$read$c, user, ownReadState, _channel$state$read$c2, _user, _ownReadState;
557
586
  return _regenerator["default"].wrap(function _callee$(_context) {
558
587
  while (1) switch (_context.prev = _context.next) {
559
588
  case 0:
589
+ setLastRead(new Date());
590
+ unreadCount = channel.countUnread();
560
591
  if (!(!channel || !shouldSyncChannel || channel.offlineMode)) {
561
- _context.next = 2;
592
+ _context.next = 4;
562
593
  break;
563
594
  }
564
595
  return _context.abrupt("return");
565
- case 2:
596
+ case 4:
566
597
  errored = false;
567
598
  if (!(!channel.initialized || !channel.state.isUpToDate)) {
568
- _context.next = 14;
599
+ _context.next = 16;
569
600
  break;
570
601
  }
571
- _context.prev = 4;
572
- _context.next = 7;
602
+ _context.prev = 6;
603
+ _context.next = 9;
573
604
  return channel == null ? void 0 : channel.watch();
574
- case 7:
575
- _context.next = 14;
576
- break;
577
605
  case 9:
578
- _context.prev = 9;
579
- _context.t0 = _context["catch"](4);
606
+ _context.next = 16;
607
+ break;
608
+ case 11:
609
+ _context.prev = 11;
610
+ _context.t0 = _context["catch"](6);
580
611
  console.warn('Channel watch request failed with error:', _context.t0);
581
612
  setError(true);
582
613
  errored = true;
583
- case 14:
614
+ case 16:
584
615
  if (!errored) {
585
616
  initStateFromChannel(channel);
586
617
  loadInitialMessagesStateFromChannel(channel, channel.state.messagePagination.hasPrev);
587
618
  }
619
+ if ((_client$user = client.user) != null && _client$user.id && channel.state.read[client.user.id]) {
620
+ _channel$state$read$c = channel.state.read[client.user.id], user = _channel$state$read$c.user, ownReadState = (0, _objectWithoutProperties2["default"])(_channel$state$read$c, _excluded);
621
+ setChannelUnreadState(ownReadState);
622
+ }
588
623
  if (!messageId) {
589
- _context.next = 20;
624
+ _context.next = 23;
590
625
  break;
591
626
  }
592
- _context.next = 18;
627
+ _context.next = 21;
593
628
  return loadChannelAroundMessage({
594
629
  messageId: messageId,
595
630
  setTargetedMessage: setTargetedMessage
596
631
  });
597
- case 18:
598
- _context.next = 23;
632
+ case 21:
633
+ _context.next = 27;
599
634
  break;
600
- case 20:
601
- if (!(initialScrollToFirstUnreadMessage && channel.countUnread() > scrollToFirstUnreadThreshold)) {
602
- _context.next = 23;
635
+ case 23:
636
+ if (!(initialScrollToFirstUnreadMessage && client.user && unreadCount > scrollToFirstUnreadThreshold)) {
637
+ _context.next = 27;
603
638
  break;
604
639
  }
605
- _context.next = 23;
640
+ _channel$state$read$c2 = channel.state.read[client.user.id], _user = _channel$state$read$c2.user, _ownReadState = (0, _objectWithoutProperties2["default"])(_channel$state$read$c2, _excluded2);
641
+ _context.next = 27;
606
642
  return loadChannelAtFirstUnreadMessage({
643
+ channelUnreadState: _ownReadState,
644
+ setChannelUnreadState: setChannelUnreadState,
607
645
  setTargetedMessage: setTargetedMessage
608
646
  });
609
- case 23:
647
+ case 27:
648
+ if (!(unreadCount > 0 && markReadOnMount)) {
649
+ _context.next = 30;
650
+ break;
651
+ }
652
+ _context.next = 30;
653
+ return markRead({
654
+ updateChannelUnreadState: false
655
+ });
656
+ case 30:
610
657
  listener = channel.on(handleEvent);
611
- case 24:
658
+ case 31:
612
659
  case "end":
613
660
  return _context.stop();
614
661
  }
615
- }, _callee, null, [[4, 9]]);
662
+ }, _callee, null, [[6, 11]]);
616
663
  }));
617
664
  return function initChannel() {
618
665
  return _ref.apply(this, arguments);
@@ -637,12 +684,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
637
684
  }, [channel == null ? void 0 : channel.cid, client]);
638
685
  (0, _react.useEffect)(function () {
639
686
  var handleEvent = function handleEvent(event) {
640
- if (channel.cid === event.cid) copyChannelState();
687
+ if (channel.cid === event.cid) setRead(channel);
641
688
  };
642
689
  var _client$on2 = client.on('notification.mark_read', handleEvent),
643
690
  unsubscribe = _client$on2.unsubscribe;
644
691
  return unsubscribe;
645
- }, [channel.cid, client, copyChannelState]);
692
+ }, [channel, client, setRead]);
646
693
  var threadPropsExists = !!threadProps;
647
694
  (0, _react.useEffect)(function () {
648
695
  if (threadProps && shouldSyncChannel) {
@@ -666,86 +713,125 @@ var ChannelWithContext = function ChannelWithContext(props) {
666
713
  }
667
714
  }, [thread == null ? void 0 : thread.id, channelId]);
668
715
  (0, _useAppStateListener.useAppStateListener)(undefined, handleAppBackground);
669
- var markRead = (0, _react.useRef)((0, _throttle["default"])(function () {
670
- if (!channel || channel != null && channel.disconnected || !(clientChannelConfig != null && clientChannelConfig.read_events)) {
671
- return;
672
- }
673
- if (doMarkReadRequest) {
674
- doMarkReadRequest(channel);
675
- } else {
676
- (0, _streamChat.logChatPromiseExecution)(channel.markRead(), 'mark read');
677
- }
678
- }, defaultThrottleInterval, throttleOptions)).current;
679
- var reloadThread = function () {
680
- var _ref2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2() {
681
- var parentID, limit, queryResponse, updatedHasMore, updatedThreadMessages, _yield$channel$getMes, messages, _messages, threadMessage, formattedMessage;
716
+ var markRead = (0, _throttle["default"])(function () {
717
+ var _ref2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(options) {
718
+ var _ref3, _ref3$updateChannelUn, updateChannelUnreadState, response;
682
719
  return _regenerator["default"].wrap(function _callee2$(_context2) {
683
720
  while (1) switch (_context2.prev = _context2.next) {
684
721
  case 0:
685
- if (!(!channel || !(thread != null && thread.id))) {
686
- _context2.next = 2;
722
+ _ref3 = options != null ? options : {}, _ref3$updateChannelUn = _ref3.updateChannelUnreadState, updateChannelUnreadState = _ref3$updateChannelUn === void 0 ? true : _ref3$updateChannelUn;
723
+ if (!(!channel || channel != null && channel.disconnected || !(clientChannelConfig != null && clientChannelConfig.read_events))) {
724
+ _context2.next = 3;
687
725
  break;
688
726
  }
689
727
  return _context2.abrupt("return");
728
+ case 3:
729
+ if (!doMarkReadRequest) {
730
+ _context2.next = 7;
731
+ break;
732
+ }
733
+ doMarkReadRequest(channel, updateChannelUnreadState ? setChannelUnreadState : undefined);
734
+ _context2.next = 17;
735
+ break;
736
+ case 7:
737
+ _context2.prev = 7;
738
+ _context2.next = 10;
739
+ return channel.markRead();
740
+ case 10:
741
+ response = _context2.sent;
742
+ if (updateChannelUnreadState && response && lastRead) {
743
+ setChannelUnreadState({
744
+ last_read: lastRead,
745
+ last_read_message_id: response == null ? void 0 : response.event.last_read_message_id,
746
+ unread_messages: 0
747
+ });
748
+ }
749
+ _context2.next = 17;
750
+ break;
751
+ case 14:
752
+ _context2.prev = 14;
753
+ _context2.t0 = _context2["catch"](7);
754
+ console.log('Error marking channel as read:', _context2.t0);
755
+ case 17:
756
+ case "end":
757
+ return _context2.stop();
758
+ }
759
+ }, _callee2, null, [[7, 14]]);
760
+ }));
761
+ return function (_x) {
762
+ return _ref2.apply(this, arguments);
763
+ };
764
+ }(), defaultThrottleInterval, throttleOptions);
765
+ var reloadThread = function () {
766
+ var _ref4 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3() {
767
+ var parentID, limit, queryResponse, updatedHasMore, updatedThreadMessages, _yield$channel$getMes, messages, _messages, threadMessage, formattedMessage;
768
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
769
+ while (1) switch (_context3.prev = _context3.next) {
770
+ case 0:
771
+ if (!(!channel || !(thread != null && thread.id))) {
772
+ _context3.next = 2;
773
+ break;
774
+ }
775
+ return _context3.abrupt("return");
690
776
  case 2:
691
777
  setThreadLoadingMore(true);
692
- _context2.prev = 3;
778
+ _context3.prev = 3;
693
779
  parentID = thread.id;
694
780
  limit = 50;
695
781
  channel.state.threads[parentID] = [];
696
- _context2.next = 9;
782
+ _context3.next = 9;
697
783
  return channel.getReplies(parentID, {
698
784
  limit: limit
699
785
  });
700
786
  case 9:
701
- queryResponse = _context2.sent;
787
+ queryResponse = _context3.sent;
702
788
  updatedHasMore = queryResponse.messages.length === limit;
703
789
  updatedThreadMessages = channel.state.threads[parentID] || [];
704
790
  loadMoreThreadFinished(updatedHasMore, updatedThreadMessages);
705
- _context2.next = 15;
791
+ _context3.next = 15;
706
792
  return channel.getMessagesById([parentID]);
707
793
  case 15:
708
- _yield$channel$getMes = _context2.sent;
794
+ _yield$channel$getMes = _context3.sent;
709
795
  messages = _yield$channel$getMes.messages;
710
796
  _messages = (0, _slicedToArray2["default"])(messages, 1), threadMessage = _messages[0];
711
797
  if (threadMessage && !threadInstance) {
712
798
  formattedMessage = channel.state.formatMessage(threadMessage);
713
799
  setThread(formattedMessage);
714
800
  }
715
- _context2.next = 27;
801
+ _context3.next = 27;
716
802
  break;
717
803
  case 21:
718
- _context2.prev = 21;
719
- _context2.t0 = _context2["catch"](3);
720
- console.warn('Thread loading request failed with error', _context2.t0);
721
- if (_context2.t0 instanceof Error) {
722
- setError(_context2.t0);
804
+ _context3.prev = 21;
805
+ _context3.t0 = _context3["catch"](3);
806
+ console.warn('Thread loading request failed with error', _context3.t0);
807
+ if (_context3.t0 instanceof Error) {
808
+ setError(_context3.t0);
723
809
  } else {
724
810
  setError(true);
725
811
  }
726
812
  setThreadLoadingMore(false);
727
- throw _context2.t0;
813
+ throw _context3.t0;
728
814
  case 27:
729
815
  case "end":
730
- return _context2.stop();
816
+ return _context3.stop();
731
817
  }
732
- }, _callee2, null, [[3, 21]]);
818
+ }, _callee3, null, [[3, 21]]);
733
819
  }));
734
820
  return function reloadThread() {
735
- return _ref2.apply(this, arguments);
821
+ return _ref4.apply(this, arguments);
736
822
  };
737
823
  }();
738
824
  var resyncChannel = function () {
739
- var _ref3 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3() {
825
+ var _ref5 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4() {
740
826
  var parseMessage, _channelMessagesState, failedMessages, failedThreadMessages;
741
- return _regenerator["default"].wrap(function _callee3$(_context3) {
742
- while (1) switch (_context3.prev = _context3.next) {
827
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
828
+ while (1) switch (_context4.prev = _context4.next) {
743
829
  case 0:
744
830
  if (!(!channel || syncingChannelRef.current)) {
745
- _context3.next = 2;
831
+ _context4.next = 2;
746
832
  break;
747
833
  }
748
- return _context3.abrupt("return");
834
+ return _context4.abrupt("return");
749
835
  case 2:
750
836
  syncingChannelRef.current = true;
751
837
  setError(false);
@@ -757,9 +843,9 @@ var ChannelWithContext = function ChannelWithContext(props) {
757
843
  updated_at: (_message$updated_at = message.updated_at) == null ? void 0 : _message$updated_at.toString()
758
844
  });
759
845
  };
760
- _context3.prev = 5;
846
+ _context4.prev = 5;
761
847
  if (thread) {
762
- _context3.next = 12;
848
+ _context4.next = 12;
763
849
  break;
764
850
  }
765
851
  copyChannelState();
@@ -769,10 +855,10 @@ var ChannelWithContext = function ChannelWithContext(props) {
769
855
  if (failedMessages != null && failedMessages.length) {
770
856
  channel.state.addMessagesSorted(failedMessages);
771
857
  }
772
- _context3.next = 16;
858
+ _context4.next = 16;
773
859
  break;
774
860
  case 12:
775
- _context3.next = 14;
861
+ _context4.next = 14;
776
862
  return reloadThread();
777
863
  case 14:
778
864
  failedThreadMessages = thread ? threadMessages.filter(function (message) {
@@ -783,13 +869,13 @@ var ChannelWithContext = function ChannelWithContext(props) {
783
869
  setThreadMessages((0, _toConsumableArray2["default"])(channel.state.threads[thread.id]));
784
870
  }
785
871
  case 16:
786
- _context3.next = 21;
872
+ _context4.next = 21;
787
873
  break;
788
874
  case 18:
789
- _context3.prev = 18;
790
- _context3.t0 = _context3["catch"](5);
791
- if (_context3.t0 instanceof Error) {
792
- setError(_context3.t0);
875
+ _context4.prev = 18;
876
+ _context4.t0 = _context4["catch"](5);
877
+ if (_context4.t0 instanceof Error) {
878
+ setError(_context4.t0);
793
879
  } else {
794
880
  setError(true);
795
881
  }
@@ -797,12 +883,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
797
883
  syncingChannelRef.current = false;
798
884
  case 22:
799
885
  case "end":
800
- return _context3.stop();
886
+ return _context4.stop();
801
887
  }
802
- }, _callee3, null, [[5, 18]]);
888
+ }, _callee4, null, [[5, 18]]);
803
889
  }));
804
890
  return function resyncChannel() {
805
- return _ref3.apply(this, arguments);
891
+ return _ref5.apply(this, arguments);
806
892
  };
807
893
  }();
808
894
  var resyncChannelRef = (0, _react.useRef)(resyncChannel);
@@ -840,51 +926,51 @@ var ChannelWithContext = function ChannelWithContext(props) {
840
926
  };
841
927
  var clientChannelConfig = getChannelConfigSafely();
842
928
  var reloadChannel = function () {
843
- var _ref4 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4() {
844
- return _regenerator["default"].wrap(function _callee4$(_context4) {
845
- while (1) switch (_context4.prev = _context4.next) {
929
+ var _ref6 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5() {
930
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
931
+ while (1) switch (_context5.prev = _context5.next) {
846
932
  case 0:
847
- _context4.prev = 0;
848
- _context4.next = 3;
933
+ _context5.prev = 0;
934
+ _context5.next = 3;
849
935
  return loadLatestMessages();
850
936
  case 3:
851
- _context4.next = 8;
937
+ _context5.next = 8;
852
938
  break;
853
939
  case 5:
854
- _context4.prev = 5;
855
- _context4.t0 = _context4["catch"](0);
856
- console.warn('Reloading channel failed with error:', _context4.t0);
940
+ _context5.prev = 5;
941
+ _context5.t0 = _context5["catch"](0);
942
+ console.warn('Reloading channel failed with error:', _context5.t0);
857
943
  case 8:
858
944
  case "end":
859
- return _context4.stop();
945
+ return _context5.stop();
860
946
  }
861
- }, _callee4, null, [[0, 5]]);
947
+ }, _callee5, null, [[0, 5]]);
862
948
  }));
863
949
  return function reloadChannel() {
864
- return _ref4.apply(this, arguments);
950
+ return _ref6.apply(this, arguments);
865
951
  };
866
952
  }();
867
953
  var loadChannelAroundMessage = function () {
868
- var _ref6 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(_ref5) {
954
+ var _ref8 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(_ref7) {
869
955
  var messageIdToLoadAround;
870
- return _regenerator["default"].wrap(function _callee5$(_context5) {
871
- while (1) switch (_context5.prev = _context5.next) {
956
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
957
+ while (1) switch (_context6.prev = _context6.next) {
872
958
  case 0:
873
- messageIdToLoadAround = _ref5.messageId;
959
+ messageIdToLoadAround = _ref7.messageId;
874
960
  if (messageIdToLoadAround) {
875
- _context5.next = 3;
961
+ _context6.next = 3;
876
962
  break;
877
963
  }
878
- return _context5.abrupt("return");
964
+ return _context6.abrupt("return");
879
965
  case 3:
880
- _context5.prev = 3;
966
+ _context6.prev = 3;
881
967
  if (!thread) {
882
- _context5.next = 20;
968
+ _context6.next = 20;
883
969
  break;
884
970
  }
885
971
  setThreadLoadingMore(true);
886
- _context5.prev = 6;
887
- _context5.next = 9;
972
+ _context6.prev = 6;
973
+ _context6.next = 9;
888
974
  return channel.state.loadMessageIntoState(messageIdToLoadAround, thread.id);
889
975
  case 9:
890
976
  setThreadLoadingMore(false);
@@ -892,41 +978,41 @@ var ChannelWithContext = function ChannelWithContext(props) {
892
978
  if (setTargetedMessage) {
893
979
  setTargetedMessage(messageIdToLoadAround);
894
980
  }
895
- _context5.next = 18;
981
+ _context6.next = 18;
896
982
  break;
897
983
  case 14:
898
- _context5.prev = 14;
899
- _context5.t0 = _context5["catch"](6);
900
- if (_context5.t0 instanceof Error) {
901
- setError(_context5.t0);
984
+ _context6.prev = 14;
985
+ _context6.t0 = _context6["catch"](6);
986
+ if (_context6.t0 instanceof Error) {
987
+ setError(_context6.t0);
902
988
  } else {
903
989
  setError(true);
904
990
  }
905
991
  setThreadLoadingMore(false);
906
992
  case 18:
907
- _context5.next = 22;
993
+ _context6.next = 22;
908
994
  break;
909
995
  case 20:
910
- _context5.next = 22;
996
+ _context6.next = 22;
911
997
  return loadChannelAroundMessageFn({
912
998
  messageId: messageIdToLoadAround,
913
999
  setTargetedMessage: setTargetedMessage
914
1000
  });
915
1001
  case 22:
916
- _context5.next = 27;
1002
+ _context6.next = 27;
917
1003
  break;
918
1004
  case 24:
919
- _context5.prev = 24;
920
- _context5.t1 = _context5["catch"](3);
921
- console.warn('Loading channel around message failed with error:', _context5.t1);
1005
+ _context6.prev = 24;
1006
+ _context6.t1 = _context6["catch"](3);
1007
+ console.warn('Loading channel around message failed with error:', _context6.t1);
922
1008
  case 27:
923
1009
  case "end":
924
- return _context5.stop();
1010
+ return _context6.stop();
925
1011
  }
926
- }, _callee5, null, [[3, 24], [6, 14]]);
1012
+ }, _callee6, null, [[3, 24], [6, 14]]);
927
1013
  }));
928
- return function loadChannelAroundMessage(_x) {
929
- return _ref6.apply(this, arguments);
1014
+ return function loadChannelAroundMessage(_x2) {
1015
+ return _ref8.apply(this, arguments);
930
1016
  };
931
1017
  }();
932
1018
  var updateMessage = function updateMessage(updatedMessage) {
@@ -950,19 +1036,19 @@ var ChannelWithContext = function ChannelWithContext(props) {
950
1036
  }
951
1037
  }
952
1038
  };
953
- var createMessagePreview = function createMessagePreview(_ref7) {
954
- var attachments = _ref7.attachments,
955
- mentioned_users = _ref7.mentioned_users,
956
- parent_id = _ref7.parent_id,
957
- poll = _ref7.poll,
958
- poll_id = _ref7.poll_id,
959
- text = _ref7.text,
960
- extraFields = (0, _objectWithoutProperties2["default"])(_ref7, _excluded);
961
- var _client$user = client.user,
962
- channel_mutes = _client$user.channel_mutes,
963
- devices = _client$user.devices,
964
- mutes = _client$user.mutes,
965
- messageUser = (0, _objectWithoutProperties2["default"])(_client$user, _excluded2);
1039
+ var createMessagePreview = function createMessagePreview(_ref9) {
1040
+ var attachments = _ref9.attachments,
1041
+ mentioned_users = _ref9.mentioned_users,
1042
+ parent_id = _ref9.parent_id,
1043
+ poll = _ref9.poll,
1044
+ poll_id = _ref9.poll_id,
1045
+ text = _ref9.text,
1046
+ extraFields = (0, _objectWithoutProperties2["default"])(_ref9, _excluded3);
1047
+ var _client$user2 = client.user,
1048
+ channel_mutes = _client$user2.channel_mutes,
1049
+ devices = _client$user2.devices,
1050
+ mutes = _client$user2.mutes,
1051
+ messageUser = (0, _objectWithoutProperties2["default"])(_client$user2, _excluded4);
966
1052
  var preview = Object.assign({
967
1053
  __html: text,
968
1054
  attachments: attachments,
@@ -995,28 +1081,28 @@ var ChannelWithContext = function ChannelWithContext(props) {
995
1081
  return preview;
996
1082
  };
997
1083
  var uploadPendingAttachments = function () {
998
- var _ref8 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(message) {
1084
+ var _ref10 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(message) {
999
1085
  var _updatedMessage$attac;
1000
1086
  var updatedMessage, i, _updatedMessage$attac2, attachment, image, file, _image$name, filename, controller, compressedUri, contentType, uploadResponse, _controller, response;
1001
- return _regenerator["default"].wrap(function _callee6$(_context6) {
1002
- while (1) switch (_context6.prev = _context6.next) {
1087
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
1088
+ while (1) switch (_context7.prev = _context7.next) {
1003
1089
  case 0:
1004
1090
  updatedMessage = Object.assign({}, message);
1005
1091
  if (!((_updatedMessage$attac = updatedMessage.attachments) != null && _updatedMessage$attac.length)) {
1006
- _context6.next = 50;
1092
+ _context7.next = 50;
1007
1093
  break;
1008
1094
  }
1009
1095
  i = 0;
1010
1096
  case 3:
1011
1097
  if (!(i < ((_updatedMessage$attac2 = updatedMessage.attachments) == null ? void 0 : _updatedMessage$attac2.length))) {
1012
- _context6.next = 50;
1098
+ _context7.next = 50;
1013
1099
  break;
1014
1100
  }
1015
1101
  attachment = updatedMessage.attachments[i];
1016
1102
  image = attachment.originalImage;
1017
1103
  file = attachment.originalFile;
1018
1104
  if (!(attachment.type === _types.FileTypes.Image && image != null && image.uri && attachment.image_url && (0, _utils.isLocalUrl)(attachment.image_url))) {
1019
- _context6.next = 29;
1105
+ _context7.next = 29;
1020
1106
  break;
1021
1107
  }
1022
1108
  filename = (_image$name = image.name) != null ? _image$name : (0, _utils.getFileNameFromPath)(image.uri);
@@ -1025,31 +1111,31 @@ var ChannelWithContext = function ChannelWithContext(props) {
1025
1111
  controller.abort();
1026
1112
  uploadAbortControllerRef.current["delete"](filename);
1027
1113
  }
1028
- _context6.next = 13;
1114
+ _context7.next = 13;
1029
1115
  return (0, _compressImage.compressedImageURI)(image, compressImageQuality);
1030
1116
  case 13:
1031
- compressedUri = _context6.sent;
1117
+ compressedUri = _context7.sent;
1032
1118
  contentType = (0, _mimeTypes.lookup)(filename) || 'multipart/form-data';
1033
1119
  if (!doImageUploadRequest) {
1034
- _context6.next = 21;
1120
+ _context7.next = 21;
1035
1121
  break;
1036
1122
  }
1037
- _context6.next = 18;
1123
+ _context7.next = 18;
1038
1124
  return doImageUploadRequest(image, channel);
1039
1125
  case 18:
1040
- _context6.t0 = _context6.sent;
1041
- _context6.next = 24;
1126
+ _context7.t0 = _context7.sent;
1127
+ _context7.next = 24;
1042
1128
  break;
1043
1129
  case 21:
1044
- _context6.next = 23;
1130
+ _context7.next = 23;
1045
1131
  return channel.sendImage(compressedUri, filename, contentType);
1046
1132
  case 23:
1047
- _context6.t0 = _context6.sent;
1133
+ _context7.t0 = _context7.sent;
1048
1134
  case 24:
1049
- uploadResponse = _context6.t0;
1135
+ uploadResponse = _context7.t0;
1050
1136
  attachment.image_url = uploadResponse.file;
1051
1137
  delete attachment.originalFile;
1052
- _context6.next = 29;
1138
+ _context7.next = 29;
1053
1139
  return dbApi.updateMessage({
1054
1140
  message: Object.assign({}, updatedMessage, {
1055
1141
  cid: channel.cid
@@ -1057,7 +1143,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1057
1143
  });
1058
1144
  case 29:
1059
1145
  if (!((attachment.type === _types.FileTypes.File || attachment.type === _types.FileTypes.Audio || attachment.type === _types.FileTypes.VoiceRecording || attachment.type === _types.FileTypes.Video) && attachment.asset_url && (0, _utils.isLocalUrl)(attachment.asset_url) && file != null && file.uri)) {
1060
- _context6.next = 47;
1146
+ _context7.next = 47;
1061
1147
  break;
1062
1148
  }
1063
1149
  _controller = uploadAbortControllerRef.current.get(file.name);
@@ -1066,28 +1152,28 @@ var ChannelWithContext = function ChannelWithContext(props) {
1066
1152
  uploadAbortControllerRef.current["delete"](file.name);
1067
1153
  }
1068
1154
  if (!doDocUploadRequest) {
1069
- _context6.next = 38;
1155
+ _context7.next = 38;
1070
1156
  break;
1071
1157
  }
1072
- _context6.next = 35;
1158
+ _context7.next = 35;
1073
1159
  return doDocUploadRequest(file, channel);
1074
1160
  case 35:
1075
- _context6.t1 = _context6.sent;
1076
- _context6.next = 41;
1161
+ _context7.t1 = _context7.sent;
1162
+ _context7.next = 41;
1077
1163
  break;
1078
1164
  case 38:
1079
- _context6.next = 40;
1165
+ _context7.next = 40;
1080
1166
  return channel.sendFile(file.uri, file.name, file.mimeType);
1081
1167
  case 40:
1082
- _context6.t1 = _context6.sent;
1168
+ _context7.t1 = _context7.sent;
1083
1169
  case 41:
1084
- response = _context6.t1;
1170
+ response = _context7.t1;
1085
1171
  attachment.asset_url = response.file;
1086
1172
  if (response.thumb_url) {
1087
1173
  attachment.thumb_url = response.thumb_url;
1088
1174
  }
1089
1175
  delete attachment.originalFile;
1090
- _context6.next = 47;
1176
+ _context7.next = 47;
1091
1177
  return dbApi.updateMessage({
1092
1178
  message: Object.assign({}, updatedMessage, {
1093
1179
  cid: channel.cid
@@ -1095,38 +1181,38 @@ var ChannelWithContext = function ChannelWithContext(props) {
1095
1181
  });
1096
1182
  case 47:
1097
1183
  i++;
1098
- _context6.next = 3;
1184
+ _context7.next = 3;
1099
1185
  break;
1100
1186
  case 50:
1101
- return _context6.abrupt("return", updatedMessage);
1187
+ return _context7.abrupt("return", updatedMessage);
1102
1188
  case 51:
1103
1189
  case "end":
1104
- return _context6.stop();
1190
+ return _context7.stop();
1105
1191
  }
1106
- }, _callee6);
1192
+ }, _callee7);
1107
1193
  }));
1108
- return function uploadPendingAttachments(_x2) {
1109
- return _ref8.apply(this, arguments);
1194
+ return function uploadPendingAttachments(_x3) {
1195
+ return _ref10.apply(this, arguments);
1110
1196
  };
1111
1197
  }();
1112
1198
  var sendMessageRequest = function () {
1113
- var _ref9 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(message, retrying) {
1199
+ var _ref11 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(message, retrying) {
1114
1200
  var _updatedMessage, extraFields, attachments, id, mentioned_users, parent_id, text, mentionedUserIds, _messageData, messageResponse, _updatedMessage2;
1115
- return _regenerator["default"].wrap(function _callee7$(_context7) {
1116
- while (1) switch (_context7.prev = _context7.next) {
1201
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
1202
+ while (1) switch (_context8.prev = _context8.next) {
1117
1203
  case 0:
1118
- _context7.prev = 0;
1119
- _context7.next = 3;
1204
+ _context8.prev = 0;
1205
+ _context8.next = 3;
1120
1206
  return uploadPendingAttachments(message);
1121
1207
  case 3:
1122
- _updatedMessage = _context7.sent;
1208
+ _updatedMessage = _context8.sent;
1123
1209
  extraFields = (0, _omit["default"])(_updatedMessage, ['__html', 'attachments', 'created_at', 'deleted_at', 'html', 'id', 'latest_reactions', 'mentioned_users', 'own_reactions', 'parent_id', 'quoted_message', 'reaction_counts', 'reaction_groups', 'reactions', 'status', 'text', 'type', 'updated_at', 'user']);
1124
1210
  attachments = _updatedMessage.attachments, id = _updatedMessage.id, mentioned_users = _updatedMessage.mentioned_users, parent_id = _updatedMessage.parent_id, text = _updatedMessage.text;
1125
1211
  if (channel.id) {
1126
- _context7.next = 8;
1212
+ _context8.next = 8;
1127
1213
  break;
1128
1214
  }
1129
- return _context7.abrupt("return");
1215
+ return _context8.abrupt("return");
1130
1216
  case 8:
1131
1217
  mentionedUserIds = (mentioned_users == null ? void 0 : mentioned_users.map(function (user) {
1132
1218
  return user.id;
@@ -1140,35 +1226,35 @@ var ChannelWithContext = function ChannelWithContext(props) {
1140
1226
  }, extraFields);
1141
1227
  messageResponse = {};
1142
1228
  if (!doSendMessageRequest) {
1143
- _context7.next = 17;
1229
+ _context8.next = 17;
1144
1230
  break;
1145
1231
  }
1146
- _context7.next = 14;
1232
+ _context8.next = 14;
1147
1233
  return doSendMessageRequest((channel == null ? void 0 : channel.cid) || '', _messageData);
1148
1234
  case 14:
1149
- messageResponse = _context7.sent;
1150
- _context7.next = 21;
1235
+ messageResponse = _context8.sent;
1236
+ _context8.next = 21;
1151
1237
  break;
1152
1238
  case 17:
1153
1239
  if (!channel) {
1154
- _context7.next = 21;
1240
+ _context8.next = 21;
1155
1241
  break;
1156
1242
  }
1157
- _context7.next = 20;
1243
+ _context8.next = 20;
1158
1244
  return channel.sendMessage(_messageData);
1159
1245
  case 20:
1160
- messageResponse = _context7.sent;
1246
+ messageResponse = _context8.sent;
1161
1247
  case 21:
1162
1248
  if (!messageResponse.message) {
1163
- _context7.next = 28;
1249
+ _context8.next = 28;
1164
1250
  break;
1165
1251
  }
1166
1252
  messageResponse.message.status = _utils.MessageStatusTypes.RECEIVED;
1167
1253
  if (!enableOfflineSupport) {
1168
- _context7.next = 26;
1254
+ _context8.next = 26;
1169
1255
  break;
1170
1256
  }
1171
- _context7.next = 26;
1257
+ _context8.next = 26;
1172
1258
  return dbApi.updateMessage({
1173
1259
  message: Object.assign({}, messageResponse.message, {
1174
1260
  cid: channel.cid
@@ -1184,12 +1270,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
1184
1270
  message: messageResponse.message
1185
1271
  });
1186
1272
  case 28:
1187
- _context7.next = 40;
1273
+ _context8.next = 40;
1188
1274
  break;
1189
1275
  case 30:
1190
- _context7.prev = 30;
1191
- _context7.t0 = _context7["catch"](0);
1192
- console.log(_context7.t0);
1276
+ _context8.prev = 30;
1277
+ _context8.t0 = _context8["catch"](0);
1278
+ console.log(_context8.t0);
1193
1279
  message.status = _utils.MessageStatusTypes.FAILED;
1194
1280
  _updatedMessage2 = Object.assign({}, message, {
1195
1281
  cid: channel.cid
@@ -1199,10 +1285,10 @@ var ChannelWithContext = function ChannelWithContext(props) {
1199
1285
  message: _updatedMessage2
1200
1286
  });
1201
1287
  if (!enableOfflineSupport) {
1202
- _context7.next = 40;
1288
+ _context8.next = 40;
1203
1289
  break;
1204
1290
  }
1205
- _context7.next = 40;
1291
+ _context8.next = 40;
1206
1292
  return dbApi.updateMessage({
1207
1293
  message: Object.assign({}, message, {
1208
1294
  cid: channel.cid
@@ -1210,20 +1296,20 @@ var ChannelWithContext = function ChannelWithContext(props) {
1210
1296
  });
1211
1297
  case 40:
1212
1298
  case "end":
1213
- return _context7.stop();
1299
+ return _context8.stop();
1214
1300
  }
1215
- }, _callee7, null, [[0, 30]]);
1301
+ }, _callee8, null, [[0, 30]]);
1216
1302
  }));
1217
- return function sendMessageRequest(_x3, _x4) {
1218
- return _ref9.apply(this, arguments);
1303
+ return function sendMessageRequest(_x4, _x5) {
1304
+ return _ref11.apply(this, arguments);
1219
1305
  };
1220
1306
  }();
1221
1307
  var sendMessage = function () {
1222
- var _ref10 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(message) {
1308
+ var _ref12 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(message) {
1223
1309
  var _channel$state;
1224
1310
  var messagePreview;
1225
- return _regenerator["default"].wrap(function _callee8$(_context8) {
1226
- while (1) switch (_context8.prev = _context8.next) {
1311
+ return _regenerator["default"].wrap(function _callee9$(_context9) {
1312
+ while (1) switch (_context9.prev = _context9.next) {
1227
1313
  case 0:
1228
1314
  if (channel != null && (_channel$state = channel.state) != null && _channel$state.filterErrorMessages) {
1229
1315
  channel.state.filterErrorMessages();
@@ -1239,10 +1325,10 @@ var ChannelWithContext = function ChannelWithContext(props) {
1239
1325
  message: messagePreview
1240
1326
  });
1241
1327
  if (!enableOfflineSupport) {
1242
- _context8.next = 7;
1328
+ _context9.next = 7;
1243
1329
  break;
1244
1330
  }
1245
- _context8.next = 7;
1331
+ _context9.next = 7;
1246
1332
  return dbApi.upsertMessages({
1247
1333
  messages: [Object.assign({}, messagePreview, {
1248
1334
  cid: channel.cid,
@@ -1250,23 +1336,23 @@ var ChannelWithContext = function ChannelWithContext(props) {
1250
1336
  })]
1251
1337
  });
1252
1338
  case 7:
1253
- _context8.next = 9;
1339
+ _context9.next = 9;
1254
1340
  return sendMessageRequest(messagePreview);
1255
1341
  case 9:
1256
1342
  case "end":
1257
- return _context8.stop();
1343
+ return _context9.stop();
1258
1344
  }
1259
- }, _callee8);
1345
+ }, _callee9);
1260
1346
  }));
1261
- return function sendMessage(_x5) {
1262
- return _ref10.apply(this, arguments);
1347
+ return function sendMessage(_x6) {
1348
+ return _ref12.apply(this, arguments);
1263
1349
  };
1264
1350
  }();
1265
1351
  var retrySendMessage = function () {
1266
- var _ref11 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(message) {
1352
+ var _ref13 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee10(message) {
1267
1353
  var statusPendingMessage, messageWithoutReservedFields;
1268
- return _regenerator["default"].wrap(function _callee9$(_context9) {
1269
- while (1) switch (_context9.prev = _context9.next) {
1354
+ return _regenerator["default"].wrap(function _callee10$(_context10) {
1355
+ while (1) switch (_context10.prev = _context10.next) {
1270
1356
  case 0:
1271
1357
  statusPendingMessage = Object.assign({}, message, {
1272
1358
  status: _utils.MessageStatusTypes.SENDING
@@ -1275,16 +1361,16 @@ var ChannelWithContext = function ChannelWithContext(props) {
1275
1361
  if (!(0, _utils.isBouncedMessage)(message)) {
1276
1362
  updateMessage(messageWithoutReservedFields);
1277
1363
  }
1278
- _context9.next = 5;
1364
+ _context10.next = 5;
1279
1365
  return sendMessageRequest(messageWithoutReservedFields, true);
1280
1366
  case 5:
1281
1367
  case "end":
1282
- return _context9.stop();
1368
+ return _context10.stop();
1283
1369
  }
1284
- }, _callee9);
1370
+ }, _callee10);
1285
1371
  }));
1286
- return function retrySendMessage(_x6) {
1287
- return _ref11.apply(this, arguments);
1372
+ return function retrySendMessage(_x7) {
1373
+ return _ref13.apply(this, arguments);
1288
1374
  };
1289
1375
  }();
1290
1376
  var editMessage = function editMessage(updatedMessage) {
@@ -1304,9 +1390,9 @@ var ChannelWithContext = function ChannelWithContext(props) {
1304
1390
  return setQuotedMessage(undefined);
1305
1391
  };
1306
1392
  var removeMessage = function () {
1307
- var _ref12 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee10(message) {
1308
- return _regenerator["default"].wrap(function _callee10$(_context10) {
1309
- while (1) switch (_context10.prev = _context10.next) {
1393
+ var _ref14 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee11(message) {
1394
+ return _regenerator["default"].wrap(function _callee11$(_context11) {
1395
+ while (1) switch (_context11.prev = _context11.next) {
1310
1396
  case 0:
1311
1397
  if (channel) {
1312
1398
  channel.state.removeMessage(message);
@@ -1316,31 +1402,31 @@ var ChannelWithContext = function ChannelWithContext(props) {
1316
1402
  }
1317
1403
  }
1318
1404
  if (!enableOfflineSupport) {
1319
- _context10.next = 4;
1405
+ _context11.next = 4;
1320
1406
  break;
1321
1407
  }
1322
- _context10.next = 4;
1408
+ _context11.next = 4;
1323
1409
  return dbApi.deleteMessage({
1324
1410
  id: message.id
1325
1411
  });
1326
1412
  case 4:
1327
1413
  case "end":
1328
- return _context10.stop();
1414
+ return _context11.stop();
1329
1415
  }
1330
- }, _callee10);
1416
+ }, _callee11);
1331
1417
  }));
1332
- return function removeMessage(_x7) {
1333
- return _ref12.apply(this, arguments);
1418
+ return function removeMessage(_x8) {
1419
+ return _ref14.apply(this, arguments);
1334
1420
  };
1335
1421
  }();
1336
1422
  var sendReaction = function () {
1337
- var _ref13 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee11(type, messageId) {
1423
+ var _ref15 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee12(type, messageId) {
1338
1424
  var payload, sendReactionResponse;
1339
- return _regenerator["default"].wrap(function _callee11$(_context11) {
1340
- while (1) switch (_context11.prev = _context11.next) {
1425
+ return _regenerator["default"].wrap(function _callee12$(_context12) {
1426
+ while (1) switch (_context12.prev = _context12.next) {
1341
1427
  case 0:
1342
1428
  if (!(!(channel != null && channel.id) || !client.user)) {
1343
- _context11.next = 2;
1429
+ _context12.next = 2;
1344
1430
  break;
1345
1431
  }
1346
1432
  throw new Error('Channel has not been initialized');
@@ -1351,13 +1437,13 @@ var ChannelWithContext = function ChannelWithContext(props) {
1351
1437
  enforce_unique: enforceUniqueReaction
1352
1438
  }];
1353
1439
  if (enableOfflineSupport) {
1354
- _context11.next = 7;
1440
+ _context12.next = 7;
1355
1441
  break;
1356
1442
  }
1357
- _context11.next = 6;
1443
+ _context12.next = 6;
1358
1444
  return channel.sendReaction.apply(channel, payload);
1359
1445
  case 6:
1360
- return _context11.abrupt("return");
1446
+ return _context12.abrupt("return");
1361
1447
  case 7:
1362
1448
  (0, _addReactionToLocalState.addReactionToLocalState)({
1363
1449
  channel: channel,
@@ -1367,7 +1453,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1367
1453
  user: client.user
1368
1454
  });
1369
1455
  copyMessagesStateFromChannel(channel);
1370
- _context11.next = 11;
1456
+ _context12.next = 11;
1371
1457
  return _DBSyncManager.DBSyncManager.queueTask({
1372
1458
  client: client,
1373
1459
  task: {
@@ -1379,7 +1465,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1379
1465
  }
1380
1466
  });
1381
1467
  case 11:
1382
- sendReactionResponse = _context11.sent;
1468
+ sendReactionResponse = _context12.sent;
1383
1469
  if (sendReactionResponse != null && sendReactionResponse.message) {
1384
1470
  threadInstance == null ? void 0 : threadInstance.upsertReplyLocally == null ? void 0 : threadInstance.upsertReplyLocally({
1385
1471
  message: sendReactionResponse.message
@@ -1387,57 +1473,57 @@ var ChannelWithContext = function ChannelWithContext(props) {
1387
1473
  }
1388
1474
  case 13:
1389
1475
  case "end":
1390
- return _context11.stop();
1476
+ return _context12.stop();
1391
1477
  }
1392
- }, _callee11);
1478
+ }, _callee12);
1393
1479
  }));
1394
- return function sendReaction(_x8, _x9) {
1395
- return _ref13.apply(this, arguments);
1480
+ return function sendReaction(_x9, _x10) {
1481
+ return _ref15.apply(this, arguments);
1396
1482
  };
1397
1483
  }();
1398
1484
  var deleteMessage = function () {
1399
- var _ref14 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee12(message) {
1485
+ var _ref16 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee13(message) {
1400
1486
  var _updatedMessage3, _data;
1401
- return _regenerator["default"].wrap(function _callee12$(_context12) {
1402
- while (1) switch (_context12.prev = _context12.next) {
1487
+ return _regenerator["default"].wrap(function _callee13$(_context13) {
1488
+ while (1) switch (_context13.prev = _context13.next) {
1403
1489
  case 0:
1404
1490
  if (channel.id) {
1405
- _context12.next = 2;
1491
+ _context13.next = 2;
1406
1492
  break;
1407
1493
  }
1408
1494
  throw new Error('Channel has not been initialized yet');
1409
1495
  case 2:
1410
1496
  if (enableOfflineSupport) {
1411
- _context12.next = 10;
1497
+ _context13.next = 10;
1412
1498
  break;
1413
1499
  }
1414
1500
  if (!(message.status === _utils.MessageStatusTypes.FAILED)) {
1415
- _context12.next = 7;
1501
+ _context13.next = 7;
1416
1502
  break;
1417
1503
  }
1418
- _context12.next = 6;
1504
+ _context13.next = 6;
1419
1505
  return removeMessage(message);
1420
1506
  case 6:
1421
- return _context12.abrupt("return");
1507
+ return _context13.abrupt("return");
1422
1508
  case 7:
1423
- _context12.next = 9;
1509
+ _context13.next = 9;
1424
1510
  return client.deleteMessage(message.id);
1425
1511
  case 9:
1426
- return _context12.abrupt("return");
1512
+ return _context13.abrupt("return");
1427
1513
  case 10:
1428
1514
  if (!(message.status === _utils.MessageStatusTypes.FAILED)) {
1429
- _context12.next = 17;
1515
+ _context13.next = 17;
1430
1516
  break;
1431
1517
  }
1432
- _context12.next = 13;
1518
+ _context13.next = 13;
1433
1519
  return _DBSyncManager.DBSyncManager.dropPendingTasks({
1434
1520
  messageId: message.id
1435
1521
  });
1436
1522
  case 13:
1437
- _context12.next = 15;
1523
+ _context13.next = 15;
1438
1524
  return removeMessage(message);
1439
1525
  case 15:
1440
- _context12.next = 24;
1526
+ _context13.next = 24;
1441
1527
  break;
1442
1528
  case 17:
1443
1529
  _updatedMessage3 = Object.assign({}, message, {
@@ -1449,7 +1535,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1449
1535
  threadInstance == null ? void 0 : threadInstance.upsertReplyLocally({
1450
1536
  message: _updatedMessage3
1451
1537
  });
1452
- _context12.next = 22;
1538
+ _context13.next = 22;
1453
1539
  return _DBSyncManager.DBSyncManager.queueTask({
1454
1540
  client: client,
1455
1541
  task: {
@@ -1461,41 +1547,41 @@ var ChannelWithContext = function ChannelWithContext(props) {
1461
1547
  }
1462
1548
  });
1463
1549
  case 22:
1464
- _data = _context12.sent;
1550
+ _data = _context13.sent;
1465
1551
  if (_data != null && _data.message) {
1466
1552
  updateMessage(Object.assign({}, _data.message));
1467
1553
  }
1468
1554
  case 24:
1469
1555
  case "end":
1470
- return _context12.stop();
1556
+ return _context13.stop();
1471
1557
  }
1472
- }, _callee12);
1558
+ }, _callee13);
1473
1559
  }));
1474
- return function deleteMessage(_x10) {
1475
- return _ref14.apply(this, arguments);
1560
+ return function deleteMessage(_x11) {
1561
+ return _ref16.apply(this, arguments);
1476
1562
  };
1477
1563
  }();
1478
1564
  var deleteReaction = function () {
1479
- var _ref15 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee13(type, messageId) {
1565
+ var _ref17 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee14(type, messageId) {
1480
1566
  var payload;
1481
- return _regenerator["default"].wrap(function _callee13$(_context13) {
1482
- while (1) switch (_context13.prev = _context13.next) {
1567
+ return _regenerator["default"].wrap(function _callee14$(_context14) {
1568
+ while (1) switch (_context14.prev = _context14.next) {
1483
1569
  case 0:
1484
1570
  if (!(!(channel != null && channel.id) || !client.user)) {
1485
- _context13.next = 2;
1571
+ _context14.next = 2;
1486
1572
  break;
1487
1573
  }
1488
1574
  throw new Error('Channel has not been initialized');
1489
1575
  case 2:
1490
1576
  payload = [messageId, type];
1491
1577
  if (enableOfflineSupport) {
1492
- _context13.next = 7;
1578
+ _context14.next = 7;
1493
1579
  break;
1494
1580
  }
1495
- _context13.next = 6;
1581
+ _context14.next = 6;
1496
1582
  return channel.deleteReaction.apply(channel, payload);
1497
1583
  case 6:
1498
- return _context13.abrupt("return");
1584
+ return _context14.abrupt("return");
1499
1585
  case 7:
1500
1586
  (0, _removeReactionFromLocalState.removeReactionFromLocalState)({
1501
1587
  channel: channel,
@@ -1504,7 +1590,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1504
1590
  user: client.user
1505
1591
  });
1506
1592
  copyMessagesStateFromChannel(channel);
1507
- _context13.next = 11;
1593
+ _context14.next = 11;
1508
1594
  return _DBSyncManager.DBSyncManager.queueTask({
1509
1595
  client: client,
1510
1596
  task: {
@@ -1517,12 +1603,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
1517
1603
  });
1518
1604
  case 11:
1519
1605
  case "end":
1520
- return _context13.stop();
1606
+ return _context14.stop();
1521
1607
  }
1522
- }, _callee13);
1608
+ }, _callee14);
1523
1609
  }));
1524
- return function deleteReaction(_x11, _x12) {
1525
- return _ref15.apply(this, arguments);
1610
+ return function deleteReaction(_x12, _x13) {
1611
+ return _ref17.apply(this, arguments);
1526
1612
  };
1527
1613
  }();
1528
1614
  var openThread = (0, _react.useCallback)(function (message) {
@@ -1543,59 +1629,59 @@ var ChannelWithContext = function ChannelWithContext(props) {
1543
1629
  setThreadMessages(updatedThreadMessages);
1544
1630
  }, defaultDebounceInterval, debounceOptions)).current;
1545
1631
  var loadMoreThread = function () {
1546
- var _ref16 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee14() {
1632
+ var _ref18 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee15() {
1547
1633
  var _threadMessages$, parentID, oldestMessageID, limit, queryResponse, updatedHasMore, updatedThreadMessages;
1548
- return _regenerator["default"].wrap(function _callee14$(_context14) {
1549
- while (1) switch (_context14.prev = _context14.next) {
1634
+ return _regenerator["default"].wrap(function _callee15$(_context15) {
1635
+ while (1) switch (_context15.prev = _context15.next) {
1550
1636
  case 0:
1551
1637
  if (!(threadLoadingMore || !(thread != null && thread.id))) {
1552
- _context14.next = 2;
1638
+ _context15.next = 2;
1553
1639
  break;
1554
1640
  }
1555
- return _context14.abrupt("return");
1641
+ return _context15.abrupt("return");
1556
1642
  case 2:
1557
1643
  setThreadLoadingMore(true);
1558
- _context14.prev = 3;
1644
+ _context15.prev = 3;
1559
1645
  if (!channel) {
1560
- _context14.next = 15;
1646
+ _context15.next = 15;
1561
1647
  break;
1562
1648
  }
1563
1649
  parentID = thread.id;
1564
1650
  channel.state.threads[parentID] = threadMessages;
1565
1651
  oldestMessageID = threadMessages == null ? void 0 : (_threadMessages$ = threadMessages[0]) == null ? void 0 : _threadMessages$.id;
1566
1652
  limit = 50;
1567
- _context14.next = 11;
1653
+ _context15.next = 11;
1568
1654
  return channel.getReplies(parentID, {
1569
1655
  id_lt: oldestMessageID,
1570
1656
  limit: limit
1571
1657
  });
1572
1658
  case 11:
1573
- queryResponse = _context14.sent;
1659
+ queryResponse = _context15.sent;
1574
1660
  updatedHasMore = queryResponse.messages.length === limit;
1575
1661
  updatedThreadMessages = channel.state.threads[parentID] || [];
1576
1662
  loadMoreThreadFinished(updatedHasMore, updatedThreadMessages);
1577
1663
  case 15:
1578
- _context14.next = 23;
1664
+ _context15.next = 23;
1579
1665
  break;
1580
1666
  case 17:
1581
- _context14.prev = 17;
1582
- _context14.t0 = _context14["catch"](3);
1583
- console.warn('Message pagination request failed with error', _context14.t0);
1584
- if (_context14.t0 instanceof Error) {
1585
- setError(_context14.t0);
1667
+ _context15.prev = 17;
1668
+ _context15.t0 = _context15["catch"](3);
1669
+ console.warn('Message pagination request failed with error', _context15.t0);
1670
+ if (_context15.t0 instanceof Error) {
1671
+ setError(_context15.t0);
1586
1672
  } else {
1587
1673
  setError(true);
1588
1674
  }
1589
1675
  setThreadLoadingMore(false);
1590
- throw _context14.t0;
1676
+ throw _context15.t0;
1591
1677
  case 23:
1592
1678
  case "end":
1593
- return _context14.stop();
1679
+ return _context15.stop();
1594
1680
  }
1595
- }, _callee14, null, [[3, 17]]);
1681
+ }, _callee15, null, [[3, 17]]);
1596
1682
  }));
1597
1683
  return function loadMoreThread() {
1598
- return _ref16.apply(this, arguments);
1684
+ return _ref18.apply(this, arguments);
1599
1685
  };
1600
1686
  }();
1601
1687
  var ownCapabilitiesContext = (0, _useCreateOwnCapabilitiesContext.useCreateOwnCapabilitiesContext)({
@@ -1604,19 +1690,22 @@ var ChannelWithContext = function ChannelWithContext(props) {
1604
1690
  });
1605
1691
  var channelContext = (0, _useCreateChannelContext.useCreateChannelContext)({
1606
1692
  channel: channel,
1693
+ channelUnreadState: channelUnreadState,
1607
1694
  disabled: !!(channel != null && (_channel$data = channel.data) != null && _channel$data.frozen),
1608
1695
  EmptyStateIndicator: EmptyStateIndicator,
1609
1696
  enableMessageGroupingByUser: enableMessageGroupingByUser,
1610
1697
  enforceUniqueReaction: enforceUniqueReaction,
1611
1698
  error: error,
1612
- giphyEnabled: giphyEnabled != null ? giphyEnabled : !!((_ref17 = (clientChannelConfig == null ? void 0 : clientChannelConfig.commands) || []) != null && _ref17.some(function (command) {
1699
+ giphyEnabled: giphyEnabled != null ? giphyEnabled : !!((_ref19 = (clientChannelConfig == null ? void 0 : clientChannelConfig.commands) || []) != null && _ref19.some(function (command) {
1613
1700
  return command.name === 'giphy';
1614
1701
  })),
1615
1702
  hideDateSeparators: hideDateSeparators,
1616
1703
  hideStickyDateHeader: hideStickyDateHeader,
1704
+ highlightedMessageId: highlightedMessageId,
1617
1705
  isChannelActive: shouldSyncChannel,
1618
1706
  lastRead: lastRead,
1619
1707
  loadChannelAroundMessage: loadChannelAroundMessage,
1708
+ loadChannelAtFirstUnreadMessage: loadChannelAtFirstUnreadMessage,
1620
1709
  loading: channelMessagesState.loading,
1621
1710
  LoadingIndicator: LoadingIndicator,
1622
1711
  markRead: markRead,
@@ -1626,6 +1715,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1626
1715
  read: (_channelState$read = channelState.read) != null ? _channelState$read : {},
1627
1716
  reloadChannel: reloadChannel,
1628
1717
  scrollToFirstUnreadThreshold: scrollToFirstUnreadThreshold,
1718
+ setChannelUnreadState: setChannelUnreadState,
1629
1719
  setLastRead: setLastRead,
1630
1720
  setTargetedMessage: setTargetedMessage,
1631
1721
  StickyHeader: StickyHeader,
@@ -1678,7 +1768,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1678
1768
  InputEditingStateHeader: InputEditingStateHeader,
1679
1769
  InputGiphySearch: InputGiphySearch,
1680
1770
  InputReplyStateHeader: InputReplyStateHeader,
1681
- maxMessageLength: (_ref18 = maxMessageLengthProp != null ? maxMessageLengthProp : clientChannelConfig == null ? void 0 : clientChannelConfig.max_message_length) != null ? _ref18 : undefined,
1771
+ maxMessageLength: (_ref20 = maxMessageLengthProp != null ? maxMessageLengthProp : clientChannelConfig == null ? void 0 : clientChannelConfig.max_message_length) != null ? _ref20 : undefined,
1682
1772
  maxNumberOfFiles: maxNumberOfFiles,
1683
1773
  mentionAllAppUsersEnabled: mentionAllAppUsersEnabled,
1684
1774
  mentionAllAppUsersQuery: mentionAllAppUsersQuery,
@@ -1741,6 +1831,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1741
1831
  handleDelete: handleDelete,
1742
1832
  handleEdit: handleEdit,
1743
1833
  handleFlag: handleFlag,
1834
+ handleMarkUnread: handleMarkUnread,
1744
1835
  handleMute: handleMute,
1745
1836
  handlePinMessage: handlePinMessage,
1746
1837
  handleQuotedReply: handleQuotedReply,
@@ -1807,6 +1898,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1807
1898
  targetedMessage: targetedMessage,
1808
1899
  TypingIndicator: TypingIndicator,
1809
1900
  TypingIndicatorContainer: TypingIndicatorContainer,
1901
+ UnreadMessagesNotification: UnreadMessagesNotification,
1810
1902
  updateMessage: updateMessage,
1811
1903
  UrlPreview: UrlPreview,
1812
1904
  VideoThumbnail: VideoThumbnail