sceyt-chat-react-uikit 1.8.8-beta.4 → 1.8.8-beta.6

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 (3) hide show
  1. package/index.js +89 -82
  2. package/index.modern.js +89 -82
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -9289,7 +9289,8 @@ var channelSlice = createSlice({
9289
9289
  config = _action$payload3.config,
9290
9290
  channelId = _action$payload3.channelId,
9291
9291
  moveUp = _action$payload3.moveUp,
9292
- sort = _action$payload3.sort;
9292
+ sort = _action$payload3.sort,
9293
+ add = _action$payload3.add;
9293
9294
  if (moveUp) {
9294
9295
  var updateChannel;
9295
9296
  var updatedChannels = state.channels.filter(function (chan) {
@@ -9298,8 +9299,8 @@ var channelSlice = createSlice({
9298
9299
  }
9299
9300
  return chan.id !== channelId;
9300
9301
  });
9301
- if (updateChannel) {
9302
- updateChannel = _extends({}, updateChannel, config);
9302
+ if (updateChannel || add) {
9303
+ updateChannel = _extends({}, updateChannel || {}, config);
9303
9304
  state.channels = sortChannelByLastMessage([updateChannel].concat(updatedChannels));
9304
9305
  }
9305
9306
  } else {
@@ -13565,12 +13566,13 @@ var updateChannelAC = function updateChannelAC(channelId, config) {
13565
13566
  }
13566
13567
  };
13567
13568
  };
13568
- var updateChannelDataAC = function updateChannelDataAC(channelId, config, moveUp, sort) {
13569
+ var updateChannelDataAC = function updateChannelDataAC(channelId, config, moveUp, sort, add) {
13569
13570
  return updateChannelData({
13570
13571
  config: config,
13571
13572
  channelId: channelId,
13572
13573
  moveUp: moveUp,
13573
- sort: sort
13574
+ sort: sort,
13575
+ add: add
13574
13576
  });
13575
13577
  };
13576
13578
  var updateChannelsMembersAC = function updateChannelsMembersAC(members) {
@@ -16667,7 +16669,7 @@ function sendTextMessage(action) {
16667
16669
  }
16668
16670
  function forwardMessage(action) {
16669
16671
  var _message$user;
16670
- var payload, message, channelId, connectionState, isForward, showOwnMessageForward, SceytChatClient, isNotShowOwnMessageForward, pendingMessage, channel, activeChannelId, messageTid, _SceytChatClient, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, pollDetails, messageToSend, _getStoredChannel8, messageResponse, messageUpdateData, messageToUpdate, resolvedLastMessage, channelUpdateParam, _channel5, isErrorResendable, _t4;
16672
+ var payload, message, channelId, connectionState, isForward, showOwnMessageForward, SceytChatClient, isNotShowOwnMessageForward, pendingMessage, channel, activeChannelId, messageTid, _SceytChatClient, parsedChannel, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, pollDetails, messageToSend, _getStoredChannel8, messageResponse, messageUpdateData, messageToUpdate, resolvedLastMessage, channelUpdateParam, _channel5, isErrorResendable, _t4;
16671
16673
  return _regenerator().w(function (_context15) {
16672
16674
  while (1) switch (_context15.p = _context15.n) {
16673
16675
  case 0:
@@ -16686,12 +16688,12 @@ function forwardMessage(action) {
16686
16688
  case 2:
16687
16689
  channel = _context15.v;
16688
16690
  if (channel) {
16689
- _context15.n = 5;
16691
+ _context15.n = 7;
16690
16692
  break;
16691
16693
  }
16692
16694
  channel = getChannelFromAllChannels(channelId) || null;
16693
16695
  if (channel) {
16694
- _context15.n = 4;
16696
+ _context15.n = 5;
16695
16697
  break;
16696
16698
  }
16697
16699
  _SceytChatClient = getClient();
@@ -16699,26 +16701,37 @@ function forwardMessage(action) {
16699
16701
  return effects.call(_SceytChatClient.getChannel, channelId);
16700
16702
  case 3:
16701
16703
  channel = _context15.v;
16702
- case 4:
16703
- if (channel) {
16704
- setChannelInMap(channel);
16704
+ if (!channel) {
16705
+ _context15.n = 4;
16706
+ break;
16705
16707
  }
16708
+ setChannelInMap(channel);
16709
+ addChannelToAllChannels(_extends({}, channel));
16710
+ parsedChannel = JSON.parse(JSON.stringify(channel));
16711
+ _context15.n = 4;
16712
+ return effects.put(addChannelAC(parsedChannel));
16713
+ case 4:
16714
+ _context15.n = 6;
16715
+ break;
16716
+ case 5:
16717
+ setChannelInMap(channel);
16718
+ case 6:
16706
16719
  if (!channel) {
16707
16720
  channel = getChannelFromAllChannelsMap(channelId);
16708
16721
  }
16709
- case 5:
16722
+ case 7:
16710
16723
  if (channel) {
16711
- _context15.n = 6;
16724
+ _context15.n = 8;
16712
16725
  break;
16713
16726
  }
16714
16727
  throw new Error('Channel not found');
16715
- case 6:
16728
+ case 8:
16716
16729
  mentionedUserIds = message.mentionedUsers ? message.mentionedUsers.map(function (member) {
16717
16730
  return member.id;
16718
16731
  }) : [];
16719
16732
  attachments = message.attachments;
16720
16733
  if ((channel.type === DEFAULT_CHANNEL_TYPE.BROADCAST || channel.type === DEFAULT_CHANNEL_TYPE.PUBLIC) && !(channel.userRole === 'admin' || channel.userRole === 'owner')) {
16721
- _context15.n = 15;
16734
+ _context15.n = 17;
16722
16735
  break;
16723
16736
  }
16724
16737
  if (message.attachments && message.attachments.length && action.type !== RESEND_MESSAGE) {
@@ -16766,51 +16779,51 @@ function forwardMessage(action) {
16766
16779
  pendingMessage.forwardingDetails.hops = message.forwardingDetails ? message.forwardingDetails.hops : 1;
16767
16780
  }
16768
16781
  if (!pendingMessage) {
16769
- _context15.n = 8;
16782
+ _context15.n = 10;
16770
16783
  break;
16771
16784
  }
16772
16785
  if (!(action.type !== RESEND_MESSAGE)) {
16773
- _context15.n = 8;
16786
+ _context15.n = 10;
16774
16787
  break;
16775
16788
  }
16776
- _context15.n = 7;
16789
+ _context15.n = 9;
16777
16790
  return effects.call(loadOGMetadataForLinkMessages, [pendingMessage], true);
16778
- case 7:
16779
- _context15.n = 8;
16791
+ case 9:
16792
+ _context15.n = 10;
16780
16793
  return effects.call(updateMessage$1, action.type, pendingMessage, channel.id, channelId === activeChannelId, message, isNotShowOwnMessageForward);
16781
- case 8:
16794
+ case 10:
16782
16795
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
16783
- _context15.n = 14;
16796
+ _context15.n = 16;
16784
16797
  break;
16785
16798
  }
16786
- _context15.n = 9;
16799
+ _context15.n = 11;
16787
16800
  return effects.call(channel.sendMessage, _extends({}, messageToSend, isNotShowOwnMessageForward ? {
16788
16801
  forwardingDetails: null
16789
16802
  } : {}));
16790
- case 9:
16803
+ case 11:
16791
16804
  messageResponse = _context15.v;
16792
16805
  messageUpdateData = _extends({}, messageResponse, {
16793
16806
  channelId: channel.id
16794
16807
  });
16795
16808
  if (!(channelId === activeChannelId)) {
16796
- _context15.n = 10;
16809
+ _context15.n = 12;
16797
16810
  break;
16798
16811
  }
16799
- _context15.n = 10;
16812
+ _context15.n = 12;
16800
16813
  return effects.put(updateMessageAC(messageToSend.tid, JSON.parse(JSON.stringify(messageUpdateData)), true));
16801
- case 10:
16814
+ case 12:
16802
16815
  addConfirmedMessageToCache(channel.id, JSON.parse(JSON.stringify(messageUpdateData)));
16803
16816
  messageToUpdate = JSON.parse(JSON.stringify(messageResponse));
16804
16817
  if (!channel.unread) {
16805
- _context15.n = 11;
16818
+ _context15.n = 13;
16806
16819
  break;
16807
16820
  }
16808
- _context15.n = 11;
16821
+ _context15.n = 13;
16809
16822
  return effects.put(markChannelAsReadAC(channel.id));
16810
- case 11:
16823
+ case 13:
16811
16824
  resolvedLastMessage = getResolvedChannelLastMessage(channel.id, messageToUpdate, messageToSend);
16812
16825
  if (!lastMessageNeedsUpdate((_getStoredChannel8 = getStoredChannel(channel.id)) === null || _getStoredChannel8 === void 0 ? void 0 : _getStoredChannel8.lastMessage, resolvedLastMessage)) {
16813
- _context15.n = 13;
16826
+ _context15.n = 15;
16814
16827
  break;
16815
16828
  }
16816
16829
  updateChannelLastMessageOnAllChannels(channel.id, resolvedLastMessage);
@@ -16818,36 +16831,36 @@ function forwardMessage(action) {
16818
16831
  lastMessage: resolvedLastMessage,
16819
16832
  lastReactedMessage: null
16820
16833
  };
16821
- _context15.n = 12;
16822
- return effects.put(updateChannelDataAC(channel.id, channelUpdateParam, true));
16823
- case 12:
16824
- updateChannelOnAllChannels(channel.id, channelUpdateParam);
16825
- case 13:
16826
- _context15.n = 15;
16827
- break;
16834
+ _context15.n = 14;
16835
+ return effects.put(updateChannelDataAC(channel.id, _extends({}, channel, channelUpdateParam), true, false, true));
16828
16836
  case 14:
16829
- throw new Error('Connection required to forward message');
16837
+ updateChannelOnAllChannels(channel.id, channelUpdateParam);
16830
16838
  case 15:
16831
- _context15.n = 18;
16839
+ _context15.n = 17;
16832
16840
  break;
16833
16841
  case 16:
16834
- _context15.p = 16;
16842
+ throw new Error('Connection required to forward message');
16843
+ case 17:
16844
+ _context15.n = 20;
16845
+ break;
16846
+ case 18:
16847
+ _context15.p = 18;
16835
16848
  _t4 = _context15.v;
16836
16849
  isErrorResendable = isResendableError(_t4 === null || _t4 === void 0 ? void 0 : _t4.type);
16837
16850
  if (!((_channel5 = channel) !== null && _channel5 !== void 0 && _channel5.id && messageTid)) {
16838
- _context15.n = 17;
16851
+ _context15.n = 19;
16839
16852
  break;
16840
16853
  }
16841
- _context15.n = 17;
16854
+ _context15.n = 19;
16842
16855
  return effects.call(syncFailedMessageState, channel, messageTid, pendingMessage || _extends({}, message, {
16843
16856
  tid: messageTid
16844
16857
  }), isErrorResendable);
16845
- case 17:
16858
+ case 19:
16846
16859
  log.error('error on forward message ... ', _t4);
16847
- case 18:
16860
+ case 20:
16848
16861
  return _context15.a(2);
16849
16862
  }
16850
- }, _marked11, null, [[1, 16]]);
16863
+ }, _marked11, null, [[1, 18]]);
16851
16864
  }
16852
16865
  function resendMessage(action) {
16853
16866
  var _message$attachments;
@@ -36009,25 +36022,19 @@ var Message = function Message(_ref) {
36009
36022
  if (setLastVisibleMessageId) {
36010
36023
  setLastVisibleMessageId(message);
36011
36024
  }
36012
- if (!channel.isLinkedChannel) {
36013
- dispatch(setVisibleMessageAC(message));
36014
- }
36025
+ dispatch(setVisibleMessageAC(message));
36015
36026
  if (scrollToNewMessage.scrollToBottom && channel.lastMessage && compareMessagesForList(message, channel.lastMessage) >= 0) {
36016
36027
  dispatch(scrollToNewMessageAC(false, false, false));
36017
36028
  }
36018
36029
  } else {
36019
- if (!channel.isLinkedChannel) {
36020
- dispatch(removeVisibleMessageAC(message));
36021
- }
36030
+ dispatch(removeVisibleMessageAC(message));
36022
36031
  }
36023
- }, [channel.isLinkedChannel, channel.lastMessage, dispatch, isVisible, message, scrollToNewMessage.scrollToBottom, unreadScrollTo, setLastVisibleMessageId]);
36032
+ }, [channel.lastMessage, dispatch, isVisible, message, scrollToNewMessage.scrollToBottom, unreadScrollTo, setLastVisibleMessageId]);
36024
36033
  React.useEffect(function () {
36025
36034
  return function () {
36026
- if (!channel.isLinkedChannel) {
36027
- dispatch(removeVisibleMessageAC(message));
36028
- }
36035
+ dispatch(removeVisibleMessageAC(message));
36029
36036
  };
36030
- }, [channel.isLinkedChannel, dispatch, message]);
36037
+ }, [dispatch, message]);
36031
36038
  return /*#__PURE__*/React__default.createElement(Container$c, {
36032
36039
  id: message.id || message.tid,
36033
36040
  ref: messageItemRef,
@@ -38651,7 +38658,7 @@ var Attachment = function Attachment(_ref) {
38651
38658
  height: '48px',
38652
38659
  downloading: downloadingFile,
38653
38660
  file: attachment,
38654
- src: attachmentUrlFromMap || attachment.attachmentUrl || attachmentUrl,
38661
+ src: attachment.attachmentUrl || attachmentUrl,
38655
38662
  borderRadius: borderRadius,
38656
38663
  setVideoIsReadyToSend: setVideoIsReadyToSend,
38657
38664
  backgroundColor: backgroundColor && backgroundColor !== 'inherit' ? backgroundColor : overlayBackground2,
@@ -40774,7 +40781,7 @@ var ImageContainer = styled__default.div(_templateObject2$C || (_templateObject2
40774
40781
  return maxHeight ? maxHeight + "px" : '240px';
40775
40782
  });
40776
40783
  var OGText = styled__default.div(_templateObject3$w || (_templateObject3$w = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n gap: 0;\n"])));
40777
- var Title$3 = styled__default.p(_templateObject4$r || (_templateObject4$r = _taggedTemplateLiteralLoose(["\n font-weight: bold;\n font-size: 14px;\n line-height: 18px;\n letter-spacing: 0px;\n color: ", ";\n margin: 4px 0 0 0;\n padding: ", ";\n box-sizing: border-box;\n overflow-wrap: anywhere;\n ", "\n"])), function (_ref0) {
40784
+ var Title$3 = styled__default.p(_templateObject4$r || (_templateObject4$r = _taggedTemplateLiteralLoose(["\n font-weight: bold;\n font-size: 14px;\n line-height: 18px;\n letter-spacing: 0px;\n color: ", ";\n margin: 4px 0 0 0;\n padding: ", ";\n box-sizing: border-box;\n overflow-wrap: anywhere;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n ", "\n"])), function (_ref0) {
40778
40785
  var color = _ref0.color;
40779
40786
  return color;
40780
40787
  }, function (_ref1) {
@@ -43401,25 +43408,19 @@ var Message$1 = function Message(_ref) {
43401
43408
  setLastVisibleMessageId(message);
43402
43409
  }
43403
43410
  handleSendReadMarker();
43404
- if (!channel.isLinkedChannel) {
43405
- dispatch(setVisibleMessageAC(message));
43406
- }
43411
+ dispatch(setVisibleMessageAC(message));
43407
43412
  if (scrollToNewMessage.scrollToBottom && channel.lastMessage && compareMessagesForList(message, channel.lastMessage) >= 0) {
43408
43413
  dispatch(scrollToNewMessageAC(false, false, false));
43409
43414
  }
43410
43415
  } else {
43411
- if (!channel.isLinkedChannel) {
43412
- dispatch(removeVisibleMessageAC(message));
43413
- }
43416
+ dispatch(removeVisibleMessageAC(message));
43414
43417
  }
43415
- }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.isLinkedChannel, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, isTabActive]);
43418
+ }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, isTabActive]);
43416
43419
  React.useEffect(function () {
43417
43420
  return function () {
43418
- if (!channel.isLinkedChannel) {
43419
- dispatch(removeVisibleMessageAC(message));
43420
- }
43421
+ dispatch(removeVisibleMessageAC(message));
43421
43422
  };
43422
- }, [channel.isLinkedChannel, dispatch, message]);
43423
+ }, [dispatch, message]);
43423
43424
  React.useEffect(function () {
43424
43425
  if (!isVisible && infoPopupOpen) {
43425
43426
  setInfoPopupOpen(false);
@@ -44151,6 +44152,7 @@ function useChatController(_ref5) {
44151
44152
  var viewIsAtLatestRef = React.useRef(true);
44152
44153
  var jumpLockUntilRef = React.useRef(0);
44153
44154
  var jumpLockModeRef = React.useRef(null);
44155
+ var jumpLockHighWaterMarkRef = React.useRef(0);
44154
44156
  var jumpUnlockTimeoutRef = React.useRef(null);
44155
44157
  var isJumping = React.useRef(false);
44156
44158
  var currentJumpIdRef = React.useRef(0);
@@ -44357,6 +44359,7 @@ function useChatController(_ref5) {
44357
44359
  var clearJumpScrollingLock = React.useCallback(function () {
44358
44360
  jumpLockUntilRef.current = 0;
44359
44361
  jumpLockModeRef.current = null;
44362
+ jumpLockHighWaterMarkRef.current = 0;
44360
44363
  historyLoadArmedRef.current = true;
44361
44364
  latestLoadArmedRef.current = true;
44362
44365
  if (historyArmTimerRef.current !== null) {
@@ -44374,9 +44377,11 @@ function useChatController(_ref5) {
44374
44377
  isJumping.current = false;
44375
44378
  }, []);
44376
44379
  var lockJumpScrolling = React.useCallback(function (smooth, mode) {
44380
+ var _scrollRef$current$sc, _scrollRef$current;
44377
44381
  var lockDuration = smooth ? JUMP_SCROLL_LOCK_MS : 250;
44378
44382
  jumpLockUntilRef.current = Date.now() + lockDuration;
44379
44383
  jumpLockModeRef.current = mode;
44384
+ jumpLockHighWaterMarkRef.current = (_scrollRef$current$sc = (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) != null ? _scrollRef$current$sc : 0;
44380
44385
  if (jumpUnlockTimeoutRef.current !== null) {
44381
44386
  clearTimeout(jumpUnlockTimeoutRef.current);
44382
44387
  }
@@ -45139,7 +45144,8 @@ function useChatController(_ref5) {
45139
45144
  if (isJumping.current) {
45140
45145
  return;
45141
45146
  }
45142
- if (currentScrollTop <= historyEdgeScrollTop + PRELOAD_TRIGGER_PX) {
45147
+ var jumpLockActive = Date.now() < jumpLockUntilRef.current;
45148
+ if (!jumpLockActive && currentScrollTop <= historyEdgeScrollTop + PRELOAD_TRIGGER_PX) {
45143
45149
  currentScrollTop = historyEdgeScrollTop;
45144
45150
  }
45145
45151
  if (currentScrollTop !== container.scrollTop) {
@@ -45147,9 +45153,14 @@ function useChatController(_ref5) {
45147
45153
  }
45148
45154
  var distanceFromLatest = latestEdgeScrollTop - currentScrollTop;
45149
45155
  lastMeasuredLatestEdgeRef.current = latestEdgeScrollTop;
45150
- if (Date.now() < jumpLockUntilRef.current) {
45156
+ if (jumpLockActive) {
45157
+ jumpLockHighWaterMarkRef.current = Math.max(jumpLockHighWaterMarkRef.current, currentScrollTop);
45151
45158
  if (jumpLockModeRef.current === 'latest' && distanceFromLatest > PRELOAD_RESET_PX) {
45152
- clearJumpScrollingLock();
45159
+ if (currentScrollTop < jumpLockHighWaterMarkRef.current - PRELOAD_RESET_PX) {
45160
+ clearJumpScrollingLock();
45161
+ } else {
45162
+ return;
45163
+ }
45153
45164
  } else {
45154
45165
  return;
45155
45166
  }
@@ -45398,12 +45409,12 @@ function useChatController(_ref5) {
45398
45409
  }, [channel.id, clearScrollIdleTimer, dispatch]);
45399
45410
  var departingChannelId = activeChannelIdRef.current;
45400
45411
  if (departingChannelId) {
45401
- var _scrollRef$current$sc, _scrollRef$current;
45412
+ var _scrollRef$current$sc2, _scrollRef$current2;
45402
45413
  var currentMessages = messagesRef.current;
45403
45414
  var startId = getFirstConfirmedMessageId(currentMessages);
45404
45415
  var endId = getLastConfirmedMessageId(currentMessages);
45405
45416
  var anchorId = lastVisibleAnchorIdRef.current;
45406
- var scrollTop = (_scrollRef$current$sc = (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) != null ? _scrollRef$current$sc : 0;
45417
+ var scrollTop = (_scrollRef$current$sc2 = (_scrollRef$current2 = scrollRef.current) === null || _scrollRef$current2 === void 0 ? void 0 : _scrollRef$current2.scrollTop) != null ? _scrollRef$current$sc2 : 0;
45407
45418
  if (startId && endId && anchorId) {
45408
45419
  var confirmedMessages = currentMessages.filter(function (m) {
45409
45420
  return !!m.id;
@@ -45721,9 +45732,7 @@ function useChatController(_ref5) {
45721
45732
  }
45722
45733
  var savedRestoreWindow = channelRestoreWindowMap.get(channel.id);
45723
45734
  if (savedRestoreWindow) {
45724
- if (!channel.isLinkedChannel) {
45725
- dispatch(clearVisibleMessagesMapAC());
45726
- }
45735
+ dispatch(clearVisibleMessagesMapAC());
45727
45736
  if (channel.backToLinkedChannel) {
45728
45737
  restoreRef.current = {
45729
45738
  mode: 'restore-scroll-top',
@@ -45758,9 +45767,7 @@ function useChatController(_ref5) {
45758
45767
  }
45759
45768
  return;
45760
45769
  }
45761
- if (!channel.isLinkedChannel) {
45762
- dispatch(clearVisibleMessagesMapAC());
45763
- }
45770
+ dispatch(clearVisibleMessagesMapAC());
45764
45771
  if (channel.newMessageCount && channel.lastDisplayedMessageId) {
45765
45772
  suppressNextMessageChange();
45766
45773
  dispatch(loadNearUnreadAC(channel));
@@ -45768,7 +45775,7 @@ function useChatController(_ref5) {
45768
45775
  suppressNextMessageChange();
45769
45776
  dispatch(loadDefaultMessagesAC(channel));
45770
45777
  }
45771
- }, [dispatch, channel === null || channel === void 0 ? void 0 : channel.id, channel.backToLinkedChannel, channel.isLinkedChannel, suppressNextMessageChange]);
45778
+ }, [dispatch, channel === null || channel === void 0 ? void 0 : channel.id, channel.backToLinkedChannel, suppressNextMessageChange]);
45772
45779
  React.useEffect(function () {
45773
45780
  if (!(channel !== null && channel !== void 0 && channel.id) || clearedSelectionChannelIdRef.current === channel.id) {
45774
45781
  return;
package/index.modern.js CHANGED
@@ -9288,7 +9288,8 @@ var channelSlice = createSlice({
9288
9288
  config = _action$payload3.config,
9289
9289
  channelId = _action$payload3.channelId,
9290
9290
  moveUp = _action$payload3.moveUp,
9291
- sort = _action$payload3.sort;
9291
+ sort = _action$payload3.sort,
9292
+ add = _action$payload3.add;
9292
9293
  if (moveUp) {
9293
9294
  var updateChannel;
9294
9295
  var updatedChannels = state.channels.filter(function (chan) {
@@ -9297,8 +9298,8 @@ var channelSlice = createSlice({
9297
9298
  }
9298
9299
  return chan.id !== channelId;
9299
9300
  });
9300
- if (updateChannel) {
9301
- updateChannel = _extends({}, updateChannel, config);
9301
+ if (updateChannel || add) {
9302
+ updateChannel = _extends({}, updateChannel || {}, config);
9302
9303
  state.channels = sortChannelByLastMessage([updateChannel].concat(updatedChannels));
9303
9304
  }
9304
9305
  } else {
@@ -13564,12 +13565,13 @@ var updateChannelAC = function updateChannelAC(channelId, config) {
13564
13565
  }
13565
13566
  };
13566
13567
  };
13567
- var updateChannelDataAC = function updateChannelDataAC(channelId, config, moveUp, sort) {
13568
+ var updateChannelDataAC = function updateChannelDataAC(channelId, config, moveUp, sort, add) {
13568
13569
  return updateChannelData({
13569
13570
  config: config,
13570
13571
  channelId: channelId,
13571
13572
  moveUp: moveUp,
13572
- sort: sort
13573
+ sort: sort,
13574
+ add: add
13573
13575
  });
13574
13576
  };
13575
13577
  var updateChannelsMembersAC = function updateChannelsMembersAC(members) {
@@ -16666,7 +16668,7 @@ function sendTextMessage(action) {
16666
16668
  }
16667
16669
  function forwardMessage(action) {
16668
16670
  var _message$user;
16669
- var payload, message, channelId, connectionState, isForward, showOwnMessageForward, SceytChatClient, isNotShowOwnMessageForward, pendingMessage, channel, activeChannelId, messageTid, _SceytChatClient, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, pollDetails, messageToSend, _getStoredChannel8, messageResponse, messageUpdateData, messageToUpdate, resolvedLastMessage, channelUpdateParam, _channel5, isErrorResendable, _t4;
16671
+ var payload, message, channelId, connectionState, isForward, showOwnMessageForward, SceytChatClient, isNotShowOwnMessageForward, pendingMessage, channel, activeChannelId, messageTid, _SceytChatClient, parsedChannel, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, pollDetails, messageToSend, _getStoredChannel8, messageResponse, messageUpdateData, messageToUpdate, resolvedLastMessage, channelUpdateParam, _channel5, isErrorResendable, _t4;
16670
16672
  return _regenerator().w(function (_context15) {
16671
16673
  while (1) switch (_context15.p = _context15.n) {
16672
16674
  case 0:
@@ -16685,12 +16687,12 @@ function forwardMessage(action) {
16685
16687
  case 2:
16686
16688
  channel = _context15.v;
16687
16689
  if (channel) {
16688
- _context15.n = 5;
16690
+ _context15.n = 7;
16689
16691
  break;
16690
16692
  }
16691
16693
  channel = getChannelFromAllChannels(channelId) || null;
16692
16694
  if (channel) {
16693
- _context15.n = 4;
16695
+ _context15.n = 5;
16694
16696
  break;
16695
16697
  }
16696
16698
  _SceytChatClient = getClient();
@@ -16698,26 +16700,37 @@ function forwardMessage(action) {
16698
16700
  return call(_SceytChatClient.getChannel, channelId);
16699
16701
  case 3:
16700
16702
  channel = _context15.v;
16701
- case 4:
16702
- if (channel) {
16703
- setChannelInMap(channel);
16703
+ if (!channel) {
16704
+ _context15.n = 4;
16705
+ break;
16704
16706
  }
16707
+ setChannelInMap(channel);
16708
+ addChannelToAllChannels(_extends({}, channel));
16709
+ parsedChannel = JSON.parse(JSON.stringify(channel));
16710
+ _context15.n = 4;
16711
+ return put(addChannelAC(parsedChannel));
16712
+ case 4:
16713
+ _context15.n = 6;
16714
+ break;
16715
+ case 5:
16716
+ setChannelInMap(channel);
16717
+ case 6:
16705
16718
  if (!channel) {
16706
16719
  channel = getChannelFromAllChannelsMap(channelId);
16707
16720
  }
16708
- case 5:
16721
+ case 7:
16709
16722
  if (channel) {
16710
- _context15.n = 6;
16723
+ _context15.n = 8;
16711
16724
  break;
16712
16725
  }
16713
16726
  throw new Error('Channel not found');
16714
- case 6:
16727
+ case 8:
16715
16728
  mentionedUserIds = message.mentionedUsers ? message.mentionedUsers.map(function (member) {
16716
16729
  return member.id;
16717
16730
  }) : [];
16718
16731
  attachments = message.attachments;
16719
16732
  if ((channel.type === DEFAULT_CHANNEL_TYPE.BROADCAST || channel.type === DEFAULT_CHANNEL_TYPE.PUBLIC) && !(channel.userRole === 'admin' || channel.userRole === 'owner')) {
16720
- _context15.n = 15;
16733
+ _context15.n = 17;
16721
16734
  break;
16722
16735
  }
16723
16736
  if (message.attachments && message.attachments.length && action.type !== RESEND_MESSAGE) {
@@ -16765,51 +16778,51 @@ function forwardMessage(action) {
16765
16778
  pendingMessage.forwardingDetails.hops = message.forwardingDetails ? message.forwardingDetails.hops : 1;
16766
16779
  }
16767
16780
  if (!pendingMessage) {
16768
- _context15.n = 8;
16781
+ _context15.n = 10;
16769
16782
  break;
16770
16783
  }
16771
16784
  if (!(action.type !== RESEND_MESSAGE)) {
16772
- _context15.n = 8;
16785
+ _context15.n = 10;
16773
16786
  break;
16774
16787
  }
16775
- _context15.n = 7;
16788
+ _context15.n = 9;
16776
16789
  return call(loadOGMetadataForLinkMessages, [pendingMessage], true);
16777
- case 7:
16778
- _context15.n = 8;
16790
+ case 9:
16791
+ _context15.n = 10;
16779
16792
  return call(updateMessage$1, action.type, pendingMessage, channel.id, channelId === activeChannelId, message, isNotShowOwnMessageForward);
16780
- case 8:
16793
+ case 10:
16781
16794
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
16782
- _context15.n = 14;
16795
+ _context15.n = 16;
16783
16796
  break;
16784
16797
  }
16785
- _context15.n = 9;
16798
+ _context15.n = 11;
16786
16799
  return call(channel.sendMessage, _extends({}, messageToSend, isNotShowOwnMessageForward ? {
16787
16800
  forwardingDetails: null
16788
16801
  } : {}));
16789
- case 9:
16802
+ case 11:
16790
16803
  messageResponse = _context15.v;
16791
16804
  messageUpdateData = _extends({}, messageResponse, {
16792
16805
  channelId: channel.id
16793
16806
  });
16794
16807
  if (!(channelId === activeChannelId)) {
16795
- _context15.n = 10;
16808
+ _context15.n = 12;
16796
16809
  break;
16797
16810
  }
16798
- _context15.n = 10;
16811
+ _context15.n = 12;
16799
16812
  return put(updateMessageAC(messageToSend.tid, JSON.parse(JSON.stringify(messageUpdateData)), true));
16800
- case 10:
16813
+ case 12:
16801
16814
  addConfirmedMessageToCache(channel.id, JSON.parse(JSON.stringify(messageUpdateData)));
16802
16815
  messageToUpdate = JSON.parse(JSON.stringify(messageResponse));
16803
16816
  if (!channel.unread) {
16804
- _context15.n = 11;
16817
+ _context15.n = 13;
16805
16818
  break;
16806
16819
  }
16807
- _context15.n = 11;
16820
+ _context15.n = 13;
16808
16821
  return put(markChannelAsReadAC(channel.id));
16809
- case 11:
16822
+ case 13:
16810
16823
  resolvedLastMessage = getResolvedChannelLastMessage(channel.id, messageToUpdate, messageToSend);
16811
16824
  if (!lastMessageNeedsUpdate((_getStoredChannel8 = getStoredChannel(channel.id)) === null || _getStoredChannel8 === void 0 ? void 0 : _getStoredChannel8.lastMessage, resolvedLastMessage)) {
16812
- _context15.n = 13;
16825
+ _context15.n = 15;
16813
16826
  break;
16814
16827
  }
16815
16828
  updateChannelLastMessageOnAllChannels(channel.id, resolvedLastMessage);
@@ -16817,36 +16830,36 @@ function forwardMessage(action) {
16817
16830
  lastMessage: resolvedLastMessage,
16818
16831
  lastReactedMessage: null
16819
16832
  };
16820
- _context15.n = 12;
16821
- return put(updateChannelDataAC(channel.id, channelUpdateParam, true));
16822
- case 12:
16823
- updateChannelOnAllChannels(channel.id, channelUpdateParam);
16824
- case 13:
16825
- _context15.n = 15;
16826
- break;
16833
+ _context15.n = 14;
16834
+ return put(updateChannelDataAC(channel.id, _extends({}, channel, channelUpdateParam), true, false, true));
16827
16835
  case 14:
16828
- throw new Error('Connection required to forward message');
16836
+ updateChannelOnAllChannels(channel.id, channelUpdateParam);
16829
16837
  case 15:
16830
- _context15.n = 18;
16838
+ _context15.n = 17;
16831
16839
  break;
16832
16840
  case 16:
16833
- _context15.p = 16;
16841
+ throw new Error('Connection required to forward message');
16842
+ case 17:
16843
+ _context15.n = 20;
16844
+ break;
16845
+ case 18:
16846
+ _context15.p = 18;
16834
16847
  _t4 = _context15.v;
16835
16848
  isErrorResendable = isResendableError(_t4 === null || _t4 === void 0 ? void 0 : _t4.type);
16836
16849
  if (!((_channel5 = channel) !== null && _channel5 !== void 0 && _channel5.id && messageTid)) {
16837
- _context15.n = 17;
16850
+ _context15.n = 19;
16838
16851
  break;
16839
16852
  }
16840
- _context15.n = 17;
16853
+ _context15.n = 19;
16841
16854
  return call(syncFailedMessageState, channel, messageTid, pendingMessage || _extends({}, message, {
16842
16855
  tid: messageTid
16843
16856
  }), isErrorResendable);
16844
- case 17:
16857
+ case 19:
16845
16858
  log.error('error on forward message ... ', _t4);
16846
- case 18:
16859
+ case 20:
16847
16860
  return _context15.a(2);
16848
16861
  }
16849
- }, _marked11, null, [[1, 16]]);
16862
+ }, _marked11, null, [[1, 18]]);
16850
16863
  }
16851
16864
  function resendMessage(action) {
16852
16865
  var _message$attachments;
@@ -36008,25 +36021,19 @@ var Message = function Message(_ref) {
36008
36021
  if (setLastVisibleMessageId) {
36009
36022
  setLastVisibleMessageId(message);
36010
36023
  }
36011
- if (!channel.isLinkedChannel) {
36012
- dispatch(setVisibleMessageAC(message));
36013
- }
36024
+ dispatch(setVisibleMessageAC(message));
36014
36025
  if (scrollToNewMessage.scrollToBottom && channel.lastMessage && compareMessagesForList(message, channel.lastMessage) >= 0) {
36015
36026
  dispatch(scrollToNewMessageAC(false, false, false));
36016
36027
  }
36017
36028
  } else {
36018
- if (!channel.isLinkedChannel) {
36019
- dispatch(removeVisibleMessageAC(message));
36020
- }
36029
+ dispatch(removeVisibleMessageAC(message));
36021
36030
  }
36022
- }, [channel.isLinkedChannel, channel.lastMessage, dispatch, isVisible, message, scrollToNewMessage.scrollToBottom, unreadScrollTo, setLastVisibleMessageId]);
36031
+ }, [channel.lastMessage, dispatch, isVisible, message, scrollToNewMessage.scrollToBottom, unreadScrollTo, setLastVisibleMessageId]);
36023
36032
  useEffect(function () {
36024
36033
  return function () {
36025
- if (!channel.isLinkedChannel) {
36026
- dispatch(removeVisibleMessageAC(message));
36027
- }
36034
+ dispatch(removeVisibleMessageAC(message));
36028
36035
  };
36029
- }, [channel.isLinkedChannel, dispatch, message]);
36036
+ }, [dispatch, message]);
36030
36037
  return /*#__PURE__*/React__default.createElement(Container$c, {
36031
36038
  id: message.id || message.tid,
36032
36039
  ref: messageItemRef,
@@ -38650,7 +38657,7 @@ var Attachment = function Attachment(_ref) {
38650
38657
  height: '48px',
38651
38658
  downloading: downloadingFile,
38652
38659
  file: attachment,
38653
- src: attachmentUrlFromMap || attachment.attachmentUrl || attachmentUrl,
38660
+ src: attachment.attachmentUrl || attachmentUrl,
38654
38661
  borderRadius: borderRadius,
38655
38662
  setVideoIsReadyToSend: setVideoIsReadyToSend,
38656
38663
  backgroundColor: backgroundColor && backgroundColor !== 'inherit' ? backgroundColor : overlayBackground2,
@@ -40773,7 +40780,7 @@ var ImageContainer = styled.div(_templateObject2$C || (_templateObject2$C = _tag
40773
40780
  return maxHeight ? maxHeight + "px" : '240px';
40774
40781
  });
40775
40782
  var OGText = styled.div(_templateObject3$w || (_templateObject3$w = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n gap: 0;\n"])));
40776
- var Title$3 = styled.p(_templateObject4$r || (_templateObject4$r = _taggedTemplateLiteralLoose(["\n font-weight: bold;\n font-size: 14px;\n line-height: 18px;\n letter-spacing: 0px;\n color: ", ";\n margin: 4px 0 0 0;\n padding: ", ";\n box-sizing: border-box;\n overflow-wrap: anywhere;\n ", "\n"])), function (_ref0) {
40783
+ var Title$3 = styled.p(_templateObject4$r || (_templateObject4$r = _taggedTemplateLiteralLoose(["\n font-weight: bold;\n font-size: 14px;\n line-height: 18px;\n letter-spacing: 0px;\n color: ", ";\n margin: 4px 0 0 0;\n padding: ", ";\n box-sizing: border-box;\n overflow-wrap: anywhere;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n ", "\n"])), function (_ref0) {
40777
40784
  var color = _ref0.color;
40778
40785
  return color;
40779
40786
  }, function (_ref1) {
@@ -43400,25 +43407,19 @@ var Message$1 = function Message(_ref) {
43400
43407
  setLastVisibleMessageId(message);
43401
43408
  }
43402
43409
  handleSendReadMarker();
43403
- if (!channel.isLinkedChannel) {
43404
- dispatch(setVisibleMessageAC(message));
43405
- }
43410
+ dispatch(setVisibleMessageAC(message));
43406
43411
  if (scrollToNewMessage.scrollToBottom && channel.lastMessage && compareMessagesForList(message, channel.lastMessage) >= 0) {
43407
43412
  dispatch(scrollToNewMessageAC(false, false, false));
43408
43413
  }
43409
43414
  } else {
43410
- if (!channel.isLinkedChannel) {
43411
- dispatch(removeVisibleMessageAC(message));
43412
- }
43415
+ dispatch(removeVisibleMessageAC(message));
43413
43416
  }
43414
- }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.isLinkedChannel, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, isTabActive]);
43417
+ }, [isVisible, setLastVisibleMessageId, message.id, handleSendReadMarker, channel.lastMessage, scrollToNewMessage.scrollToBottom, dispatch, message, isTabActive]);
43415
43418
  useEffect(function () {
43416
43419
  return function () {
43417
- if (!channel.isLinkedChannel) {
43418
- dispatch(removeVisibleMessageAC(message));
43419
- }
43420
+ dispatch(removeVisibleMessageAC(message));
43420
43421
  };
43421
- }, [channel.isLinkedChannel, dispatch, message]);
43422
+ }, [dispatch, message]);
43422
43423
  useEffect(function () {
43423
43424
  if (!isVisible && infoPopupOpen) {
43424
43425
  setInfoPopupOpen(false);
@@ -44150,6 +44151,7 @@ function useChatController(_ref5) {
44150
44151
  var viewIsAtLatestRef = useRef(true);
44151
44152
  var jumpLockUntilRef = useRef(0);
44152
44153
  var jumpLockModeRef = useRef(null);
44154
+ var jumpLockHighWaterMarkRef = useRef(0);
44153
44155
  var jumpUnlockTimeoutRef = useRef(null);
44154
44156
  var isJumping = useRef(false);
44155
44157
  var currentJumpIdRef = useRef(0);
@@ -44356,6 +44358,7 @@ function useChatController(_ref5) {
44356
44358
  var clearJumpScrollingLock = useCallback(function () {
44357
44359
  jumpLockUntilRef.current = 0;
44358
44360
  jumpLockModeRef.current = null;
44361
+ jumpLockHighWaterMarkRef.current = 0;
44359
44362
  historyLoadArmedRef.current = true;
44360
44363
  latestLoadArmedRef.current = true;
44361
44364
  if (historyArmTimerRef.current !== null) {
@@ -44373,9 +44376,11 @@ function useChatController(_ref5) {
44373
44376
  isJumping.current = false;
44374
44377
  }, []);
44375
44378
  var lockJumpScrolling = useCallback(function (smooth, mode) {
44379
+ var _scrollRef$current$sc, _scrollRef$current;
44376
44380
  var lockDuration = smooth ? JUMP_SCROLL_LOCK_MS : 250;
44377
44381
  jumpLockUntilRef.current = Date.now() + lockDuration;
44378
44382
  jumpLockModeRef.current = mode;
44383
+ jumpLockHighWaterMarkRef.current = (_scrollRef$current$sc = (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) != null ? _scrollRef$current$sc : 0;
44379
44384
  if (jumpUnlockTimeoutRef.current !== null) {
44380
44385
  clearTimeout(jumpUnlockTimeoutRef.current);
44381
44386
  }
@@ -45138,7 +45143,8 @@ function useChatController(_ref5) {
45138
45143
  if (isJumping.current) {
45139
45144
  return;
45140
45145
  }
45141
- if (currentScrollTop <= historyEdgeScrollTop + PRELOAD_TRIGGER_PX) {
45146
+ var jumpLockActive = Date.now() < jumpLockUntilRef.current;
45147
+ if (!jumpLockActive && currentScrollTop <= historyEdgeScrollTop + PRELOAD_TRIGGER_PX) {
45142
45148
  currentScrollTop = historyEdgeScrollTop;
45143
45149
  }
45144
45150
  if (currentScrollTop !== container.scrollTop) {
@@ -45146,9 +45152,14 @@ function useChatController(_ref5) {
45146
45152
  }
45147
45153
  var distanceFromLatest = latestEdgeScrollTop - currentScrollTop;
45148
45154
  lastMeasuredLatestEdgeRef.current = latestEdgeScrollTop;
45149
- if (Date.now() < jumpLockUntilRef.current) {
45155
+ if (jumpLockActive) {
45156
+ jumpLockHighWaterMarkRef.current = Math.max(jumpLockHighWaterMarkRef.current, currentScrollTop);
45150
45157
  if (jumpLockModeRef.current === 'latest' && distanceFromLatest > PRELOAD_RESET_PX) {
45151
- clearJumpScrollingLock();
45158
+ if (currentScrollTop < jumpLockHighWaterMarkRef.current - PRELOAD_RESET_PX) {
45159
+ clearJumpScrollingLock();
45160
+ } else {
45161
+ return;
45162
+ }
45152
45163
  } else {
45153
45164
  return;
45154
45165
  }
@@ -45397,12 +45408,12 @@ function useChatController(_ref5) {
45397
45408
  }, [channel.id, clearScrollIdleTimer, dispatch]);
45398
45409
  var departingChannelId = activeChannelIdRef.current;
45399
45410
  if (departingChannelId) {
45400
- var _scrollRef$current$sc, _scrollRef$current;
45411
+ var _scrollRef$current$sc2, _scrollRef$current2;
45401
45412
  var currentMessages = messagesRef.current;
45402
45413
  var startId = getFirstConfirmedMessageId(currentMessages);
45403
45414
  var endId = getLastConfirmedMessageId(currentMessages);
45404
45415
  var anchorId = lastVisibleAnchorIdRef.current;
45405
- var scrollTop = (_scrollRef$current$sc = (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) != null ? _scrollRef$current$sc : 0;
45416
+ var scrollTop = (_scrollRef$current$sc2 = (_scrollRef$current2 = scrollRef.current) === null || _scrollRef$current2 === void 0 ? void 0 : _scrollRef$current2.scrollTop) != null ? _scrollRef$current$sc2 : 0;
45406
45417
  if (startId && endId && anchorId) {
45407
45418
  var confirmedMessages = currentMessages.filter(function (m) {
45408
45419
  return !!m.id;
@@ -45720,9 +45731,7 @@ function useChatController(_ref5) {
45720
45731
  }
45721
45732
  var savedRestoreWindow = channelRestoreWindowMap.get(channel.id);
45722
45733
  if (savedRestoreWindow) {
45723
- if (!channel.isLinkedChannel) {
45724
- dispatch(clearVisibleMessagesMapAC());
45725
- }
45734
+ dispatch(clearVisibleMessagesMapAC());
45726
45735
  if (channel.backToLinkedChannel) {
45727
45736
  restoreRef.current = {
45728
45737
  mode: 'restore-scroll-top',
@@ -45757,9 +45766,7 @@ function useChatController(_ref5) {
45757
45766
  }
45758
45767
  return;
45759
45768
  }
45760
- if (!channel.isLinkedChannel) {
45761
- dispatch(clearVisibleMessagesMapAC());
45762
- }
45769
+ dispatch(clearVisibleMessagesMapAC());
45763
45770
  if (channel.newMessageCount && channel.lastDisplayedMessageId) {
45764
45771
  suppressNextMessageChange();
45765
45772
  dispatch(loadNearUnreadAC(channel));
@@ -45767,7 +45774,7 @@ function useChatController(_ref5) {
45767
45774
  suppressNextMessageChange();
45768
45775
  dispatch(loadDefaultMessagesAC(channel));
45769
45776
  }
45770
- }, [dispatch, channel === null || channel === void 0 ? void 0 : channel.id, channel.backToLinkedChannel, channel.isLinkedChannel, suppressNextMessageChange]);
45777
+ }, [dispatch, channel === null || channel === void 0 ? void 0 : channel.id, channel.backToLinkedChannel, suppressNextMessageChange]);
45771
45778
  useEffect(function () {
45772
45779
  if (!(channel !== null && channel !== void 0 && channel.id) || clearedSelectionChannelIdRef.current === channel.id) {
45773
45780
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.8.8-beta.4",
3
+ "version": "1.8.8-beta.6",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",