sceyt-chat-react-uikit 1.7.9-beta.1 → 1.7.9-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.modern.js CHANGED
@@ -3,7 +3,7 @@ import { createSelectorHook, createDispatchHook, createStoreHook, shallowEqual,
3
3
  import log from 'loglevel';
4
4
  import createSagaMiddleware, { eventChannel } from 'redux-saga';
5
5
  import FileSaver from 'file-saver';
6
- import { select, put, call, take, takeLatest, takeEvery, spawn, all } from 'redux-saga/effects';
6
+ import { select, put, call, take, takeLatest, takeEvery, spawn, delay, all } from 'redux-saga/effects';
7
7
  import { v4 } from 'uuid';
8
8
  import styled, { createGlobalStyle, keyframes } from 'styled-components';
9
9
  import LinkifyIt from 'linkify-it';
@@ -8989,11 +8989,11 @@ var handleVoteDetails = function handleVoteDetails(voteDetails, message) {
8989
8989
  return undefined;
8990
8990
  }
8991
8991
  var existingPollDetails = message.pollDetails;
8992
- var existingVoteDetails = existingPollDetails.voteDetails || {
8992
+ var existingVoteDetails = JSON.parse(JSON.stringify(existingPollDetails.voteDetails || {
8993
8993
  votesPerOption: {},
8994
8994
  votes: [],
8995
8995
  ownVotes: []
8996
- };
8996
+ }));
8997
8997
  if (voteDetails.type === 'close') {
8998
8998
  return _extends({}, existingPollDetails, {
8999
8999
  closed: true
@@ -9005,19 +9005,32 @@ var handleVoteDetails = function handleVoteDetails(voteDetails, message) {
9005
9005
  var vote = voteDetails.vote;
9006
9006
  var optionId = vote.optionId;
9007
9007
  var currentVotesPerOption = existingVoteDetails.votesPerOption || {};
9008
- var optionVotesCount = (currentVotesPerOption[optionId] || 0) + voteDetails.incrementVotesPerOptionCount;
9009
- var newVotesPerOption = _extends({}, currentVotesPerOption, (_extends2 = {}, _extends2[optionId] = optionVotesCount >= 0 ? optionVotesCount : 0, _extends2));
9008
+ var optionVotesCount = currentVotesPerOption[optionId] || 0;
9010
9009
  var newVotes = existingVoteDetails.votes || [];
9011
9010
  var newOwnVotes = existingVoteDetails.ownVotes || [];
9012
9011
  if (voteDetails.type === 'add') {
9013
9012
  newVotes = [].concat(newVotes, [vote]);
9013
+ optionVotesCount++;
9014
9014
  } else if (voteDetails.type === 'delete') {
9015
9015
  newVotes = deleteVoteFromPollDetails(newVotes, vote);
9016
+ optionVotesCount--;
9016
9017
  } else if (voteDetails.type === 'addOwn') {
9017
- newOwnVotes = [].concat(newOwnVotes, [vote]);
9018
+ var existingOwnVote = existingVoteDetails.ownVotes.find(function (v) {
9019
+ return v.optionId === vote.optionId && v.user.id === vote.user.id;
9020
+ });
9021
+ if (!existingOwnVote) {
9022
+ optionVotesCount++;
9023
+ if (existingPollDetails.allowMultipleVotes) {
9024
+ newOwnVotes = [].concat(newOwnVotes, [vote]);
9025
+ } else {
9026
+ newOwnVotes = [vote];
9027
+ }
9028
+ }
9018
9029
  } else if (voteDetails.type === 'deleteOwn') {
9019
9030
  newOwnVotes = deleteVoteFromPollDetails(newOwnVotes, vote);
9031
+ optionVotesCount--;
9020
9032
  }
9033
+ var newVotesPerOption = _extends({}, currentVotesPerOption, (_extends2 = {}, _extends2[optionId] = optionVotesCount >= 0 ? optionVotesCount : 0, _extends2));
9021
9034
  var newVoteDetails = {
9022
9035
  votesPerOption: newVotesPerOption,
9023
9036
  votes: newVotes,
@@ -9058,6 +9071,8 @@ var baseUrlForInviteMembers = '';
9058
9071
  var autoSelectFitsChannel = false;
9059
9072
  var allChannels = [];
9060
9073
  var channelsMap = {};
9074
+ var allChannelsMap = {};
9075
+ var pendingDeleteChannelMap = {};
9061
9076
  var channelTypesMemberDisplayTextMap;
9062
9077
  var defaultRolesByChannelTypesMap;
9063
9078
  var activeChannelId = '';
@@ -9090,6 +9105,7 @@ function getInviteLinkOptions() {
9090
9105
  }
9091
9106
  function setChannelInMap(channel) {
9092
9107
  channelsMap[channel.id] = _extends({}, channel);
9108
+ allChannelsMap[channel.id] = _extends({}, channel);
9093
9109
  }
9094
9110
  function setActiveChannelId(id) {
9095
9111
  activeChannelId = id;
@@ -9105,6 +9121,7 @@ function setChannelsInMap(channels) {
9105
9121
  channelsForUpdateLastReactionMessage.push(channel);
9106
9122
  }
9107
9123
  channelsMap[channel.id] = _extends({}, channel);
9124
+ allChannelsMap[channel.id] = _extends({}, channel);
9108
9125
  return channel;
9109
9126
  });
9110
9127
  return {
@@ -9115,11 +9132,24 @@ function setChannelsInMap(channels) {
9115
9132
  function getChannelFromMap(channelId) {
9116
9133
  return channelsMap[channelId];
9117
9134
  }
9118
- function getLastChannelFromMap() {
9119
- return Object.values(channelsMap)[0];
9135
+ function getLastChannelFromMap(deletePending) {
9136
+ if (deletePending === void 0) {
9137
+ deletePending = false;
9138
+ }
9139
+ var channels = Object.values(channelsMap);
9140
+ if (deletePending) {
9141
+ for (var _iterator = _createForOfIteratorHelperLoose(channels), _step; !(_step = _iterator()).done;) {
9142
+ var channel = _step.value;
9143
+ if (!getPendingDeleteChannel(channel.id)) {
9144
+ return channel;
9145
+ }
9146
+ }
9147
+ }
9148
+ return channels[0];
9120
9149
  }
9121
9150
  function removeChannelFromMap(channelId) {
9122
9151
  delete channelsMap[channelId];
9152
+ delete allChannelsMap[channelId];
9123
9153
  }
9124
9154
  function checkChannelExists(channelId) {
9125
9155
  return !!channelsMap[channelId];
@@ -9206,6 +9236,9 @@ function getChannelFromAllChannels(channelId) {
9206
9236
  return channel.id === channelId;
9207
9237
  });
9208
9238
  }
9239
+ function getChannelFromAllChannelsMap(channelId) {
9240
+ return allChannelsMap[channelId];
9241
+ }
9209
9242
  function deleteChannelFromAllChannels(channelId) {
9210
9243
  allChannels = allChannels.filter(function (channel) {
9211
9244
  return channel.id !== channelId;
@@ -9223,6 +9256,9 @@ function updateChannelLastMessageOnAllChannels(channelId, message) {
9223
9256
  channelsMap[channelId] = _extends({}, chan, {
9224
9257
  lastMessage: message
9225
9258
  });
9259
+ allChannelsMap[channelId] = _extends({}, chan, {
9260
+ lastMessage: message
9261
+ });
9226
9262
  return _extends({}, chan, {
9227
9263
  lastMessage: message
9228
9264
  });
@@ -9245,6 +9281,7 @@ function updateChannelLastMessageOnAllChannels(channelId, message) {
9245
9281
  lastMessage: updateMessage
9246
9282
  });
9247
9283
  channelsMap[channelId] = updateChannel;
9284
+ allChannelsMap[channelId] = updateChannel;
9248
9285
  allChannels = [updateChannel].concat(updatedChannels);
9249
9286
  }
9250
9287
  }
@@ -9267,6 +9304,7 @@ function updateChannelOnAllChannels(channelId, config, messageUpdateData) {
9267
9304
  });
9268
9305
  if (channelsMap[channelId]) {
9269
9306
  channelsMap[channelId] = _extends({}, channelsMap[channelId], config);
9307
+ allChannelsMap[channelId] = _extends({}, channelsMap[channelId], config);
9270
9308
  }
9271
9309
  }
9272
9310
  var getChannelGroupName = function getChannelGroupName(channel) {
@@ -9315,6 +9353,18 @@ var sortChannelByLastMessage = function sortChannelByLastMessage(channels) {
9315
9353
  }
9316
9354
  });
9317
9355
  };
9356
+ var setPendingDeleteChannel = function setPendingDeleteChannel(channel) {
9357
+ pendingDeleteChannelMap[channel === null || channel === void 0 ? void 0 : channel.id] = channel;
9358
+ };
9359
+ var getPendingDeleteChannel = function getPendingDeleteChannel(channelId) {
9360
+ return pendingDeleteChannelMap[channelId];
9361
+ };
9362
+ var getPendingDeleteChannels = function getPendingDeleteChannels() {
9363
+ return Object.values(pendingDeleteChannelMap);
9364
+ };
9365
+ var removePendingDeleteChannel = function removePendingDeleteChannel(channelId) {
9366
+ delete pendingDeleteChannelMap[channelId];
9367
+ };
9318
9368
 
9319
9369
  var initialState = {
9320
9370
  channelsLoadingState: null,
@@ -9373,7 +9423,7 @@ var channelSlice = createSlice({
9373
9423
  }
9374
9424
  },
9375
9425
  setChannels: function setChannels(state, action) {
9376
- state.channels = [].concat(action.payload.channels);
9426
+ state.channels = sortChannelByLastMessage([].concat(action.payload.channels));
9377
9427
  },
9378
9428
  setSearchedChannels: function setSearchedChannels(state, action) {
9379
9429
  state.searchedChannels = action.payload.searchedChannels;
@@ -9546,7 +9596,7 @@ var channelSlice = createSlice({
9546
9596
  })
9547
9597
  });
9548
9598
  }
9549
- state.channels = [].concat(updatedChannels);
9599
+ state.channels = sortChannelByLastMessage([].concat(updatedChannels));
9550
9600
  },
9551
9601
  updateChannelLastMessage: function updateChannelLastMessage(state, action) {
9552
9602
  var _action$payload5 = action.payload,
@@ -9566,6 +9616,7 @@ var channelSlice = createSlice({
9566
9616
  }
9567
9617
  return chan;
9568
9618
  });
9619
+ state.channels = sortChannelByLastMessage(state.channels);
9569
9620
  }
9570
9621
  } else {
9571
9622
  var updatedChannels = state.channels.filter(function (chan) {
@@ -9595,6 +9646,7 @@ var channelSlice = createSlice({
9595
9646
  }
9596
9647
  return chan;
9597
9648
  });
9649
+ state.channels = sortChannelByLastMessage(state.channels);
9598
9650
  },
9599
9651
  setChannelInfoOpenClose: function setChannelInfoOpenClose(state, action) {
9600
9652
  state.channelInfoIsOpen = action.payload.open;
@@ -10809,6 +10861,11 @@ function updatePendingMessageAC(channelId, messageId, updatedMessage) {
10809
10861
  updatedMessage: updatedMessage
10810
10862
  });
10811
10863
  }
10864
+ function setUnreadMessageIdAC(messageId) {
10865
+ return setUnreadMessageId({
10866
+ messageId: messageId
10867
+ });
10868
+ }
10812
10869
 
10813
10870
  var MESSAGES_MAX_PAGE_COUNT = 80;
10814
10871
  var MESSAGES_MAX_LENGTH = 50;
@@ -10999,6 +11056,9 @@ function setMessagesToMap(channelId, messages, firstMessageId, lastMessageId) {
10999
11056
  }
11000
11057
  }
11001
11058
  messages.forEach(function (msg) {
11059
+ if (msg.tid && messagesMap[channelId][msg.tid]) {
11060
+ delete messagesMap[channelId][msg.tid];
11061
+ }
11002
11062
  messagesMap[channelId][msg.id || msg.tid] = msg;
11003
11063
  });
11004
11064
  }
@@ -11326,6 +11386,31 @@ var setPendingPollAction = function setPendingPollAction(action) {
11326
11386
  }
11327
11387
  store.dispatch(setPendingPollActionsMapAC(messageId, action));
11328
11388
  };
11389
+ var getCenterTwoMessages = function getCenterTwoMessages(messages) {
11390
+ var mid = Math.floor(messages.length / 2);
11391
+ if (messages.length % 2 === 0) {
11392
+ return {
11393
+ mid1: {
11394
+ messageId: messages[mid - 1].id,
11395
+ index: mid - 1
11396
+ },
11397
+ mid2: {
11398
+ messageId: messages[mid].id,
11399
+ index: mid
11400
+ }
11401
+ };
11402
+ }
11403
+ return {
11404
+ mid1: {
11405
+ messageId: messages[mid - 1].id,
11406
+ index: mid - 1
11407
+ },
11408
+ mid2: {
11409
+ messageId: messages[mid + 1].id,
11410
+ index: mid + 1
11411
+ }
11412
+ };
11413
+ };
11329
11414
 
11330
11415
  var initialState$1 = {
11331
11416
  messagesLoadingState: null,
@@ -11372,7 +11457,8 @@ var initialState$1 = {
11372
11457
  pollVotesInitialCount: null,
11373
11458
  pendingPollActions: {},
11374
11459
  pendingMessagesMap: {},
11375
- unreadScrollTo: true
11460
+ unreadScrollTo: true,
11461
+ unreadMessageId: ''
11376
11462
  };
11377
11463
  var messageSlice = createSlice({
11378
11464
  name: 'messages',
@@ -11948,6 +12034,9 @@ var messageSlice = createSlice({
11948
12034
  },
11949
12035
  clearPendingMessagesMap: function clearPendingMessagesMap(state) {
11950
12036
  state.pendingMessagesMap = {};
12037
+ },
12038
+ setUnreadMessageId: function setUnreadMessageId(state, action) {
12039
+ state.unreadMessageId = action.payload.messageId;
11951
12040
  }
11952
12041
  },
11953
12042
  extraReducers: function extraReducers(builder) {
@@ -12012,7 +12101,8 @@ var _messageSlice$actions = messageSlice.actions,
12012
12101
  setPendingMessage$1 = _messageSlice$actions.setPendingMessage,
12013
12102
  removePendingMessage = _messageSlice$actions.removePendingMessage,
12014
12103
  updatePendingMessage = _messageSlice$actions.updatePendingMessage,
12015
- updatePendingPollAction = _messageSlice$actions.updatePendingPollAction;
12104
+ updatePendingPollAction = _messageSlice$actions.updatePendingPollAction,
12105
+ setUnreadMessageId = _messageSlice$actions.setUnreadMessageId;
12016
12106
  var MessageReducer = messageSlice.reducer;
12017
12107
 
12018
12108
  var initialState$2 = {
@@ -15726,16 +15816,14 @@ function watchForEvents() {
15726
15816
  vote = _step2.value;
15727
15817
  objs.push({
15728
15818
  type: vote.user.id === SceytChatClient.user.id ? 'deleteOwn' : 'delete',
15729
- vote: vote,
15730
- incrementVotesPerOptionCount: -1
15819
+ vote: vote
15731
15820
  });
15732
15821
  }
15733
15822
  for (_iterator3 = _createForOfIteratorHelperLoose(addedVotes); !(_step3 = _iterator3()).done;) {
15734
15823
  _vote = _step3.value;
15735
15824
  objs.push({
15736
15825
  type: _vote.user.id === SceytChatClient.user.id ? 'addOwn' : 'add',
15737
- vote: _vote,
15738
- incrementVotesPerOptionCount: 1
15826
+ vote: _vote
15739
15827
  });
15740
15828
  }
15741
15829
  _i = 0, _objs = objs;
@@ -15780,8 +15868,7 @@ function watchForEvents() {
15780
15868
  params: {}
15781
15869
  }, {
15782
15870
  type: _obj.type,
15783
- vote: _obj.vote,
15784
- incrementVotesPerOptionCount: _obj.incrementVotesPerOptionCount
15871
+ vote: _obj.vote
15785
15872
  });
15786
15873
  if (!(_channel10.id === _activeChannelId0)) {
15787
15874
  _context.n = 107;
@@ -15810,8 +15897,7 @@ function watchForEvents() {
15810
15897
  _vote2 = _step4.value;
15811
15898
  _objs3.push({
15812
15899
  type: _vote2.user.id === SceytChatClient.user.id ? 'deleteOwn' : 'delete',
15813
- vote: _vote2,
15814
- incrementVotesPerOptionCount: -1
15900
+ vote: _vote2
15815
15901
  });
15816
15902
  }
15817
15903
  _i3 = 0, _objs4 = _objs3;
@@ -15870,8 +15956,7 @@ function watchForEvents() {
15870
15956
  _vote4 = _step5.value;
15871
15957
  _objs6.push({
15872
15958
  type: _vote4.user.id === SceytChatClient.user.id ? 'deleteOwn' : 'delete',
15873
- vote: _vote4,
15874
- incrementVotesPerOptionCount: -1
15959
+ vote: _vote4
15875
15960
  });
15876
15961
  }
15877
15962
  _i5 = 0, _objs7 = _objs6;
@@ -15923,8 +16008,7 @@ function watchForEvents() {
15923
16008
  case 126:
15924
16009
  _activeChannelId11 = _context.v;
15925
16010
  _obj5 = {
15926
- type: 'close',
15927
- incrementVotesPerOptionCount: 0
16011
+ type: 'close'
15928
16012
  };
15929
16013
  updateMessageOnMap(_channel13.id, {
15930
16014
  messageId: _messageId4,
@@ -16302,6 +16386,56 @@ function watchForEvents() {
16302
16386
  }, _marked$1);
16303
16387
  }
16304
16388
 
16389
+ var SDKErrorTypeEnum = {
16390
+ BadRequest: {
16391
+ value: 'BadRequest',
16392
+ isResendable: false
16393
+ },
16394
+ BadParam: {
16395
+ value: 'BadParam',
16396
+ isResendable: false
16397
+ },
16398
+ NotFound: {
16399
+ value: 'NotFound',
16400
+ isResendable: false
16401
+ },
16402
+ NotAllowed: {
16403
+ value: 'NotAllowed',
16404
+ isResendable: false
16405
+ },
16406
+ TooLargeRequest: {
16407
+ value: 'TooLargeRequest',
16408
+ isResendable: false
16409
+ },
16410
+ InternalError: {
16411
+ value: 'InternalError',
16412
+ isResendable: true
16413
+ },
16414
+ TooManyRequests: {
16415
+ value: 'TooManyRequests',
16416
+ isResendable: true
16417
+ },
16418
+ Authentication: {
16419
+ value: 'Authentication',
16420
+ isResendable: true
16421
+ }
16422
+ };
16423
+ var fromValue = function fromValue(value) {
16424
+ if (!value) return null;
16425
+ var entries = Object.values(SDKErrorTypeEnum);
16426
+ return entries.find(function (entry) {
16427
+ return entry.value === value;
16428
+ }) || null;
16429
+ };
16430
+ var isResendableError = function isResendableError(value) {
16431
+ var _errorType$isResendab;
16432
+ if (!value) {
16433
+ return true;
16434
+ }
16435
+ var errorType = fromValue(value);
16436
+ return (_errorType$isResendab = errorType === null || errorType === void 0 ? void 0 : errorType.isResendable) != null ? _errorType$isResendab : true;
16437
+ };
16438
+
16305
16439
  var _marked$2 = /*#__PURE__*/_regenerator().m(createChannel),
16306
16440
  _marked2$1 = /*#__PURE__*/_regenerator().m(getChannels),
16307
16441
  _marked3 = /*#__PURE__*/_regenerator().m(searchChannels),
@@ -16322,28 +16456,29 @@ var _marked$2 = /*#__PURE__*/_regenerator().m(createChannel),
16322
16456
  _marked16 = /*#__PURE__*/_regenerator().m(unpinChannel),
16323
16457
  _marked17 = /*#__PURE__*/_regenerator().m(removeChannelCaches),
16324
16458
  _marked18 = /*#__PURE__*/_regenerator().m(leaveChannel),
16325
- _marked19 = /*#__PURE__*/_regenerator().m(deleteChannel),
16326
- _marked20 = /*#__PURE__*/_regenerator().m(blockChannel),
16327
- _marked21 = /*#__PURE__*/_regenerator().m(updateChannel),
16328
- _marked22 = /*#__PURE__*/_regenerator().m(checkUsersStatus),
16329
- _marked23 = /*#__PURE__*/_regenerator().m(sendTyping),
16330
- _marked24 = /*#__PURE__*/_regenerator().m(sendRecording),
16331
- _marked25 = /*#__PURE__*/_regenerator().m(clearHistory),
16332
- _marked26 = /*#__PURE__*/_regenerator().m(deleteAllMessages),
16333
- _marked27 = /*#__PURE__*/_regenerator().m(joinChannel),
16334
- _marked28 = /*#__PURE__*/_regenerator().m(watchForChannelEvents),
16335
- _marked29 = /*#__PURE__*/_regenerator().m(createChannelInviteKey),
16336
- _marked30 = /*#__PURE__*/_regenerator().m(getChannelInviteKeys),
16337
- _marked31 = /*#__PURE__*/_regenerator().m(regenerateChannelInviteKey),
16338
- _marked32 = /*#__PURE__*/_regenerator().m(updateChannelInviteKey),
16339
- _marked33 = /*#__PURE__*/_regenerator().m(getChannelByInviteKey),
16340
- _marked34 = /*#__PURE__*/_regenerator().m(joinChannelWithInviteKey),
16341
- _marked35 = /*#__PURE__*/_regenerator().m(setMessageRetentionPeriod),
16342
- _marked36 = /*#__PURE__*/_regenerator().m(getChannelsWithUser),
16343
- _marked37 = /*#__PURE__*/_regenerator().m(loadMoreMutualChannels),
16344
- _marked38 = /*#__PURE__*/_regenerator().m(ChannelsSaga);
16459
+ _marked19 = /*#__PURE__*/_regenerator().m(deletePendingDeleteChannels),
16460
+ _marked20 = /*#__PURE__*/_regenerator().m(deleteChannel),
16461
+ _marked21 = /*#__PURE__*/_regenerator().m(blockChannel),
16462
+ _marked22 = /*#__PURE__*/_regenerator().m(updateChannel),
16463
+ _marked23 = /*#__PURE__*/_regenerator().m(checkUsersStatus),
16464
+ _marked24 = /*#__PURE__*/_regenerator().m(sendTyping),
16465
+ _marked25 = /*#__PURE__*/_regenerator().m(sendRecording),
16466
+ _marked26 = /*#__PURE__*/_regenerator().m(clearHistory),
16467
+ _marked27 = /*#__PURE__*/_regenerator().m(deleteAllMessages),
16468
+ _marked28 = /*#__PURE__*/_regenerator().m(joinChannel),
16469
+ _marked29 = /*#__PURE__*/_regenerator().m(watchForChannelEvents),
16470
+ _marked30 = /*#__PURE__*/_regenerator().m(createChannelInviteKey),
16471
+ _marked31 = /*#__PURE__*/_regenerator().m(getChannelInviteKeys),
16472
+ _marked32 = /*#__PURE__*/_regenerator().m(regenerateChannelInviteKey),
16473
+ _marked33 = /*#__PURE__*/_regenerator().m(updateChannelInviteKey),
16474
+ _marked34 = /*#__PURE__*/_regenerator().m(getChannelByInviteKey),
16475
+ _marked35 = /*#__PURE__*/_regenerator().m(joinChannelWithInviteKey),
16476
+ _marked36 = /*#__PURE__*/_regenerator().m(setMessageRetentionPeriod),
16477
+ _marked37 = /*#__PURE__*/_regenerator().m(getChannelsWithUser),
16478
+ _marked38 = /*#__PURE__*/_regenerator().m(loadMoreMutualChannels),
16479
+ _marked39 = /*#__PURE__*/_regenerator().m(ChannelsSaga);
16345
16480
  function createChannel(action) {
16346
- var payload, channelData, dontCreateIfNotExists, callback, SceytChatClient, createChannelData, fileToUpload, isSelfChannel, channelIsExistOnAllChannels, createdChannel, allChannels, memberId, checkChannelExist, messageToSend, _allChannels, _memberId, _t;
16481
+ var payload, channelData, dontCreateIfNotExists, callback, SceytChatClient, createChannelData, fileToUpload, isSelfChannel, channelIsExistOnAllChannels, createdChannel, allChannels, memberId, whoDoesNotAdded, checkChannelExist, messageToSend, _allChannels, _memberId, _t;
16347
16482
  return _regenerator().w(function (_context) {
16348
16483
  while (1) switch (_context.p = _context.n) {
16349
16484
  case 0:
@@ -16435,26 +16570,38 @@ function createChannel(action) {
16435
16570
  case 7:
16436
16571
  createdChannel = _context.v;
16437
16572
  case 8:
16573
+ whoDoesNotAdded = channelData.members.filter(function (mem) {
16574
+ return !createdChannel.members.some(function (addedMem) {
16575
+ return addedMem.id === mem.id;
16576
+ });
16577
+ });
16578
+ if (!whoDoesNotAdded.length) {
16579
+ _context.n = 9;
16580
+ break;
16581
+ }
16582
+ _context.n = 9;
16583
+ return put(setActionIsRestrictedAC(true, false, whoDoesNotAdded));
16584
+ case 9:
16438
16585
  checkChannelExist = false;
16439
16586
  if (!(createdChannel.type === DEFAULT_CHANNEL_TYPE.DIRECT)) {
16440
- _context.n = 10;
16587
+ _context.n = 11;
16441
16588
  break;
16442
16589
  }
16443
- _context.n = 9;
16590
+ _context.n = 10;
16444
16591
  return call(checkChannelExists, createdChannel.id);
16445
- case 9:
16446
- checkChannelExist = _context.v;
16447
16592
  case 10:
16593
+ checkChannelExist = _context.v;
16594
+ case 11:
16448
16595
  createdChannel.metadata = isJSON(createdChannel.metadata) ? JSON.parse(createdChannel.metadata) : createdChannel.metadata;
16449
16596
  if (checkChannelExist) {
16450
- _context.n = 13;
16597
+ _context.n = 14;
16451
16598
  break;
16452
16599
  }
16453
- _context.n = 11;
16600
+ _context.n = 12;
16454
16601
  return call(setChannelInMap, createdChannel);
16455
- case 11:
16602
+ case 12:
16456
16603
  if (!(createdChannel.type !== DEFAULT_CHANNEL_TYPE.DIRECT)) {
16457
- _context.n = 12;
16604
+ _context.n = 13;
16458
16605
  break;
16459
16606
  }
16460
16607
  messageToSend = {
@@ -16463,21 +16610,21 @@ function createChannel(action) {
16463
16610
  attachments: [],
16464
16611
  type: 'system'
16465
16612
  };
16466
- _context.n = 12;
16613
+ _context.n = 13;
16467
16614
  return put(sendTextMessageAC(messageToSend, createdChannel.id, CONNECTION_STATUS.CONNECTED));
16468
- case 12:
16615
+ case 13:
16469
16616
  if (!(!dontCreateIfNotExists || channelIsExistOnAllChannels)) {
16470
- _context.n = 13;
16617
+ _context.n = 14;
16471
16618
  break;
16472
16619
  }
16473
- _context.n = 13;
16474
- return put(setChannelToAddAC(JSON.parse(JSON.stringify(createdChannel))));
16475
- case 13:
16476
16620
  _context.n = 14;
16621
+ return put(setChannelToAddAC(JSON.parse(JSON.stringify(createdChannel))));
16622
+ case 14:
16623
+ _context.n = 15;
16477
16624
  return put(switchChannelActionAC(JSON.parse(JSON.stringify(_extends({}, createdChannel, {
16478
16625
  isLinkedChannel: dontCreateIfNotExists
16479
16626
  }))), !callback));
16480
- case 14:
16627
+ case 15:
16481
16628
  if (dontCreateIfNotExists) {
16482
16629
  if (!channelIsExistOnAllChannels) {
16483
16630
  addChannelToAllChannels(createdChannel);
@@ -16507,60 +16654,56 @@ function createChannel(action) {
16507
16654
  }
16508
16655
  }
16509
16656
  if (!callback) {
16510
- _context.n = 15;
16657
+ _context.n = 16;
16511
16658
  break;
16512
16659
  }
16513
16660
  callback(createdChannel);
16514
- _context.n = 16;
16661
+ _context.n = 17;
16515
16662
  break;
16516
- case 15:
16517
- _context.n = 16;
16518
- return call(setActiveChannelId, createdChannel.id);
16519
16663
  case 16:
16664
+ _context.n = 17;
16665
+ return call(setActiveChannelId, createdChannel.id);
16666
+ case 17:
16520
16667
  _context.n = 19;
16521
16668
  break;
16522
- case 17:
16523
- _context.p = 17;
16524
- _t = _context.v;
16525
- if (!(_t.code === 1041)) {
16526
- _context.n = 18;
16527
- break;
16528
- }
16529
- _context.n = 18;
16530
- return put(setActionIsRestrictedAC(true, false, null));
16531
16669
  case 18:
16670
+ _context.p = 18;
16671
+ _t = _context.v;
16532
16672
  log.error(_t, 'Error on create channel');
16533
16673
  case 19:
16534
16674
  return _context.a(2);
16535
16675
  }
16536
- }, _marked$2, null, [[0, 17]]);
16676
+ }, _marked$2, null, [[0, 18]]);
16537
16677
  }
16538
16678
  function getChannels(action) {
16539
- var _params$filter, _types, _activeChannel, _mappedChannels, _mappedChannels3, _mappedChannels4, payload, params, SceytChatClient, connectionStatus, channelQueryBuilder, channelTypesFilter, types, limit, channelQuery, channelsData, channelList, channelId, activeChannel, _yield$call, mappedChannels, channelsForUpdateLastReactionMessage, _Object$keys, _mappedChannels2, channelMessageMap, _activeChannel2, _activeChannel3, hiddenList, allChannelsQueryBuilder, allChannelsQuery, hasNext, totalAllChannelsAdded, i, _connectionStatus, allChannelsData, allChannelList, _t2, _t3, _t4;
16679
+ var _params$filter, _types, _activeChannel, _mappedChannels, _mappedChannels3, _mappedChannels4, payload, params, SceytChatClient, connectionStatus, channelQueryBuilder, channelTypesFilter, types, limit, channelQuery, channelsData, channelList, channelId, activeChannel, _yield$call, mappedChannels, channelsForUpdateLastReactionMessage, _Object$keys, _Object$keys2, _mappedChannels2, channelMessageMap, _activeChannel2, _activeChannel3, hiddenList, allChannelsQueryBuilder, allChannelsQuery, hasNext, totalAllChannelsAdded, i, _connectionStatus, allChannelsData, allChannelList, _t2, _t3, _t4;
16540
16680
  return _regenerator().w(function (_context2) {
16541
16681
  while (1) switch (_context2.p = _context2.n) {
16542
16682
  case 0:
16543
- log.info('[getChannels] start get channels');
16683
+ log.info(new Date().toISOString() + " [getChannels] start get channels");
16544
16684
  _context2.p = 1;
16545
16685
  payload = action.payload;
16546
16686
  params = payload.params;
16547
- log.info('[getChannels] input params:', JSON.stringify(params));
16687
+ _context2.n = 2;
16688
+ return call(deletePendingDeleteChannels);
16689
+ case 2:
16690
+ log.info(new Date().toISOString() + " [getChannels] input params: " + JSON.stringify(params));
16548
16691
  SceytChatClient = getClient();
16549
16692
  connectionStatus = store.getState().UserReducer.connectionStatus;
16550
- log.info('[getChannels] connection status:', connectionStatus);
16693
+ log.info(new Date().toISOString() + " [getChannels] connection status: " + connectionStatus);
16551
16694
  if (!(connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
16552
- _context2.n = 2;
16695
+ _context2.n = 3;
16553
16696
  break;
16554
16697
  }
16555
- log.warn('[getChannels] connection not ready, aborting. Status:', connectionStatus);
16698
+ log.warn(new Date().toISOString() + " [getChannels] connection not ready, aborting. Status: " + connectionStatus);
16556
16699
  return _context2.a(2);
16557
- case 2:
16558
- _context2.n = 3;
16559
- return put(setChannelsLoadingStateAC(LOADING_STATE.LOADING));
16560
16700
  case 3:
16701
+ _context2.n = 4;
16702
+ return put(setChannelsLoadingStateAC(LOADING_STATE.LOADING));
16703
+ case 4:
16561
16704
  channelQueryBuilder = new SceytChatClient.ChannelListQueryBuilder();
16562
16705
  channelTypesFilter = getChannelTypesFilter();
16563
- log.info('[getChannels] channelTypesFilter:', JSON.stringify(channelTypesFilter));
16706
+ log.info(new Date().toISOString() + " [getChannels] channelTypesFilter: " + JSON.stringify(channelTypesFilter));
16564
16707
  types = [];
16565
16708
  if (channelTypesFilter !== null && channelTypesFilter !== void 0 && channelTypesFilter.length) {
16566
16709
  types = channelTypesFilter;
@@ -16568,77 +16711,77 @@ function getChannels(action) {
16568
16711
  if (params !== null && params !== void 0 && (_params$filter = params.filter) !== null && _params$filter !== void 0 && _params$filter.channelType) {
16569
16712
  types.push(params.filter.channelType);
16570
16713
  }
16571
- log.info('[getChannels] final types array:', JSON.stringify(types));
16714
+ log.info(new Date().toISOString() + " [getChannels] final types array: " + JSON.stringify(types));
16572
16715
  if ((_types = types) !== null && _types !== void 0 && _types.length) {
16573
16716
  channelQueryBuilder.types(types);
16574
16717
  }
16575
16718
  if (params.memberCount) {
16576
- log.info('[getChannels] setting memberCount filter:', params === null || params === void 0 ? void 0 : params.memberCount);
16719
+ log.info(new Date().toISOString() + " [getChannels] setting memberCount filter: " + (params === null || params === void 0 ? void 0 : params.memberCount));
16577
16720
  channelQueryBuilder.memberCount(params.memberCount);
16578
16721
  }
16579
16722
  channelQueryBuilder.order('lastMessage');
16580
16723
  limit = params.limit || 50;
16581
- log.info('[getChannels] query limit:', limit);
16724
+ log.info(new Date().toISOString() + " [getChannels] query limit: " + limit);
16582
16725
  channelQueryBuilder.limit(limit);
16583
- _context2.n = 4;
16726
+ _context2.n = 5;
16584
16727
  return call(channelQueryBuilder.build);
16585
- case 4:
16728
+ case 5:
16586
16729
  channelQuery = _context2.v;
16587
- log.info('[getChannels] query built successfully');
16588
- _context2.n = 5;
16730
+ log.info(new Date().toISOString() + " [getChannels] query built successfully");
16731
+ _context2.n = 6;
16589
16732
  return call(channelQuery.loadNextPage);
16590
- case 5:
16733
+ case 6:
16591
16734
  channelsData = _context2.v;
16592
16735
  channelList = channelsData.channels;
16593
- log.info('[getChannels] channelsData received:', JSON.stringify({
16736
+ log.info(new Date().toISOString() + " [getChannels] channelsData received: " + JSON.stringify({
16594
16737
  channelsCount: (channelList === null || channelList === void 0 ? void 0 : channelList.length) || 0,
16595
16738
  hasNext: channelsData.hasNext
16596
16739
  }));
16597
- _context2.n = 6;
16598
- return put(channelHasNextAC(channelsData.hasNext));
16599
- case 6:
16600
16740
  _context2.n = 7;
16601
- return call(getActiveChannelId);
16741
+ return put(channelHasNextAC(channelsData.hasNext));
16602
16742
  case 7:
16743
+ _context2.n = 8;
16744
+ return call(getActiveChannelId);
16745
+ case 8:
16603
16746
  channelId = _context2.v;
16604
- log.info('[getChannels] active channelId:', channelId);
16747
+ log.info(new Date().toISOString() + " [getChannels] active channelId: " + channelId);
16605
16748
  if (!channelId) {
16606
- _context2.n = 9;
16749
+ _context2.n = 10;
16607
16750
  break;
16608
16751
  }
16609
- _context2.n = 8;
16752
+ _context2.n = 9;
16610
16753
  return call(getChannelFromMap, channelId);
16611
- case 8:
16754
+ case 9:
16612
16755
  _t2 = _context2.v;
16613
- _context2.n = 10;
16756
+ _context2.n = 11;
16614
16757
  break;
16615
- case 9:
16616
- _t2 = null;
16617
16758
  case 10:
16618
- activeChannel = _t2;
16619
- log.info('[getChannels] activeChannel from map:', activeChannel ? (_activeChannel = activeChannel) === null || _activeChannel === void 0 ? void 0 : _activeChannel.id : 'null');
16620
- _context2.n = 11;
16621
- return call(destroyChannelsMap);
16759
+ _t2 = null;
16622
16760
  case 11:
16623
- log.info('[getChannels] channels map destroyed');
16761
+ activeChannel = _t2;
16762
+ log.info(new Date().toISOString() + " [getChannels] activeChannel from map: " + (activeChannel ? (_activeChannel = activeChannel) === null || _activeChannel === void 0 ? void 0 : _activeChannel.id : 'null'));
16624
16763
  _context2.n = 12;
16625
- return call(setChannelsInMap, channelList);
16764
+ return call(destroyChannelsMap);
16626
16765
  case 12:
16766
+ log.info(new Date().toISOString() + " [getChannels] channels map destroyed");
16767
+ _context2.n = 13;
16768
+ return call(setChannelsInMap, channelList);
16769
+ case 13:
16627
16770
  _yield$call = _context2.v;
16628
16771
  mappedChannels = _yield$call.channels;
16629
16772
  channelsForUpdateLastReactionMessage = _yield$call.channelsForUpdateLastReactionMessage;
16630
- log.info('[getChannels] setChannelsInMap result:', JSON.stringify({
16773
+ log.info(new Date().toISOString() + " [getChannels] setChannelsInMap result: " + JSON.stringify({
16631
16774
  mappedChannelsCount: ((_mappedChannels = mappedChannels) === null || _mappedChannels === void 0 ? void 0 : _mappedChannels.length) || 0,
16632
16775
  channelsForUpdateLastReactionMessageCount: (channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length) || 0
16633
16776
  }));
16634
- log.info('channelsForUpdateLastReactionMessage', channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length);
16777
+ log.info(new Date().toISOString() + " channelsForUpdateLastReactionMessage: " + (channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length));
16635
16778
  if (!(channelsForUpdateLastReactionMessage !== null && channelsForUpdateLastReactionMessage !== void 0 && channelsForUpdateLastReactionMessage.length)) {
16636
- _context2.n = 14;
16779
+ _context2.n = 15;
16637
16780
  break;
16638
16781
  }
16639
- log.info('[getChannels] processing channels for reaction message update:', channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length);
16782
+ log.info(new Date().toISOString() + " [getChannels] processing channels for\n reaction message update: " + (channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length));
16640
16783
  channelMessageMap = {};
16641
- _context2.n = 13;
16784
+ _context2.n = 14;
16642
16785
  return call(function () {
16643
16786
  try {
16644
16787
  return Promise.resolve(Promise.all(channelsForUpdateLastReactionMessage.map(function (channel) {
@@ -16646,10 +16789,10 @@ function getChannels(action) {
16646
16789
  return Promise.resolve(new Promise(function (resolve) {
16647
16790
  channel.getMessagesById([channel.newReactions[0].messageId]).then(function (messages) {
16648
16791
  channelMessageMap[channel === null || channel === void 0 ? void 0 : channel.id] = messages[0];
16649
- log.info('[getChannels] successfully fetched reaction message for channel:', channel === null || channel === void 0 ? void 0 : channel.id);
16792
+ log.info(new Date().toISOString() + " [getChannels] successfully fetched reaction message for channel: " + (channel === null || channel === void 0 ? void 0 : channel.id));
16650
16793
  resolve(true);
16651
16794
  })["catch"](function (e) {
16652
- log.error(e, 'Error on getMessagesById for channel:', channel === null || channel === void 0 ? void 0 : channel.id);
16795
+ log.error(e, "Error on getMessagesById for channel: " + (channel === null || channel === void 0 ? void 0 : channel.id));
16653
16796
  resolve(true);
16654
16797
  });
16655
16798
  }));
@@ -16661,133 +16804,133 @@ function getChannels(action) {
16661
16804
  return Promise.reject(e);
16662
16805
  }
16663
16806
  });
16664
- case 13:
16665
- log.info('[getChannels] reaction messages fetched:', channelMessageMap ? (_Object$keys = Object.keys(channelMessageMap)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length : 0);
16807
+ case 14:
16808
+ log.info(new Date().toISOString() + " [getChannels] reaction messages fetched: " + (channelMessageMap ? (_Object$keys = Object.keys(channelMessageMap)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length : 0), channelMessageMap ? (_Object$keys2 = Object.keys(channelMessageMap)) === null || _Object$keys2 === void 0 ? void 0 : _Object$keys2.length : 0);
16666
16809
  mappedChannels = mappedChannels.map(function (channel) {
16667
16810
  if (channelMessageMap[channel === null || channel === void 0 ? void 0 : channel.id]) {
16668
16811
  channel.lastReactedMessage = channelMessageMap[channel === null || channel === void 0 ? void 0 : channel.id];
16669
16812
  }
16670
16813
  return channel;
16671
16814
  });
16672
- log.info('[getChannels] mappedChannels updated with reaction messages, final count:', ((_mappedChannels2 = mappedChannels) === null || _mappedChannels2 === void 0 ? void 0 : _mappedChannels2.length) || 0);
16673
- case 14:
16674
- log.info('[getChannels] setting channels in state, count:', ((_mappedChannels3 = mappedChannels) === null || _mappedChannels3 === void 0 ? void 0 : _mappedChannels3.length) || 0);
16675
- _context2.n = 15;
16676
- return put(setChannelsAC(mappedChannels));
16815
+ log.info(new Date().toISOString() + " [getChannels] mappedChannels updated with reaction messages, final count: " + (((_mappedChannels2 = mappedChannels) === null || _mappedChannels2 === void 0 ? void 0 : _mappedChannels2.length) || 0));
16677
16816
  case 15:
16817
+ log.info(new Date().toISOString() + " [getChannels] setting channels in state, count: " + (((_mappedChannels3 = mappedChannels) === null || _mappedChannels3 === void 0 ? void 0 : _mappedChannels3.length) || 0));
16818
+ _context2.n = 16;
16819
+ return put(setChannelsAC(mappedChannels));
16820
+ case 16:
16678
16821
  if (!channelId) {
16679
16822
  activeChannel = channelList[0];
16680
- log.info('[getChannels] no active channelId, setting first channel as active:', (_activeChannel2 = activeChannel) === null || _activeChannel2 === void 0 ? void 0 : _activeChannel2.id);
16823
+ log.info(new Date().toISOString() + " [getChannels] no active channelId, setting first channel as active: " + ((_activeChannel2 = activeChannel) === null || _activeChannel2 === void 0 ? void 0 : _activeChannel2.id));
16681
16824
  }
16682
16825
  query.channelQuery = channelQuery;
16683
16826
  if (!(activeChannel && getAutoSelectFitsChannel())) {
16684
- _context2.n = 16;
16827
+ _context2.n = 17;
16685
16828
  break;
16686
16829
  }
16687
- log.info('[getChannels] auto-selecting channel:', (_activeChannel3 = activeChannel) === null || _activeChannel3 === void 0 ? void 0 : _activeChannel3.id);
16688
- _context2.n = 16;
16689
- return put(switchChannelActionAC(JSON.parse(JSON.stringify(activeChannel))));
16690
- case 16:
16830
+ log.info(new Date().toISOString() + " [getChannels] auto-selecting channel: " + ((_activeChannel3 = activeChannel) === null || _activeChannel3 === void 0 ? void 0 : _activeChannel3.id));
16691
16831
  _context2.n = 17;
16692
- return put(setChannelsLoadingStateAC(LOADING_STATE.LOADED));
16832
+ return put(switchChannelActionAC(JSON.parse(JSON.stringify(activeChannel))));
16693
16833
  case 17:
16834
+ _context2.n = 18;
16835
+ return put(setChannelsLoadingStateAC(LOADING_STATE.LOADED));
16836
+ case 18:
16694
16837
  hiddenList = store.getState().ChannelReducer.hideChannelList;
16695
- log.info('[getChannels] hiddenList state:', hiddenList);
16838
+ log.info(new Date().toISOString() + " [getChannels] hiddenList state: " + hiddenList);
16696
16839
  if (hiddenList) {
16697
- _context2.n = 28;
16840
+ _context2.n = 29;
16698
16841
  break;
16699
16842
  }
16700
- log.info('[getChannels] starting all channels query (hiddenList is false)');
16843
+ log.info(new Date().toISOString() + " [getChannels] starting all channels query (hiddenList is false)");
16701
16844
  allChannelsQueryBuilder = new SceytChatClient.ChannelListQueryBuilder();
16702
16845
  allChannelsQueryBuilder.order('lastMessage');
16703
16846
  if (channelTypesFilter !== null && channelTypesFilter !== void 0 && channelTypesFilter.length) {
16704
16847
  allChannelsQueryBuilder.types(channelTypesFilter);
16705
- log.info('[getChannels] allChannelsQuery types:', JSON.stringify(channelTypesFilter));
16848
+ log.info(new Date().toISOString() + " [getChannels] allChannelsQuery types: " + JSON.stringify(channelTypesFilter));
16706
16849
  }
16707
16850
  if (params !== null && params !== void 0 && params.memberCount) {
16708
16851
  allChannelsQueryBuilder.memberCount(params.memberCount);
16709
- log.info('[getChannels] allChannelsQuery memberCount:', params === null || params === void 0 ? void 0 : params.memberCount);
16852
+ log.info(new Date().toISOString() + " [getChannels] allChannelsQuery memberCount: " + (params === null || params === void 0 ? void 0 : params.memberCount));
16710
16853
  }
16711
16854
  allChannelsQueryBuilder.limit(50);
16712
- _context2.n = 18;
16855
+ _context2.n = 19;
16713
16856
  return call(allChannelsQueryBuilder.build);
16714
- case 18:
16857
+ case 19:
16715
16858
  allChannelsQuery = _context2.v;
16716
- log.info('[getChannels] allChannelsQuery built');
16859
+ log.info(new Date().toISOString() + " [getChannels] allChannelsQuery built");
16717
16860
  hasNext = true;
16718
16861
  totalAllChannelsAdded = 0;
16719
16862
  i = 0;
16720
- case 19:
16863
+ case 20:
16721
16864
  if (!(i <= 4)) {
16722
- _context2.n = 27;
16865
+ _context2.n = 28;
16723
16866
  break;
16724
16867
  }
16725
16868
  if (!hasNext) {
16726
- _context2.n = 25;
16869
+ _context2.n = 26;
16727
16870
  break;
16728
16871
  }
16729
- _context2.p = 20;
16872
+ _context2.p = 21;
16730
16873
  _connectionStatus = store.getState().UserReducer.connectionStatus;
16731
16874
  if (!(_connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
16732
- _context2.n = 21;
16875
+ _context2.n = 22;
16733
16876
  break;
16734
16877
  }
16735
- log.warn('[getChannels] connection not ready, aborting. Status:', _connectionStatus);
16736
- return _context2.a(3, 27);
16737
- case 21:
16738
- log.info('[getChannels] loading all channels page:', i + 1);
16739
- _context2.n = 22;
16740
- return call(allChannelsQuery.loadNextPage);
16878
+ log.warn(new Date().toISOString() + " [getChannels] connection not ready, aborting. Status: " + _connectionStatus);
16879
+ return _context2.a(3, 28);
16741
16880
  case 22:
16881
+ log.info(new Date().toISOString() + " [getChannels] loading all channels page: " + (i + 1));
16882
+ _context2.n = 23;
16883
+ return call(allChannelsQuery.loadNextPage);
16884
+ case 23:
16742
16885
  allChannelsData = _context2.v;
16743
16886
  hasNext = allChannelsData.hasNext;
16744
16887
  allChannelList = allChannelsData.channels;
16745
- log.info('[getChannels] all channels page', i + 1, 'loaded:', JSON.stringify({
16888
+ log.info(new Date().toISOString() + " [getChannels] all channels page: " + (i + 1), i + 1, 'loaded:', JSON.stringify({
16746
16889
  channelsCount: (allChannelList === null || allChannelList === void 0 ? void 0 : allChannelList.length) || 0,
16747
16890
  hasNext: hasNext
16748
16891
  }));
16749
16892
  addChannelsToAllChannels(allChannelList);
16750
16893
  totalAllChannelsAdded += (allChannelList === null || allChannelList === void 0 ? void 0 : allChannelList.length) || 0;
16751
- log.info('[getChannels] total all channels added so far:', totalAllChannelsAdded);
16752
- _context2.n = 24;
16894
+ log.info(new Date().toISOString() + " [getChannels] total all channels added so far: " + totalAllChannelsAdded);
16895
+ _context2.n = 25;
16753
16896
  break;
16754
- case 23:
16755
- _context2.p = 23;
16756
- _t3 = _context2.v;
16757
- log.error(_t3, 'Error on get all channels page:', i + 1);
16758
- return _context2.a(3, 27);
16759
16897
  case 24:
16760
- _context2.n = 26;
16761
- break;
16898
+ _context2.p = 24;
16899
+ _t3 = _context2.v;
16900
+ log.error(_t3, "Error on get all channels page: " + (i + 1));
16901
+ return _context2.a(3, 28);
16762
16902
  case 25:
16763
- log.info('[getChannels] no more pages available, stopping at iteration:', i);
16764
- case 26:
16765
- i++;
16766
- _context2.n = 19;
16903
+ _context2.n = 27;
16767
16904
  break;
16905
+ case 26:
16906
+ log.info(new Date().toISOString() + " [getChannels] no more pages available, stopping at iteration: " + i);
16768
16907
  case 27:
16769
- log.info('[getChannels] all channels query completed, total channels added:', totalAllChannelsAdded);
16770
- _context2.n = 29;
16908
+ i++;
16909
+ _context2.n = 20;
16771
16910
  break;
16772
16911
  case 28:
16773
- log.info('[getChannels] skipping all channels query (hiddenList is true)');
16774
- case 29:
16775
- log.info('[getChannels] completed successfully. Final mapped channels count:', ((_mappedChannels4 = mappedChannels) === null || _mappedChannels4 === void 0 ? void 0 : _mappedChannels4.length) || 0);
16776
- _context2.n = 31;
16912
+ log.info(new Date().toISOString() + " [getChannels] all channels query completed, total channels added: " + totalAllChannelsAdded);
16913
+ _context2.n = 30;
16777
16914
  break;
16915
+ case 29:
16916
+ log.info(new Date().toISOString() + " [getChannels] skipping all channels query (hiddenList is true)");
16778
16917
  case 30:
16779
- _context2.p = 30;
16918
+ log.info(new Date().toISOString() + " [getChannels] completed successfully. Final mapped channels count: " + (((_mappedChannels4 = mappedChannels) === null || _mappedChannels4 === void 0 ? void 0 : _mappedChannels4.length) || 0));
16919
+ _context2.n = 32;
16920
+ break;
16921
+ case 31:
16922
+ _context2.p = 31;
16780
16923
  _t4 = _context2.v;
16781
- log.error('[getChannels] error occurred:', JSON.stringify(_t4), 'Error on get channels');
16782
- log.error('[getChannels] error details:', {
16924
+ log.error(new Date().toISOString() + " [getChannels] error occurred: " + JSON.stringify(_t4), 'Error on get channels');
16925
+ log.error(new Date().toISOString() + " [getChannels] error details: " + JSON.stringify({
16783
16926
  message: _t4.message,
16784
16927
  code: _t4.code,
16785
16928
  stack: _t4.stack
16786
- });
16787
- case 31:
16929
+ }));
16930
+ case 32:
16788
16931
  return _context2.a(2);
16789
16932
  }
16790
- }, _marked2$1, null, [[20, 23], [1, 30]]);
16933
+ }, _marked2$1, null, [[21, 24], [1, 31]]);
16791
16934
  }
16792
16935
  function searchChannels(action) {
16793
16936
  var payload, params, contactsMap, SceytChatClient, getFromContacts, searchBy, _params$filter2, _types2, channelQueryBuilder, channelTypesFilter, types, allChannels, publicChannels, chatsGroups, contactsList, contactsWithChannelsMap, lowerCaseSearchBy, handleChannels, channelsMap, _iterator, _step, channel, channelQuery, channelsData, _iterator2, _step2, _channel, channelsToAdd, _t5;
@@ -17110,56 +17253,56 @@ function searchChannelsForForward(action) {
17110
17253
  }, _marked5, null, [[0, 7]]);
17111
17254
  }
17112
17255
  function channelsLoadMore(action) {
17113
- var _mappedChannels5, _mappedChannels7, _mappedChannels8, payload, limit, channelQuery, channelsData, channelList, _yield$call3, mappedChannels, channelsForUpdateLastReactionMessage, _Object$keys2, _mappedChannels6, channelMessageMap, _t8;
17256
+ var _mappedChannels5, _mappedChannels7, _mappedChannels8, payload, limit, channelQuery, channelsData, channelList, _yield$call3, mappedChannels, channelsForUpdateLastReactionMessage, _Object$keys3, _mappedChannels6, channelMessageMap, _t8;
17114
17257
  return _regenerator().w(function (_context6) {
17115
17258
  while (1) switch (_context6.p = _context6.n) {
17116
17259
  case 0:
17117
- log.info('[channelsLoadMore] start load more channels');
17260
+ log.info(new Date().toISOString() + " [channelsLoadMore] start load more channels");
17118
17261
  _context6.p = 1;
17119
17262
  payload = action.payload;
17120
17263
  limit = payload.limit;
17121
- log.info('[channelsLoadMore] input payload:', JSON.stringify({
17264
+ log.info(new Date().toISOString() + " [channelsLoadMore] input payload:", JSON.stringify({
17122
17265
  limit: limit
17123
17266
  }));
17124
17267
  channelQuery = query.channelQuery;
17125
- log.info('[channelsLoadMore] channelQuery exists:', !!channelQuery);
17268
+ log.info(new Date().toISOString() + " [channelsLoadMore] channelQuery exists:", !!channelQuery);
17126
17269
  if (channelQuery) {
17127
17270
  _context6.n = 2;
17128
17271
  break;
17129
17272
  }
17130
- log.error('[channelsLoadMore] channelQuery is null or undefined, cannot load more');
17273
+ log.error(new Date().toISOString() + " [channelsLoadMore] channelQuery is null or undefined, cannot load more");
17131
17274
  return _context6.a(2);
17132
17275
  case 2:
17133
17276
  if (limit) {
17134
- log.info('[channelsLoadMore] setting query limit to:', limit);
17277
+ log.info(new Date().toISOString() + " [channelsLoadMore] setting query limit to:", limit);
17135
17278
  channelQuery.limit = limit;
17136
17279
  } else {
17137
- log.info('[channelsLoadMore] no limit provided, using existing query limit');
17280
+ log.info(new Date().toISOString() + " [channelsLoadMore] no limit provided, using existing query limit");
17138
17281
  }
17139
17282
  _context6.n = 3;
17140
17283
  return put(setChannelsLoadingStateAC(LOADING_STATE.LOADING));
17141
17284
  case 3:
17142
- log.info('[channelsLoadMore] loading next page...');
17285
+ log.info(new Date().toISOString() + " [channelsLoadMore] loading next page...");
17143
17286
  _context6.n = 4;
17144
17287
  return call(channelQuery.loadNextPage);
17145
17288
  case 4:
17146
17289
  channelsData = _context6.v;
17147
17290
  channelList = channelsData.channels;
17148
- log.info('[channelsLoadMore] channelsData received:', JSON.stringify({
17291
+ log.info(new Date().toISOString() + " [channelsLoadMore] channelsData received:", JSON.stringify({
17149
17292
  channelsCount: (channelList === null || channelList === void 0 ? void 0 : channelList.length) || 0,
17150
17293
  hasNext: channelsData.hasNext
17151
17294
  }));
17152
17295
  _context6.n = 5;
17153
17296
  return put(channelHasNextAC(channelsData.hasNext));
17154
17297
  case 5:
17155
- log.info('[channelsLoadMore] hasNext set to:', channelsData.hasNext);
17298
+ log.info(new Date().toISOString() + " [channelsLoadMore] hasNext set to:", channelsData.hasNext);
17156
17299
  _context6.n = 6;
17157
17300
  return call(setChannelsInMap, channelsData.channels);
17158
17301
  case 6:
17159
17302
  _yield$call3 = _context6.v;
17160
17303
  mappedChannels = _yield$call3.channels;
17161
17304
  channelsForUpdateLastReactionMessage = _yield$call3.channelsForUpdateLastReactionMessage;
17162
- log.info('[channelsLoadMore] setChannelsInMap result:', JSON.stringify({
17305
+ log.info(new Date().toISOString() + " [channelsLoadMore] setChannelsInMap result:", JSON.stringify({
17163
17306
  mappedChannelsCount: ((_mappedChannels5 = mappedChannels) === null || _mappedChannels5 === void 0 ? void 0 : _mappedChannels5.length) || 0,
17164
17307
  channelsForUpdateLastReactionMessageCount: (channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length) || 0
17165
17308
  }));
@@ -17167,7 +17310,7 @@ function channelsLoadMore(action) {
17167
17310
  _context6.n = 8;
17168
17311
  break;
17169
17312
  }
17170
- log.info('[channelsLoadMore] processing channels for reaction message update:', channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length);
17313
+ log.info(new Date().toISOString() + " [channelsLoadMore] processing channels for reaction message update:", channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length);
17171
17314
  channelMessageMap = {};
17172
17315
  _context6.n = 7;
17173
17316
  return call(function () {
@@ -17177,7 +17320,7 @@ function channelsLoadMore(action) {
17177
17320
  return Promise.resolve(new Promise(function (resolve) {
17178
17321
  channel.getMessagesById([channel.newReactions[0].messageId]).then(function (messages) {
17179
17322
  channelMessageMap[channel.id] = messages[0];
17180
- log.info('[channelsLoadMore] successfully fetched reaction message for channel:', channel === null || channel === void 0 ? void 0 : channel.id);
17323
+ log.info(new Date().toISOString() + " [channelsLoadMore] successfully fetched reaction message for channel:", channel === null || channel === void 0 ? void 0 : channel.id);
17181
17324
  resolve(true);
17182
17325
  })["catch"](function (e) {
17183
17326
  log.error(e, 'Error on getMessagesById for channel:', channel === null || channel === void 0 ? void 0 : channel.id);
@@ -17193,34 +17336,34 @@ function channelsLoadMore(action) {
17193
17336
  }
17194
17337
  });
17195
17338
  case 7:
17196
- log.info('[channelsLoadMore] reaction messages fetched:', channelMessageMap ? (_Object$keys2 = Object.keys(channelMessageMap)) === null || _Object$keys2 === void 0 ? void 0 : _Object$keys2.length : 0);
17339
+ log.info(new Date().toISOString() + " [channelsLoadMore] reaction messages fetched:", channelMessageMap ? (_Object$keys3 = Object.keys(channelMessageMap)) === null || _Object$keys3 === void 0 ? void 0 : _Object$keys3.length : 0);
17197
17340
  mappedChannels = mappedChannels.map(function (channel) {
17198
17341
  if (channelMessageMap[channel.id]) {
17199
17342
  channel.lastReactedMessage = channelMessageMap[channel.id];
17200
17343
  }
17201
17344
  return channel;
17202
17345
  });
17203
- log.info('[channelsLoadMore] mappedChannels updated with reaction messages, final count:', ((_mappedChannels6 = mappedChannels) === null || _mappedChannels6 === void 0 ? void 0 : _mappedChannels6.length) || 0);
17346
+ log.info(new Date().toISOString() + " [channelsLoadMore] mappedChannels updated with reaction messages, final count:", ((_mappedChannels6 = mappedChannels) === null || _mappedChannels6 === void 0 ? void 0 : _mappedChannels6.length) || 0);
17204
17347
  _context6.n = 9;
17205
17348
  break;
17206
17349
  case 8:
17207
- log.info('[channelsLoadMore] no channels need reaction message update');
17350
+ log.info(new Date().toISOString() + " [channelsLoadMore] no channels need reaction message update");
17208
17351
  case 9:
17209
- log.info('[channelsLoadMore] adding channels to state, count:', ((_mappedChannels7 = mappedChannels) === null || _mappedChannels7 === void 0 ? void 0 : _mappedChannels7.length) || 0);
17352
+ log.info(new Date().toISOString() + " [channelsLoadMore] adding channels to state, count:", ((_mappedChannels7 = mappedChannels) === null || _mappedChannels7 === void 0 ? void 0 : _mappedChannels7.length) || 0);
17210
17353
  _context6.n = 10;
17211
17354
  return put(addChannelsAC(mappedChannels));
17212
17355
  case 10:
17213
17356
  _context6.n = 11;
17214
17357
  return put(setChannelsLoadingStateAC(LOADING_STATE.LOADED));
17215
17358
  case 11:
17216
- log.info('[channelsLoadMore] completed successfully. Total channels added:', ((_mappedChannels8 = mappedChannels) === null || _mappedChannels8 === void 0 ? void 0 : _mappedChannels8.length) || 0);
17359
+ log.info(new Date().toISOString() + " [channelsLoadMore] completed successfully. Total channels added:", ((_mappedChannels8 = mappedChannels) === null || _mappedChannels8 === void 0 ? void 0 : _mappedChannels8.length) || 0);
17217
17360
  _context6.n = 13;
17218
17361
  break;
17219
17362
  case 12:
17220
17363
  _context6.p = 12;
17221
17364
  _t8 = _context6.v;
17222
- log.error('[channelsLoadMore] error occurred:', _t8);
17223
- log.error('[channelsLoadMore] error details:', JSON.stringify({
17365
+ log.error(new Date().toISOString() + " [channelsLoadMore] error occurred:", _t8);
17366
+ log.error(new Date().toISOString() + " [channelsLoadMore] error details:", JSON.stringify({
17224
17367
  message: _t8 === null || _t8 === void 0 ? void 0 : _t8.message,
17225
17368
  code: _t8 === null || _t8 === void 0 ? void 0 : _t8.code,
17226
17369
  stack: _t8 === null || _t8 === void 0 ? void 0 : _t8.stack
@@ -17391,7 +17534,7 @@ function markMessagesRead(action) {
17391
17534
  }, _marked9, null, [[2, 9]]);
17392
17535
  }
17393
17536
  function markVoiceMessageAsPlayed(action) {
17394
- var payload, channelId, messageIds, channel, _t10;
17537
+ var payload, channelId, messageIds, channel, messageListMarker, _iterator6, _step6, messageId, updateParams, _t10;
17395
17538
  return _regenerator().w(function (_context0) {
17396
17539
  while (1) switch (_context0.p = _context0.n) {
17397
17540
  case 0:
@@ -17409,25 +17552,54 @@ function markVoiceMessageAsPlayed(action) {
17409
17552
  }
17410
17553
  }
17411
17554
  if (!channel) {
17412
- _context0.n = 3;
17555
+ _context0.n = 7;
17413
17556
  break;
17414
17557
  }
17415
17558
  _context0.n = 3;
17416
17559
  return call(channel.markVoiceMessagesAsPlayed, messageIds);
17417
17560
  case 3:
17561
+ messageListMarker = _context0.v;
17562
+ _iterator6 = _createForOfIteratorHelperLoose(messageListMarker.messageIds);
17563
+ case 4:
17564
+ if ((_step6 = _iterator6()).done) {
17565
+ _context0.n = 7;
17566
+ break;
17567
+ }
17568
+ messageId = _step6.value;
17569
+ updateParams = {
17570
+ deliveryStatus: MESSAGE_DELIVERY_STATUS.PLAYED,
17571
+ userMarkers: [{
17572
+ user: messageListMarker.user,
17573
+ createdAt: messageListMarker.createdAt,
17574
+ messageId: messageId,
17575
+ name: MESSAGE_DELIVERY_STATUS.READ
17576
+ }]
17577
+ };
17418
17578
  _context0.n = 5;
17579
+ return put(updateMessageAC(messageId, updateParams));
17580
+ case 5:
17581
+ updateMessageOnMap(channel.id, {
17582
+ messageId: messageId,
17583
+ params: updateParams
17584
+ });
17585
+ updateMessageOnAllMessages(messageId, updateParams);
17586
+ case 6:
17587
+ _context0.n = 4;
17419
17588
  break;
17420
- case 4:
17421
- _context0.p = 4;
17589
+ case 7:
17590
+ _context0.n = 9;
17591
+ break;
17592
+ case 8:
17593
+ _context0.p = 8;
17422
17594
  _t10 = _context0.v;
17423
17595
  log.error(_t10, 'Error on mark voice messages read');
17424
- case 5:
17596
+ case 9:
17425
17597
  return _context0.a(2);
17426
17598
  }
17427
- }, _marked0, null, [[1, 4]]);
17599
+ }, _marked0, null, [[1, 8]]);
17428
17600
  }
17429
17601
  function markMessagesDelivered(action) {
17430
- var payload, channelId, messageIds, channel, _t11;
17602
+ var payload, channelId, messageIds, channel, messageListMarker, _iterator7, _step7, messageId, updateParams, _t11;
17431
17603
  return _regenerator().w(function (_context1) {
17432
17604
  while (1) switch (_context1.p = _context1.n) {
17433
17605
  case 0:
@@ -17445,23 +17617,52 @@ function markMessagesDelivered(action) {
17445
17617
  }
17446
17618
  }
17447
17619
  if (!channel) {
17448
- _context1.n = 3;
17620
+ _context1.n = 7;
17449
17621
  break;
17450
17622
  }
17451
17623
  log.info('send delivered marker ', messageIds);
17452
17624
  _context1.n = 3;
17453
17625
  return call(channel.markMessagesAsReceived, messageIds);
17454
17626
  case 3:
17627
+ messageListMarker = _context1.v;
17628
+ _iterator7 = _createForOfIteratorHelperLoose(messageListMarker.messageIds);
17629
+ case 4:
17630
+ if ((_step7 = _iterator7()).done) {
17631
+ _context1.n = 7;
17632
+ break;
17633
+ }
17634
+ messageId = _step7.value;
17635
+ updateParams = {
17636
+ deliveryStatus: MESSAGE_DELIVERY_STATUS.DELIVERED,
17637
+ userMarkers: [{
17638
+ user: messageListMarker.user,
17639
+ createdAt: messageListMarker.createdAt,
17640
+ messageId: messageId,
17641
+ name: MESSAGE_DELIVERY_STATUS.DELIVERED
17642
+ }]
17643
+ };
17455
17644
  _context1.n = 5;
17645
+ return put(updateMessageAC(messageId, updateParams));
17646
+ case 5:
17647
+ updateMessageOnMap(channel.id, {
17648
+ messageId: messageId,
17649
+ params: updateParams
17650
+ });
17651
+ updateMessageOnAllMessages(messageId, updateParams);
17652
+ case 6:
17653
+ _context1.n = 4;
17456
17654
  break;
17457
- case 4:
17458
- _context1.p = 4;
17655
+ case 7:
17656
+ _context1.n = 9;
17657
+ break;
17658
+ case 8:
17659
+ _context1.p = 8;
17459
17660
  _t11 = _context1.v;
17460
17661
  log.error(_t11, 'Error on mark messages delivered');
17461
- case 5:
17662
+ case 9:
17462
17663
  return _context1.a(2);
17463
17664
  }
17464
- }, _marked1, null, [[1, 4]]);
17665
+ }, _marked1, null, [[1, 8]]);
17465
17666
  }
17466
17667
  function switchChannel(action) {
17467
17668
  var payload, channel, updateActiveChannel, channelToSwitch, existingChannel, addChannel, _SceytChatClient5, fetchedChannel, channelFromMap, currentActiveChannel, _t12;
@@ -17858,50 +18059,52 @@ function leaveChannel(action) {
17858
18059
  }
17859
18060
  }, _marked18, null, [[0, 6]]);
17860
18061
  }
17861
- function deleteChannel(action) {
17862
- var payload, channelId, channel, _t20;
18062
+ function deletePendingDeleteChannels() {
18063
+ var pendingDeleteChannels, _iterator8, _step8, channel, resendableError, _t20;
17863
18064
  return _regenerator().w(function (_context19) {
17864
18065
  while (1) switch (_context19.p = _context19.n) {
17865
18066
  case 0:
17866
- _context19.p = 0;
17867
- payload = action.payload;
17868
- channelId = payload.channelId;
17869
- _context19.n = 1;
17870
- return call(getChannelFromMap, channelId);
18067
+ pendingDeleteChannels = getPendingDeleteChannels();
18068
+ _iterator8 = _createForOfIteratorHelperLoose(pendingDeleteChannels);
17871
18069
  case 1:
17872
- channel = _context19.v;
17873
- if (!channel) {
17874
- channel = getChannelFromAllChannels(channelId);
17875
- }
17876
- if (!channel) {
17877
- _context19.n = 5;
18070
+ if ((_step8 = _iterator8()).done) {
18071
+ _context19.n = 9;
17878
18072
  break;
17879
18073
  }
17880
- _context19.n = 2;
17881
- return call(channel["delete"]);
17882
- case 2:
18074
+ channel = _step8.value;
18075
+ _context19.p = 2;
17883
18076
  _context19.n = 3;
17884
- return put(setChannelToRemoveAC(channel));
18077
+ return call(channel["delete"]);
17885
18078
  case 3:
17886
18079
  _context19.n = 4;
17887
- return put(removeChannelAC(channelId));
18080
+ return put(setChannelToRemoveAC(channel));
17888
18081
  case 4:
17889
18082
  _context19.n = 5;
17890
- return put(removeChannelCachesAC(channelId));
18083
+ return put(removeChannelAC(channel.id));
17891
18084
  case 5:
17892
- _context19.n = 7;
17893
- break;
18085
+ _context19.n = 6;
18086
+ return put(removeChannelCachesAC(channel.id));
17894
18087
  case 6:
17895
- _context19.p = 6;
17896
- _t20 = _context19.v;
17897
- log.error('ERROR in delete channel', _t20);
18088
+ removePendingDeleteChannel(channel.id);
18089
+ _context19.n = 8;
18090
+ break;
17898
18091
  case 7:
18092
+ _context19.p = 7;
18093
+ _t20 = _context19.v;
18094
+ resendableError = isResendableError(_t20 === null || _t20 === void 0 ? void 0 : _t20.type);
18095
+ if (!resendableError) {
18096
+ removePendingDeleteChannel(channel.id);
18097
+ }
18098
+ case 8:
18099
+ _context19.n = 1;
18100
+ break;
18101
+ case 9:
17899
18102
  return _context19.a(2);
17900
18103
  }
17901
- }, _marked19, null, [[0, 6]]);
18104
+ }, _marked19, null, [[2, 7]]);
17902
18105
  }
17903
- function blockChannel(action) {
17904
- var payload, channelId, channel, _t21;
18106
+ function deleteChannel(action) {
18107
+ var payload, channelId, channel, activeChannelId, lastChannel, _t21;
17905
18108
  return _regenerator().w(function (_context20) {
17906
18109
  while (1) switch (_context20.p = _context20.n) {
17907
18110
  case 0:
@@ -17915,39 +18118,63 @@ function blockChannel(action) {
17915
18118
  if (!channel) {
17916
18119
  channel = getChannelFromAllChannels(channelId);
17917
18120
  }
17918
- if (!channel) {
17919
- _context20.n = 4;
18121
+ if (!(store.getState().UserReducer.connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
18122
+ _context20.n = 5;
17920
18123
  break;
17921
18124
  }
18125
+ setPendingDeleteChannel(channel);
17922
18126
  _context20.n = 2;
17923
- return call(channel.block);
18127
+ return call(getActiveChannelId);
17924
18128
  case 2:
18129
+ activeChannelId = _context20.v;
18130
+ if (!(activeChannelId === channelId)) {
18131
+ _context20.n = 4;
18132
+ break;
18133
+ }
17925
18134
  _context20.n = 3;
17926
- return put(removeChannelAC(channelId));
18135
+ return call(getLastChannelFromMap, true);
17927
18136
  case 3:
18137
+ lastChannel = _context20.v;
17928
18138
  _context20.n = 4;
17929
- return put(removeChannelCachesAC(channelId));
18139
+ return put(switchChannelActionAC(lastChannel || null));
17930
18140
  case 4:
18141
+ return _context20.a(2);
18142
+ case 5:
18143
+ if (!channel) {
18144
+ _context20.n = 9;
18145
+ break;
18146
+ }
17931
18147
  _context20.n = 6;
18148
+ return call(channel["delete"]);
18149
+ case 6:
18150
+ _context20.n = 7;
18151
+ return put(setChannelToRemoveAC(channel));
18152
+ case 7:
18153
+ _context20.n = 8;
18154
+ return put(removeChannelAC(channelId));
18155
+ case 8:
18156
+ _context20.n = 9;
18157
+ return put(removeChannelCachesAC(channelId));
18158
+ case 9:
18159
+ _context20.n = 11;
17932
18160
  break;
17933
- case 5:
17934
- _context20.p = 5;
18161
+ case 10:
18162
+ _context20.p = 10;
17935
18163
  _t21 = _context20.v;
17936
- log.error('ERROR in block channel - ', _t21.message);
17937
- case 6:
18164
+ log.error('ERROR in delete channel', _t21);
18165
+ case 11:
17938
18166
  return _context20.a(2);
17939
18167
  }
17940
- }, _marked20, null, [[0, 5]]);
18168
+ }, _marked20, null, [[0, 10]]);
17941
18169
  }
17942
- function updateChannel(action) {
17943
- var payload, channelId, config, _SceytChatClient6, channel, paramsToUpdate, fileToUpload, _yield$call5, subject, avatarUrl, metadata, onUpdateChannel, _channel3, _channel4, _channel5, fields, updatedChannel, _t22;
18170
+ function blockChannel(action) {
18171
+ var payload, channelId, channel, _t22;
17944
18172
  return _regenerator().w(function (_context21) {
17945
18173
  while (1) switch (_context21.p = _context21.n) {
17946
18174
  case 0:
17947
18175
  _context21.p = 0;
17948
18176
  payload = action.payload;
17949
- channelId = payload.channelId, config = payload.config;
17950
- _SceytChatClient6 = getClient();
18177
+ channelId = payload.channelId;
17951
18178
  _context21.n = 1;
17952
18179
  return call(getChannelFromMap, channelId);
17953
18180
  case 1:
@@ -17955,6 +18182,46 @@ function updateChannel(action) {
17955
18182
  if (!channel) {
17956
18183
  channel = getChannelFromAllChannels(channelId);
17957
18184
  }
18185
+ if (!channel) {
18186
+ _context21.n = 4;
18187
+ break;
18188
+ }
18189
+ _context21.n = 2;
18190
+ return call(channel.block);
18191
+ case 2:
18192
+ _context21.n = 3;
18193
+ return put(removeChannelAC(channelId));
18194
+ case 3:
18195
+ _context21.n = 4;
18196
+ return put(removeChannelCachesAC(channelId));
18197
+ case 4:
18198
+ _context21.n = 6;
18199
+ break;
18200
+ case 5:
18201
+ _context21.p = 5;
18202
+ _t22 = _context21.v;
18203
+ log.error('ERROR in block channel - ', _t22.message);
18204
+ case 6:
18205
+ return _context21.a(2);
18206
+ }
18207
+ }, _marked21, null, [[0, 5]]);
18208
+ }
18209
+ function updateChannel(action) {
18210
+ var payload, channelId, config, _SceytChatClient6, channel, paramsToUpdate, fileToUpload, _yield$call5, subject, avatarUrl, metadata, onUpdateChannel, _channel3, _channel4, _channel5, fields, updatedChannel, _t23;
18211
+ return _regenerator().w(function (_context22) {
18212
+ while (1) switch (_context22.p = _context22.n) {
18213
+ case 0:
18214
+ _context22.p = 0;
18215
+ payload = action.payload;
18216
+ channelId = payload.channelId, config = payload.config;
18217
+ _SceytChatClient6 = getClient();
18218
+ _context22.n = 1;
18219
+ return call(getChannelFromMap, channelId);
18220
+ case 1:
18221
+ channel = _context22.v;
18222
+ if (!channel) {
18223
+ channel = getChannelFromAllChannels(channelId);
18224
+ }
17958
18225
  paramsToUpdate = {
17959
18226
  uri: channel.uri,
17960
18227
  subject: channel.subject,
@@ -17962,7 +18229,7 @@ function updateChannel(action) {
17962
18229
  avatarUrl: channel.avatarUrl
17963
18230
  };
17964
18231
  if (!config.avatar) {
17965
- _context21.n = 3;
18232
+ _context22.n = 3;
17966
18233
  break;
17967
18234
  }
17968
18235
  fileToUpload = {
@@ -17971,10 +18238,10 @@ function updateChannel(action) {
17971
18238
  log.info('upload percent - ', progressPercent);
17972
18239
  }
17973
18240
  };
17974
- _context21.n = 2;
18241
+ _context22.n = 2;
17975
18242
  return call(_SceytChatClient6.uploadFile, fileToUpload);
17976
18243
  case 2:
17977
- paramsToUpdate.avatarUrl = _context21.v;
18244
+ paramsToUpdate.avatarUrl = _context22.v;
17978
18245
  case 3:
17979
18246
  if (config.subject) {
17980
18247
  paramsToUpdate.subject = config.subject;
@@ -17985,14 +18252,14 @@ function updateChannel(action) {
17985
18252
  if (config.avatarUrl === '') {
17986
18253
  paramsToUpdate.avatarUrl = '';
17987
18254
  }
17988
- _context21.n = 4;
18255
+ _context22.n = 4;
17989
18256
  return call(channel.update, paramsToUpdate);
17990
18257
  case 4:
17991
- _yield$call5 = _context21.v;
18258
+ _yield$call5 = _context22.v;
17992
18259
  subject = _yield$call5.subject;
17993
18260
  avatarUrl = _yield$call5.avatarUrl;
17994
18261
  metadata = _yield$call5.metadata;
17995
- _context21.n = 5;
18262
+ _context22.n = 5;
17996
18263
  return put(updateChannelDataAC(channelId, {
17997
18264
  subject: subject,
17998
18265
  avatarUrl: avatarUrl,
@@ -18006,7 +18273,7 @@ function updateChannel(action) {
18006
18273
  });
18007
18274
  onUpdateChannel = getOnUpdateChannel();
18008
18275
  if (!onUpdateChannel) {
18009
- _context21.n = 7;
18276
+ _context22.n = 7;
18010
18277
  break;
18011
18278
  }
18012
18279
  fields = [];
@@ -18019,35 +18286,35 @@ function updateChannel(action) {
18019
18286
  if (JSON.stringify((_channel5 = channel) === null || _channel5 === void 0 ? void 0 : _channel5.metadata) !== metadata) {
18020
18287
  fields.push('metadata');
18021
18288
  }
18022
- _context21.n = 6;
18289
+ _context22.n = 6;
18023
18290
  return call(getChannelFromMap, channelId);
18024
18291
  case 6:
18025
- updatedChannel = _context21.v;
18292
+ updatedChannel = _context22.v;
18026
18293
  onUpdateChannel(updatedChannel, fields);
18027
18294
  case 7:
18028
- _context21.n = 9;
18295
+ _context22.n = 9;
18029
18296
  break;
18030
18297
  case 8:
18031
- _context21.p = 8;
18032
- _t22 = _context21.v;
18033
- log.error('ERROR in update channel', _t22.message);
18298
+ _context22.p = 8;
18299
+ _t23 = _context22.v;
18300
+ log.error('ERROR in update channel', _t23.message);
18034
18301
  case 9:
18035
- return _context21.a(2);
18302
+ return _context22.a(2);
18036
18303
  }
18037
- }, _marked21, null, [[0, 8]]);
18304
+ }, _marked22, null, [[0, 8]]);
18038
18305
  }
18039
18306
  function checkUsersStatus() {
18040
- var _SceytChatClient7, usersForUpdate, updatedUsers, usersToUpdateMap, update, updateData, _t23;
18041
- return _regenerator().w(function (_context22) {
18042
- while (1) switch (_context22.p = _context22.n) {
18307
+ var _SceytChatClient7, usersForUpdate, updatedUsers, usersToUpdateMap, update, updateData, _t24;
18308
+ return _regenerator().w(function (_context23) {
18309
+ while (1) switch (_context23.p = _context23.n) {
18043
18310
  case 0:
18044
- _context22.p = 0;
18311
+ _context23.p = 0;
18045
18312
  _SceytChatClient7 = getClient();
18046
18313
  usersForUpdate = Object.keys(usersMap);
18047
- _context22.n = 1;
18314
+ _context23.n = 1;
18048
18315
  return call(_SceytChatClient7.getUsers, usersForUpdate);
18049
18316
  case 1:
18050
- updatedUsers = _context22.v;
18317
+ updatedUsers = _context23.v;
18051
18318
  usersToUpdateMap = {};
18052
18319
  update = false;
18053
18320
  updatedUsers.forEach(function (updatedUser) {
@@ -18059,149 +18326,149 @@ function checkUsersStatus() {
18059
18326
  }
18060
18327
  });
18061
18328
  if (!update) {
18062
- _context22.n = 4;
18329
+ _context23.n = 4;
18063
18330
  break;
18064
18331
  }
18065
18332
  updateData = JSON.parse(JSON.stringify(usersToUpdateMap));
18066
- _context22.n = 2;
18333
+ _context23.n = 2;
18067
18334
  return put(updateMembersPresenceAC(updateData));
18068
18335
  case 2:
18069
- _context22.n = 3;
18336
+ _context23.n = 3;
18070
18337
  return put(updateUserStatusOnMapAC(updateData));
18071
18338
  case 3:
18072
- _context22.n = 4;
18339
+ _context23.n = 4;
18073
18340
  return put(updateUserStatusOnChannelAC(updateData));
18074
18341
  case 4:
18075
- _context22.n = 6;
18342
+ _context23.n = 6;
18076
18343
  break;
18077
18344
  case 5:
18078
- _context22.p = 5;
18079
- _t23 = _context22.v;
18080
- log.error('ERROR in check user status : ', _t23.message);
18345
+ _context23.p = 5;
18346
+ _t24 = _context23.v;
18347
+ log.error('ERROR in check user status : ', _t24.message);
18081
18348
  case 6:
18082
- return _context22.a(2);
18349
+ return _context23.a(2);
18083
18350
  }
18084
- }, _marked22, null, [[0, 5]]);
18351
+ }, _marked23, null, [[0, 5]]);
18085
18352
  }
18086
18353
  function sendTyping(action) {
18087
- var state, activeChannelId, channel, _t24;
18088
- return _regenerator().w(function (_context23) {
18089
- while (1) switch (_context23.p = _context23.n) {
18354
+ var state, activeChannelId, channel, _t25;
18355
+ return _regenerator().w(function (_context24) {
18356
+ while (1) switch (_context24.p = _context24.n) {
18090
18357
  case 0:
18091
18358
  state = action.payload.state;
18092
- _context23.n = 1;
18359
+ _context24.n = 1;
18093
18360
  return call(getActiveChannelId);
18094
18361
  case 1:
18095
- activeChannelId = _context23.v;
18096
- _context23.n = 2;
18362
+ activeChannelId = _context24.v;
18363
+ _context24.n = 2;
18097
18364
  return call(getChannelFromMap, activeChannelId);
18098
18365
  case 2:
18099
- channel = _context23.v;
18100
- _context23.p = 3;
18366
+ channel = _context24.v;
18367
+ _context24.p = 3;
18101
18368
  if (!channel) {
18102
- _context23.n = 6;
18369
+ _context24.n = 6;
18103
18370
  break;
18104
18371
  }
18105
18372
  if (!state) {
18106
- _context23.n = 5;
18373
+ _context24.n = 5;
18107
18374
  break;
18108
18375
  }
18109
- _context23.n = 4;
18376
+ _context24.n = 4;
18110
18377
  return call(channel.startTyping);
18111
18378
  case 4:
18112
- _context23.n = 6;
18379
+ _context24.n = 6;
18113
18380
  break;
18114
18381
  case 5:
18115
- _context23.n = 6;
18382
+ _context24.n = 6;
18116
18383
  return call(channel.stopTyping);
18117
18384
  case 6:
18118
- _context23.n = 8;
18385
+ _context24.n = 8;
18119
18386
  break;
18120
18387
  case 7:
18121
- _context23.p = 7;
18122
- _t24 = _context23.v;
18123
- log.error('ERROR in send typing', _t24);
18388
+ _context24.p = 7;
18389
+ _t25 = _context24.v;
18390
+ log.error('ERROR in send typing', _t25);
18124
18391
  case 8:
18125
- return _context23.a(2);
18392
+ return _context24.a(2);
18126
18393
  }
18127
- }, _marked23, null, [[3, 7]]);
18394
+ }, _marked24, null, [[3, 7]]);
18128
18395
  }
18129
18396
  function sendRecording(action) {
18130
- var _action$payload, state, channelId, channel, _t25;
18131
- return _regenerator().w(function (_context24) {
18132
- while (1) switch (_context24.p = _context24.n) {
18397
+ var _action$payload, state, channelId, channel, _t26;
18398
+ return _regenerator().w(function (_context25) {
18399
+ while (1) switch (_context25.p = _context25.n) {
18133
18400
  case 0:
18134
18401
  _action$payload = action.payload, state = _action$payload.state, channelId = _action$payload.channelId;
18135
- _context24.n = 1;
18402
+ _context25.n = 1;
18136
18403
  return call(getChannelFromMap, channelId);
18137
18404
  case 1:
18138
- channel = _context24.v;
18139
- _context24.p = 2;
18405
+ channel = _context25.v;
18406
+ _context25.p = 2;
18140
18407
  if (!channel) {
18141
- _context24.n = 5;
18408
+ _context25.n = 5;
18142
18409
  break;
18143
18410
  }
18144
18411
  if (!state) {
18145
- _context24.n = 4;
18412
+ _context25.n = 4;
18146
18413
  break;
18147
18414
  }
18148
- _context24.n = 3;
18415
+ _context25.n = 3;
18149
18416
  return call(channel.startRecording);
18150
18417
  case 3:
18151
- _context24.n = 5;
18418
+ _context25.n = 5;
18152
18419
  break;
18153
18420
  case 4:
18154
- _context24.n = 5;
18421
+ _context25.n = 5;
18155
18422
  return call(channel.stopRecording);
18156
18423
  case 5:
18157
- _context24.n = 7;
18424
+ _context25.n = 7;
18158
18425
  break;
18159
18426
  case 6:
18160
- _context24.p = 6;
18161
- _t25 = _context24.v;
18162
- log.error('ERROR in send recording', _t25);
18427
+ _context25.p = 6;
18428
+ _t26 = _context25.v;
18429
+ log.error('ERROR in send recording', _t26);
18163
18430
  case 7:
18164
- return _context24.a(2);
18431
+ return _context25.a(2);
18165
18432
  }
18166
- }, _marked24, null, [[2, 6]]);
18433
+ }, _marked25, null, [[2, 6]]);
18167
18434
  }
18168
18435
  function clearHistory(action) {
18169
- var payload, channelId, channel, activeChannelId, groupName, _t26;
18170
- return _regenerator().w(function (_context25) {
18171
- while (1) switch (_context25.p = _context25.n) {
18436
+ var payload, channelId, channel, activeChannelId, groupName, _t27;
18437
+ return _regenerator().w(function (_context26) {
18438
+ while (1) switch (_context26.p = _context26.n) {
18172
18439
  case 0:
18173
- _context25.p = 0;
18440
+ _context26.p = 0;
18174
18441
  payload = action.payload;
18175
18442
  channelId = payload.channelId;
18176
- _context25.n = 1;
18443
+ _context26.n = 1;
18177
18444
  return call(getChannelFromMap, channelId);
18178
18445
  case 1:
18179
- channel = _context25.v;
18446
+ channel = _context26.v;
18180
18447
  if (!channel) {
18181
18448
  channel = getChannelFromAllChannels(channelId);
18182
18449
  }
18183
- _context25.n = 2;
18450
+ _context26.n = 2;
18184
18451
  return call(getActiveChannelId);
18185
18452
  case 2:
18186
- activeChannelId = _context25.v;
18453
+ activeChannelId = _context26.v;
18187
18454
  if (!channel) {
18188
- _context25.n = 7;
18455
+ _context26.n = 7;
18189
18456
  break;
18190
18457
  }
18191
- _context25.n = 3;
18458
+ _context26.n = 3;
18192
18459
  return call(channel.deleteAllMessages);
18193
18460
  case 3:
18194
- _context25.n = 4;
18461
+ _context26.n = 4;
18195
18462
  return put(clearMessagesAC());
18196
18463
  case 4:
18197
18464
  removeMessagesFromMap(channelId);
18198
18465
  if (channelId === activeChannelId) {
18199
18466
  removeAllMessages();
18200
18467
  }
18201
- _context25.n = 5;
18468
+ _context26.n = 5;
18202
18469
  return put(clearSelectedMessagesAC());
18203
18470
  case 5:
18204
- _context25.n = 6;
18471
+ _context26.n = 6;
18205
18472
  return put(updateChannelDataAC(channel.id, {
18206
18473
  lastMessage: null,
18207
18474
  newMessageCount: 0,
@@ -18214,64 +18481,64 @@ function clearHistory(action) {
18214
18481
  newMentionCount: 0
18215
18482
  });
18216
18483
  groupName = getChannelGroupName(channel);
18217
- _context25.n = 7;
18484
+ _context26.n = 7;
18218
18485
  return put(updateSearchedChannelDataAC(channel.id, {
18219
18486
  lastMessage: null,
18220
18487
  newMessageCount: 0,
18221
18488
  newMentionCount: 0
18222
18489
  }, groupName));
18223
18490
  case 7:
18224
- _context25.n = 9;
18491
+ _context26.n = 9;
18225
18492
  break;
18226
18493
  case 8:
18227
- _context25.p = 8;
18228
- _t26 = _context25.v;
18229
- log.error('ERROR in clear history', _t26);
18494
+ _context26.p = 8;
18495
+ _t27 = _context26.v;
18496
+ log.error('ERROR in clear history', _t27);
18230
18497
  case 9:
18231
- return _context25.a(2);
18498
+ return _context26.a(2);
18232
18499
  }
18233
- }, _marked25, null, [[0, 8]]);
18500
+ }, _marked26, null, [[0, 8]]);
18234
18501
  }
18235
18502
  function deleteAllMessages(action) {
18236
- var payload, channelId, channel, activeChannelId, groupName, _t27;
18237
- return _regenerator().w(function (_context26) {
18238
- while (1) switch (_context26.p = _context26.n) {
18503
+ var payload, channelId, channel, activeChannelId, groupName, _t28;
18504
+ return _regenerator().w(function (_context27) {
18505
+ while (1) switch (_context27.p = _context27.n) {
18239
18506
  case 0:
18240
- _context26.p = 0;
18507
+ _context27.p = 0;
18241
18508
  payload = action.payload;
18242
18509
  channelId = payload.channelId;
18243
- _context26.n = 1;
18510
+ _context27.n = 1;
18244
18511
  return call(getChannelFromMap, channelId);
18245
18512
  case 1:
18246
- channel = _context26.v;
18513
+ channel = _context27.v;
18247
18514
  if (!channel) {
18248
18515
  channel = getChannelFromAllChannels(channelId);
18249
18516
  }
18250
- _context26.n = 2;
18517
+ _context27.n = 2;
18251
18518
  return call(getActiveChannelId);
18252
18519
  case 2:
18253
- activeChannelId = _context26.v;
18520
+ activeChannelId = _context27.v;
18254
18521
  if (!channel) {
18255
- _context26.n = 8;
18522
+ _context27.n = 8;
18256
18523
  break;
18257
18524
  }
18258
- _context26.n = 3;
18525
+ _context27.n = 3;
18259
18526
  return call(channel.deleteAllMessages, true);
18260
18527
  case 3:
18261
18528
  removeMessagesFromMap(channelId);
18262
18529
  if (!(channelId === activeChannelId)) {
18263
- _context26.n = 5;
18530
+ _context27.n = 5;
18264
18531
  break;
18265
18532
  }
18266
- _context26.n = 4;
18533
+ _context27.n = 4;
18267
18534
  return put(clearMessagesAC());
18268
18535
  case 4:
18269
18536
  removeAllMessages();
18270
18537
  case 5:
18271
- _context26.n = 6;
18538
+ _context27.n = 6;
18272
18539
  return put(clearSelectedMessagesAC());
18273
18540
  case 6:
18274
- _context26.n = 7;
18541
+ _context27.n = 7;
18275
18542
  return put(updateChannelDataAC(channel.id, {
18276
18543
  lastMessage: null,
18277
18544
  newMessageCount: 0,
@@ -18284,230 +18551,230 @@ function deleteAllMessages(action) {
18284
18551
  newMentionCount: 0
18285
18552
  });
18286
18553
  groupName = getChannelGroupName(channel);
18287
- _context26.n = 8;
18554
+ _context27.n = 8;
18288
18555
  return put(updateSearchedChannelDataAC(channel.id, {
18289
18556
  lastMessage: null,
18290
18557
  newMessageCount: 0,
18291
18558
  newMentionCount: 0
18292
18559
  }, groupName));
18293
18560
  case 8:
18294
- _context26.n = 10;
18561
+ _context27.n = 10;
18295
18562
  break;
18296
18563
  case 9:
18297
- _context26.p = 9;
18298
- _t27 = _context26.v;
18299
- log.error('ERROR in clear history', _t27);
18564
+ _context27.p = 9;
18565
+ _t28 = _context27.v;
18566
+ log.error('ERROR in clear history', _t28);
18300
18567
  case 10:
18301
- return _context26.a(2);
18568
+ return _context27.a(2);
18302
18569
  }
18303
- }, _marked26, null, [[0, 9]]);
18570
+ }, _marked27, null, [[0, 9]]);
18304
18571
  }
18305
18572
  function joinChannel(action) {
18306
- var payload, channelId, _SceytChatClient8, channel, joinedChannel, _t28;
18307
- return _regenerator().w(function (_context27) {
18308
- while (1) switch (_context27.p = _context27.n) {
18573
+ var payload, channelId, _SceytChatClient8, channel, joinedChannel, _t29;
18574
+ return _regenerator().w(function (_context28) {
18575
+ while (1) switch (_context28.p = _context28.n) {
18309
18576
  case 0:
18310
- _context27.p = 0;
18577
+ _context28.p = 0;
18311
18578
  payload = action.payload;
18312
18579
  channelId = payload.channelId;
18313
18580
  _SceytChatClient8 = getClient();
18314
- _context27.n = 1;
18581
+ _context28.n = 1;
18315
18582
  return call(getChannelFromMap, channelId);
18316
18583
  case 1:
18317
- channel = _context27.v;
18584
+ channel = _context28.v;
18318
18585
  if (!channel) {
18319
18586
  channel = getChannelFromAllChannels(channelId);
18320
18587
  }
18321
18588
  if (channel) {
18322
- _context27.n = 3;
18589
+ _context28.n = 3;
18323
18590
  break;
18324
18591
  }
18325
- _context27.n = 2;
18592
+ _context28.n = 2;
18326
18593
  return call(_SceytChatClient8.getChannel, channelId);
18327
18594
  case 2:
18328
- channel = _context27.v;
18595
+ channel = _context28.v;
18329
18596
  case 3:
18330
- _context27.n = 4;
18597
+ _context28.n = 4;
18331
18598
  return call(channel.join);
18332
18599
  case 4:
18333
- joinedChannel = _context27.v;
18334
- _context27.n = 5;
18600
+ joinedChannel = _context28.v;
18601
+ _context28.n = 5;
18335
18602
  return put(setCloseSearchChannelsAC(true));
18336
18603
  case 5:
18337
- _context27.n = 6;
18604
+ _context28.n = 6;
18338
18605
  return put(setChannelToAddAC(JSON.parse(JSON.stringify(joinedChannel))));
18339
18606
  case 6:
18340
- _context27.n = 7;
18607
+ _context28.n = 7;
18341
18608
  return put(switchChannelActionAC(JSON.parse(JSON.stringify(joinedChannel))));
18342
18609
  case 7:
18343
18610
  addChannelToAllChannels(joinedChannel);
18344
- _context27.n = 8;
18611
+ _context28.n = 8;
18345
18612
  return call(setActiveChannelId, joinedChannel.id);
18346
18613
  case 8:
18347
- _context27.n = 10;
18614
+ _context28.n = 10;
18348
18615
  break;
18349
18616
  case 9:
18350
- _context27.p = 9;
18351
- _t28 = _context27.v;
18352
- log.error(_t28, 'Error in join to channel');
18617
+ _context28.p = 9;
18618
+ _t29 = _context28.v;
18619
+ log.error(_t29, 'Error in join to channel');
18353
18620
  case 10:
18354
- return _context27.a(2);
18621
+ return _context28.a(2);
18355
18622
  }
18356
- }, _marked27, null, [[0, 9]]);
18623
+ }, _marked28, null, [[0, 9]]);
18357
18624
  }
18358
18625
  function watchForChannelEvents() {
18359
- return _regenerator().w(function (_context28) {
18360
- while (1) switch (_context28.n) {
18626
+ return _regenerator().w(function (_context29) {
18627
+ while (1) switch (_context29.n) {
18361
18628
  case 0:
18362
- _context28.n = 1;
18629
+ _context29.n = 1;
18363
18630
  return call(watchForEvents);
18364
18631
  case 1:
18365
- return _context28.a(2);
18632
+ return _context29.a(2);
18366
18633
  }
18367
- }, _marked28);
18634
+ }, _marked29);
18368
18635
  }
18369
18636
  function createChannelInviteKey(action) {
18370
- var payload, channelId, _SceytChatClient9, channel, inviteKey, _t29;
18371
- return _regenerator().w(function (_context29) {
18372
- while (1) switch (_context29.p = _context29.n) {
18637
+ var payload, channelId, _SceytChatClient9, channel, inviteKey, _t30;
18638
+ return _regenerator().w(function (_context30) {
18639
+ while (1) switch (_context30.p = _context30.n) {
18373
18640
  case 0:
18374
- _context29.p = 0;
18641
+ _context30.p = 0;
18375
18642
  payload = action.payload;
18376
18643
  channelId = payload.channelId;
18377
18644
  _SceytChatClient9 = getClient();
18378
- _context29.n = 1;
18645
+ _context30.n = 1;
18379
18646
  return call(getChannelFromMap, channelId);
18380
18647
  case 1:
18381
- channel = _context29.v;
18648
+ channel = _context30.v;
18382
18649
  if (!channel) {
18383
18650
  channel = getChannelFromAllChannels(channelId);
18384
18651
  }
18385
18652
  if (!channel) {
18386
- _context29.n = 3;
18653
+ _context30.n = 3;
18387
18654
  break;
18388
18655
  }
18389
- _context29.n = 2;
18656
+ _context30.n = 2;
18390
18657
  return call(_SceytChatClient9.createInviteKey, {
18391
18658
  maxUses: 0,
18392
18659
  expiresAt: 0,
18393
18660
  accessPriorHistory: true
18394
18661
  });
18395
18662
  case 2:
18396
- inviteKey = _context29.v;
18397
- _context29.n = 3;
18663
+ inviteKey = _context30.v;
18664
+ _context30.n = 3;
18398
18665
  return put(setChannelInviteKeysAC(channelId, [inviteKey]));
18399
18666
  case 3:
18400
- _context29.n = 5;
18667
+ _context30.n = 5;
18401
18668
  break;
18402
18669
  case 4:
18403
- _context29.p = 4;
18404
- _t29 = _context29.v;
18405
- log.error('ERROR in create channel invite key', _t29);
18670
+ _context30.p = 4;
18671
+ _t30 = _context30.v;
18672
+ log.error('ERROR in create channel invite key', _t30);
18406
18673
  case 5:
18407
- return _context29.a(2);
18674
+ return _context30.a(2);
18408
18675
  }
18409
- }, _marked29, null, [[0, 4]]);
18676
+ }, _marked30, null, [[0, 4]]);
18410
18677
  }
18411
18678
  function getChannelInviteKeys(action) {
18412
- var payload, channelId, channel, inviteKeys, _t30;
18413
- return _regenerator().w(function (_context30) {
18414
- while (1) switch (_context30.p = _context30.n) {
18679
+ var payload, channelId, channel, inviteKeys, _t31;
18680
+ return _regenerator().w(function (_context31) {
18681
+ while (1) switch (_context31.p = _context31.n) {
18415
18682
  case 0:
18416
- _context30.p = 0;
18683
+ _context31.p = 0;
18417
18684
  payload = action.payload;
18418
18685
  channelId = payload.channelId;
18419
- _context30.n = 1;
18686
+ _context31.n = 1;
18420
18687
  return call(getChannelFromMap, channelId);
18421
18688
  case 1:
18422
- channel = _context30.v;
18689
+ channel = _context31.v;
18423
18690
  if (!channel) {
18424
18691
  channel = getChannelFromAllChannels(channelId);
18425
18692
  }
18426
18693
  if (!channel) {
18427
- _context30.n = 3;
18694
+ _context31.n = 3;
18428
18695
  break;
18429
18696
  }
18430
- _context30.n = 2;
18697
+ _context31.n = 2;
18431
18698
  return call(channel.getInviteKeys);
18432
18699
  case 2:
18433
- inviteKeys = _context30.v;
18434
- _context30.n = 3;
18700
+ inviteKeys = _context31.v;
18701
+ _context31.n = 3;
18435
18702
  return put(setChannelInviteKeysAC(channelId, inviteKeys));
18436
18703
  case 3:
18437
- _context30.n = 5;
18704
+ _context31.n = 5;
18438
18705
  break;
18439
18706
  case 4:
18440
- _context30.p = 4;
18441
- _t30 = _context30.v;
18442
- log.error('ERROR in get channel invite keys', _t30);
18707
+ _context31.p = 4;
18708
+ _t31 = _context31.v;
18709
+ log.error('ERROR in get channel invite keys', _t31);
18443
18710
  case 5:
18444
- return _context30.a(2);
18711
+ return _context31.a(2);
18445
18712
  }
18446
- }, _marked30, null, [[0, 4]]);
18713
+ }, _marked31, null, [[0, 4]]);
18447
18714
  }
18448
18715
  function regenerateChannelInviteKey(action) {
18449
- var payload, channelId, key, deletePermanently, channel, inviteKey, _t31;
18450
- return _regenerator().w(function (_context31) {
18451
- while (1) switch (_context31.p = _context31.n) {
18716
+ var payload, channelId, key, deletePermanently, channel, inviteKey, _t32;
18717
+ return _regenerator().w(function (_context32) {
18718
+ while (1) switch (_context32.p = _context32.n) {
18452
18719
  case 0:
18453
- _context31.p = 0;
18720
+ _context32.p = 0;
18454
18721
  payload = action.payload;
18455
18722
  channelId = payload.channelId, key = payload.key, deletePermanently = payload.deletePermanently;
18456
- _context31.n = 1;
18723
+ _context32.n = 1;
18457
18724
  return call(getChannelFromMap, channelId);
18458
18725
  case 1:
18459
- channel = _context31.v;
18726
+ channel = _context32.v;
18460
18727
  if (!channel) {
18461
18728
  channel = getChannelFromAllChannels(channelId);
18462
18729
  }
18463
18730
  if (!channel) {
18464
- _context31.n = 3;
18731
+ _context32.n = 3;
18465
18732
  break;
18466
18733
  }
18467
- _context31.n = 2;
18734
+ _context32.n = 2;
18468
18735
  return call(channel.regenerateInviteKey, {
18469
18736
  key: key,
18470
18737
  channelId: channelId,
18471
18738
  deletePermanently: deletePermanently
18472
18739
  });
18473
18740
  case 2:
18474
- inviteKey = _context31.v;
18475
- _context31.n = 3;
18741
+ inviteKey = _context32.v;
18742
+ _context32.n = 3;
18476
18743
  return put(setChannelInviteKeysAC(channelId, [inviteKey]));
18477
18744
  case 3:
18478
- _context31.n = 5;
18745
+ _context32.n = 5;
18479
18746
  break;
18480
18747
  case 4:
18481
- _context31.p = 4;
18482
- _t31 = _context31.v;
18483
- log.error('ERROR in regenerate channel invite key', _t31);
18748
+ _context32.p = 4;
18749
+ _t32 = _context32.v;
18750
+ log.error('ERROR in regenerate channel invite key', _t32);
18484
18751
  case 5:
18485
- return _context31.a(2);
18752
+ return _context32.a(2);
18486
18753
  }
18487
- }, _marked31, null, [[0, 4]]);
18754
+ }, _marked32, null, [[0, 4]]);
18488
18755
  }
18489
18756
  function updateChannelInviteKey(action) {
18490
- var channelInviteKeys, channelId, payload, payloadChannelId, key, accessPriorHistory, expiresAt, maxUses, channel, copiedChannelInviteKeys, _t32;
18491
- return _regenerator().w(function (_context32) {
18492
- while (1) switch (_context32.p = _context32.n) {
18757
+ var channelInviteKeys, channelId, payload, payloadChannelId, key, accessPriorHistory, expiresAt, maxUses, channel, copiedChannelInviteKeys, _t33;
18758
+ return _regenerator().w(function (_context33) {
18759
+ while (1) switch (_context33.p = _context33.n) {
18493
18760
  case 0:
18494
18761
  channelInviteKeys = [];
18495
18762
  channelId = '';
18496
- _context32.p = 1;
18763
+ _context33.p = 1;
18497
18764
  payload = action.payload;
18498
18765
  payloadChannelId = payload.channelId, key = payload.key, accessPriorHistory = payload.accessPriorHistory, expiresAt = payload.expiresAt, maxUses = payload.maxUses;
18499
18766
  channelId = payloadChannelId;
18500
- _context32.n = 2;
18767
+ _context33.n = 2;
18501
18768
  return call(getChannelFromMap, channelId);
18502
18769
  case 2:
18503
- channel = _context32.v;
18770
+ channel = _context33.v;
18504
18771
  if (!channel) {
18505
18772
  channel = getChannelFromAllChannels(channelId);
18506
18773
  }
18507
18774
  channelInviteKeys = store.getState().ChannelReducer.channelInviteKeys[channelId];
18508
18775
  copiedChannelInviteKeys = JSON.parse(JSON.stringify(channelInviteKeys));
18509
18776
  if (!copiedChannelInviteKeys) {
18510
- _context32.n = 3;
18777
+ _context33.n = 3;
18511
18778
  break;
18512
18779
  }
18513
18780
  copiedChannelInviteKeys.forEach(function (inviteKey) {
@@ -18517,14 +18784,14 @@ function updateChannelInviteKey(action) {
18517
18784
  inviteKey.maxUses = maxUses;
18518
18785
  }
18519
18786
  });
18520
- _context32.n = 3;
18787
+ _context33.n = 3;
18521
18788
  return put(setChannelInviteKeysAC(channelId, copiedChannelInviteKeys));
18522
18789
  case 3:
18523
18790
  if (!channel) {
18524
- _context32.n = 4;
18791
+ _context33.n = 4;
18525
18792
  break;
18526
18793
  }
18527
- _context32.n = 4;
18794
+ _context33.n = 4;
18528
18795
  return call(channel.updateInviteKey, {
18529
18796
  key: key,
18530
18797
  channelId: channelId,
@@ -18533,88 +18800,88 @@ function updateChannelInviteKey(action) {
18533
18800
  accessPriorHistory: accessPriorHistory
18534
18801
  });
18535
18802
  case 4:
18536
- _context32.n = 6;
18803
+ _context33.n = 6;
18537
18804
  break;
18538
18805
  case 5:
18539
- _context32.p = 5;
18540
- _t32 = _context32.v;
18541
- log.error('ERROR in update channel invite key', _t32);
18542
- _context32.n = 6;
18806
+ _context33.p = 5;
18807
+ _t33 = _context33.v;
18808
+ log.error('ERROR in update channel invite key', _t33);
18809
+ _context33.n = 6;
18543
18810
  return put(setChannelInviteKeysAC(channelId, channelInviteKeys));
18544
18811
  case 6:
18545
- return _context32.a(2);
18812
+ return _context33.a(2);
18546
18813
  }
18547
- }, _marked32, null, [[1, 5]]);
18814
+ }, _marked33, null, [[1, 5]]);
18548
18815
  }
18549
18816
  function getChannelByInviteKey(action) {
18550
- var _channel$, _channel$2, payload, key, _SceytChatClient0, channel, _t33;
18551
- return _regenerator().w(function (_context33) {
18552
- while (1) switch (_context33.p = _context33.n) {
18817
+ var _channel$, _channel$2, payload, key, _SceytChatClient0, channel, _t34;
18818
+ return _regenerator().w(function (_context34) {
18819
+ while (1) switch (_context34.p = _context34.n) {
18553
18820
  case 0:
18554
- _context33.p = 0;
18821
+ _context34.p = 0;
18555
18822
  payload = action.payload;
18556
18823
  key = payload.key;
18557
18824
  _SceytChatClient0 = getClient();
18558
- _context33.n = 1;
18825
+ _context34.n = 1;
18559
18826
  return call(_SceytChatClient0.Channel.getChannelByInviteKey, key);
18560
18827
  case 1:
18561
- channel = _context33.v;
18828
+ channel = _context34.v;
18562
18829
  if (!(channel && channel.length > 0 && !((_channel$ = channel[0]) !== null && _channel$ !== void 0 && _channel$.role))) {
18563
- _context33.n = 3;
18830
+ _context34.n = 3;
18564
18831
  break;
18565
18832
  }
18566
- _context33.n = 2;
18833
+ _context34.n = 2;
18567
18834
  return put(setJoinableChannelAC(JSON.parse(JSON.stringify(channel[0]))));
18568
18835
  case 2:
18569
18836
  window.history.pushState({}, '', window.location.pathname + '?join=' + key);
18570
- _context33.n = 5;
18837
+ _context34.n = 5;
18571
18838
  break;
18572
18839
  case 3:
18573
18840
  if (!(channel && channel.length > 0 && (_channel$2 = channel[0]) !== null && _channel$2 !== void 0 && _channel$2.role)) {
18574
- _context33.n = 5;
18841
+ _context34.n = 5;
18575
18842
  break;
18576
18843
  }
18577
- _context33.n = 4;
18844
+ _context34.n = 4;
18578
18845
  return put(switchChannelActionAC(JSON.parse(JSON.stringify(channel[0]))));
18579
18846
  case 4:
18580
18847
  window.history.pushState({}, '', window.location.pathname);
18581
18848
  case 5:
18582
- _context33.n = 8;
18849
+ _context34.n = 8;
18583
18850
  break;
18584
18851
  case 6:
18585
- _context33.p = 6;
18586
- _t33 = _context33.v;
18587
- if (!(_t33.code === 1109)) {
18588
- _context33.n = 7;
18852
+ _context34.p = 6;
18853
+ _t34 = _context34.v;
18854
+ if (!(_t34.code === 1109)) {
18855
+ _context34.n = 7;
18589
18856
  break;
18590
18857
  }
18591
- _context33.n = 7;
18858
+ _context34.n = 7;
18592
18859
  return put(setChannelInviteKeyAvailableAC(false));
18593
18860
  case 7:
18594
- log.error('ERROR in get channel by invite key', _t33);
18861
+ log.error('ERROR in get channel by invite key', _t34);
18595
18862
  case 8:
18596
- return _context33.a(2);
18863
+ return _context34.a(2);
18597
18864
  }
18598
- }, _marked33, null, [[0, 6]]);
18865
+ }, _marked34, null, [[0, 6]]);
18599
18866
  }
18600
18867
  function joinChannelWithInviteKey(action) {
18601
- var payload, key, _SceytChatClient1, user, channel, messageToSend, _t34;
18602
- return _regenerator().w(function (_context34) {
18603
- while (1) switch (_context34.p = _context34.n) {
18868
+ var payload, key, _SceytChatClient1, user, channel, messageToSend, _t35;
18869
+ return _regenerator().w(function (_context35) {
18870
+ while (1) switch (_context35.p = _context35.n) {
18604
18871
  case 0:
18605
- _context34.p = 0;
18872
+ _context35.p = 0;
18606
18873
  payload = action.payload;
18607
18874
  key = payload.key;
18608
18875
  _SceytChatClient1 = getClient();
18609
18876
  user = _SceytChatClient1.user;
18610
- _context34.n = 1;
18877
+ _context35.n = 1;
18611
18878
  return call(_SceytChatClient1.Channel.joinChannelByInviteKey, key);
18612
18879
  case 1:
18613
- channel = _context34.v;
18614
- _context34.n = 2;
18880
+ channel = _context35.v;
18881
+ _context35.n = 2;
18615
18882
  return put(setJoinableChannelAC(null));
18616
18883
  case 2:
18617
- _context34.n = 3;
18884
+ _context35.n = 3;
18618
18885
  return call(setChannelInMap, channel);
18619
18886
  case 3:
18620
18887
  messageToSend = {
@@ -18623,47 +18890,47 @@ function joinChannelWithInviteKey(action) {
18623
18890
  attachments: [],
18624
18891
  type: 'system'
18625
18892
  };
18626
- _context34.n = 4;
18893
+ _context35.n = 4;
18627
18894
  return put(sendTextMessageAC(messageToSend, channel === null || channel === void 0 ? void 0 : channel.id, CONNECTION_STATUS.CONNECTED));
18628
18895
  case 4:
18629
- _context34.n = 5;
18896
+ _context35.n = 5;
18630
18897
  return put(switchChannelActionAC(JSON.parse(JSON.stringify(channel))));
18631
18898
  case 5:
18632
18899
  window.history.pushState({}, '', window.location.pathname);
18633
- _context34.n = 7;
18900
+ _context35.n = 7;
18634
18901
  break;
18635
18902
  case 6:
18636
- _context34.p = 6;
18637
- _t34 = _context34.v;
18638
- log.error('ERROR in join channel with invite key', _t34);
18903
+ _context35.p = 6;
18904
+ _t35 = _context35.v;
18905
+ log.error('ERROR in join channel with invite key', _t35);
18639
18906
  case 7:
18640
- return _context34.a(2);
18907
+ return _context35.a(2);
18641
18908
  }
18642
- }, _marked34, null, [[0, 6]]);
18909
+ }, _marked35, null, [[0, 6]]);
18643
18910
  }
18644
18911
  function setMessageRetentionPeriod(action) {
18645
- var payload, channelId, periodInMilliseconds, channel, messageToSend, _t35;
18646
- return _regenerator().w(function (_context35) {
18647
- while (1) switch (_context35.p = _context35.n) {
18912
+ var payload, channelId, periodInMilliseconds, channel, messageToSend, _t36;
18913
+ return _regenerator().w(function (_context36) {
18914
+ while (1) switch (_context36.p = _context36.n) {
18648
18915
  case 0:
18649
- _context35.p = 0;
18916
+ _context36.p = 0;
18650
18917
  payload = action.payload;
18651
18918
  channelId = payload.channelId, periodInMilliseconds = payload.periodInMilliseconds;
18652
- _context35.n = 1;
18919
+ _context36.n = 1;
18653
18920
  return call(getChannelFromMap, channelId);
18654
18921
  case 1:
18655
- channel = _context35.v;
18922
+ channel = _context36.v;
18656
18923
  if (!channel) {
18657
18924
  channel = getChannelFromAllChannels(channelId);
18658
18925
  }
18659
18926
  if (!channel) {
18660
- _context35.n = 4;
18927
+ _context36.n = 4;
18661
18928
  break;
18662
18929
  }
18663
- _context35.n = 2;
18930
+ _context36.n = 2;
18664
18931
  return call(channel.setMessageRetentionPeriod, periodInMilliseconds);
18665
18932
  case 2:
18666
- _context35.n = 3;
18933
+ _context36.n = 3;
18667
18934
  return put(updateChannelDataAC(channelId, {
18668
18935
  messageRetentionPeriod: periodInMilliseconds
18669
18936
  }));
@@ -18680,264 +18947,265 @@ function setMessageRetentionPeriod(action) {
18680
18947
  attachments: [],
18681
18948
  type: 'system'
18682
18949
  };
18683
- _context35.n = 4;
18950
+ _context36.n = 4;
18684
18951
  return put(sendTextMessageAC(messageToSend, channelId, CONNECTION_STATUS.CONNECTED));
18685
18952
  case 4:
18686
- _context35.n = 6;
18953
+ _context36.n = 6;
18687
18954
  break;
18688
18955
  case 5:
18689
- _context35.p = 5;
18690
- _t35 = _context35.v;
18691
- log.error('ERROR in set message retention period', _t35);
18956
+ _context36.p = 5;
18957
+ _t36 = _context36.v;
18958
+ log.error('ERROR in set message retention period', _t36);
18692
18959
  case 6:
18693
- return _context35.a(2);
18960
+ return _context36.a(2);
18694
18961
  }
18695
- }, _marked35, null, [[0, 5]]);
18962
+ }, _marked36, null, [[0, 5]]);
18696
18963
  }
18697
18964
  function getChannelsWithUser(action) {
18698
- var payload, userId, _SceytChatClient10, channelsQueryBuilder, channelsQuery, channelsData, channels, _t36;
18699
- return _regenerator().w(function (_context36) {
18700
- while (1) switch (_context36.p = _context36.n) {
18965
+ var payload, userId, _SceytChatClient10, channelsQueryBuilder, channelsQuery, channelsData, channels, _t37;
18966
+ return _regenerator().w(function (_context37) {
18967
+ while (1) switch (_context37.p = _context37.n) {
18701
18968
  case 0:
18702
- _context36.n = 1;
18969
+ _context37.n = 1;
18703
18970
  return put(setMutualChannelsLoadingStateAC(LOADING_STATE.LOADING));
18704
18971
  case 1:
18705
- _context36.n = 2;
18972
+ _context37.n = 2;
18706
18973
  return put(setMutualChannelsAC([]));
18707
18974
  case 2:
18708
- _context36.p = 2;
18975
+ _context37.p = 2;
18709
18976
  payload = action.payload;
18710
18977
  userId = payload.userId;
18711
18978
  _SceytChatClient10 = getClient();
18712
18979
  channelsQueryBuilder = new _SceytChatClient10.ChannelListQueryBuilder();
18713
18980
  channelsQueryBuilder.memberCount(0);
18714
18981
  channelsQueryBuilder.setMutualWithUserId(userId);
18982
+ channelsQueryBuilder.withExcludeTypes([DEFAULT_CHANNEL_TYPE.DIRECT]);
18715
18983
  channelsQueryBuilder.limit(15);
18716
- _context36.n = 3;
18984
+ _context37.n = 3;
18717
18985
  return call(channelsQueryBuilder.build);
18718
18986
  case 3:
18719
- channelsQuery = _context36.v;
18987
+ channelsQuery = _context37.v;
18720
18988
  query.mutualChannelsQuery = channelsQuery;
18721
- _context36.n = 4;
18989
+ _context37.n = 4;
18722
18990
  return call(channelsQuery.loadNextPage);
18723
18991
  case 4:
18724
- channelsData = _context36.v;
18992
+ channelsData = _context37.v;
18725
18993
  channels = channelsData.channels;
18726
18994
  if (!channelsData.hasNext) {
18727
- _context36.n = 6;
18995
+ _context37.n = 6;
18728
18996
  break;
18729
18997
  }
18730
- _context36.n = 5;
18998
+ _context37.n = 5;
18731
18999
  return put(setMutualChannelsHasNextAC(true));
18732
19000
  case 5:
18733
- _context36.n = 7;
19001
+ _context37.n = 7;
18734
19002
  break;
18735
19003
  case 6:
18736
- _context36.n = 7;
19004
+ _context37.n = 7;
18737
19005
  return put(setMutualChannelsHasNextAC(false));
18738
19006
  case 7:
18739
- _context36.n = 8;
19007
+ _context37.n = 8;
18740
19008
  return put(setMutualChannelsAC(channels));
18741
19009
  case 8:
18742
- _context36.n = 10;
19010
+ _context37.n = 10;
18743
19011
  break;
18744
19012
  case 9:
18745
- _context36.p = 9;
18746
- _t36 = _context36.v;
18747
- log.error('ERROR in get groups in common', _t36);
19013
+ _context37.p = 9;
19014
+ _t37 = _context37.v;
19015
+ log.error('ERROR in get groups in common', _t37);
18748
19016
  case 10:
18749
- _context36.p = 10;
18750
- _context36.n = 11;
19017
+ _context37.p = 10;
19018
+ _context37.n = 11;
18751
19019
  return put(setMutualChannelsLoadingStateAC(LOADING_STATE.LOADED));
18752
19020
  case 11:
18753
- return _context36.f(10);
19021
+ return _context37.f(10);
18754
19022
  case 12:
18755
- return _context36.a(2);
19023
+ return _context37.a(2);
18756
19024
  }
18757
- }, _marked36, null, [[2, 9, 10, 12]]);
19025
+ }, _marked37, null, [[2, 9, 10, 12]]);
18758
19026
  }
18759
19027
  function loadMoreMutualChannels(action) {
18760
- var payload, limit, mutualChannelsQuery, channelsData, _t37;
18761
- return _regenerator().w(function (_context37) {
18762
- while (1) switch (_context37.p = _context37.n) {
19028
+ var payload, limit, mutualChannelsQuery, channelsData, _t38;
19029
+ return _regenerator().w(function (_context38) {
19030
+ while (1) switch (_context38.p = _context38.n) {
18763
19031
  case 0:
18764
- _context37.n = 1;
19032
+ _context38.n = 1;
18765
19033
  return put(setMutualChannelsLoadingStateAC(LOADING_STATE.LOADING));
18766
19034
  case 1:
18767
- _context37.p = 1;
19035
+ _context38.p = 1;
18768
19036
  payload = action.payload;
18769
19037
  limit = payload.limit;
18770
19038
  mutualChannelsQuery = query.mutualChannelsQuery;
18771
19039
  if (mutualChannelsQuery) {
18772
- _context37.n = 2;
19040
+ _context38.n = 2;
18773
19041
  break;
18774
19042
  }
18775
- return _context37.a(2);
19043
+ return _context38.a(2);
18776
19044
  case 2:
18777
19045
  if (limit) {
18778
19046
  mutualChannelsQuery.limit = limit;
18779
19047
  }
18780
- _context37.n = 3;
19048
+ _context38.n = 3;
18781
19049
  return call(mutualChannelsQuery.loadNextPage);
18782
19050
  case 3:
18783
- channelsData = _context37.v;
19051
+ channelsData = _context38.v;
18784
19052
  if (!channelsData.hasNext) {
18785
- _context37.n = 5;
19053
+ _context38.n = 5;
18786
19054
  break;
18787
19055
  }
18788
- _context37.n = 4;
19056
+ _context38.n = 4;
18789
19057
  return put(setMutualChannelsHasNextAC(true));
18790
19058
  case 4:
18791
- _context37.n = 6;
19059
+ _context38.n = 6;
18792
19060
  break;
18793
19061
  case 5:
18794
- _context37.n = 6;
19062
+ _context38.n = 6;
18795
19063
  return put(setMutualChannelsHasNextAC(false));
18796
19064
  case 6:
18797
- _context37.n = 7;
19065
+ _context38.n = 7;
18798
19066
  return put(setMutualChannelsAC(channelsData.channels));
18799
19067
  case 7:
18800
- _context37.n = 9;
19068
+ _context38.n = 9;
18801
19069
  break;
18802
19070
  case 8:
18803
- _context37.p = 8;
18804
- _t37 = _context37.v;
18805
- log.error('ERROR in load more mutual channels', _t37);
19071
+ _context38.p = 8;
19072
+ _t38 = _context38.v;
19073
+ log.error('ERROR in load more mutual channels', _t38);
18806
19074
  case 9:
18807
- _context37.p = 9;
18808
- _context37.n = 10;
19075
+ _context38.p = 9;
19076
+ _context38.n = 10;
18809
19077
  return put(setMutualChannelsLoadingStateAC(LOADING_STATE.LOADED));
18810
19078
  case 10:
18811
- return _context37.f(9);
19079
+ return _context38.f(9);
18812
19080
  case 11:
18813
- return _context37.a(2);
19081
+ return _context38.a(2);
18814
19082
  }
18815
- }, _marked37, null, [[1, 8, 9, 11]]);
19083
+ }, _marked38, null, [[1, 8, 9, 11]]);
18816
19084
  }
18817
19085
  function ChannelsSaga() {
18818
- return _regenerator().w(function (_context38) {
18819
- while (1) switch (_context38.n) {
19086
+ return _regenerator().w(function (_context39) {
19087
+ while (1) switch (_context39.n) {
18820
19088
  case 0:
18821
- _context38.n = 1;
19089
+ _context39.n = 1;
18822
19090
  return takeLatest(CREATE_CHANNEL, createChannel);
18823
19091
  case 1:
18824
- _context38.n = 2;
19092
+ _context39.n = 2;
18825
19093
  return takeLatest(GET_CHANNELS, getChannels);
18826
19094
  case 2:
18827
- _context38.n = 3;
19095
+ _context39.n = 3;
18828
19096
  return takeLatest(SEARCH_CHANNELS, searchChannels);
18829
19097
  case 3:
18830
- _context38.n = 4;
19098
+ _context39.n = 4;
18831
19099
  return takeLatest(GET_CHANNELS_FOR_FORWARD, getChannelsForForward);
18832
19100
  case 4:
18833
- _context38.n = 5;
19101
+ _context39.n = 5;
18834
19102
  return takeLatest(SEARCH_CHANNELS_FOR_FORWARD, searchChannelsForForward);
18835
19103
  case 5:
18836
- _context38.n = 6;
19104
+ _context39.n = 6;
18837
19105
  return takeLatest(LOAD_MORE_CHANNEL, channelsLoadMore);
18838
19106
  case 6:
18839
- _context38.n = 7;
19107
+ _context39.n = 7;
18840
19108
  return takeLatest(LOAD_MORE_CHANNELS_FOR_FORWARD, channelsForForwardLoadMore);
18841
19109
  case 7:
18842
- _context38.n = 8;
19110
+ _context39.n = 8;
18843
19111
  return takeLatest(GET_CHANNELS_WITH_USER, getChannelsWithUser);
18844
19112
  case 8:
18845
- _context38.n = 9;
19113
+ _context39.n = 9;
18846
19114
  return takeLatest(LOAD_MORE_MUTUAL_CHANNELS, loadMoreMutualChannels);
18847
19115
  case 9:
18848
- _context38.n = 10;
19116
+ _context39.n = 10;
18849
19117
  return takeEvery(SWITCH_CHANNEL, switchChannel);
18850
19118
  case 10:
18851
- _context38.n = 11;
19119
+ _context39.n = 11;
18852
19120
  return takeLatest(LEAVE_CHANNEL, leaveChannel);
18853
19121
  case 11:
18854
- _context38.n = 12;
19122
+ _context39.n = 12;
18855
19123
  return takeLatest(DELETE_CHANNEL, deleteChannel);
18856
19124
  case 12:
18857
- _context38.n = 13;
19125
+ _context39.n = 13;
18858
19126
  return takeLatest(BLOCK_CHANNEL, blockChannel);
18859
19127
  case 13:
18860
- _context38.n = 14;
19128
+ _context39.n = 14;
18861
19129
  return takeLatest(UPDATE_CHANNEL, updateChannel);
18862
19130
  case 14:
18863
- _context38.n = 15;
19131
+ _context39.n = 15;
18864
19132
  return takeEvery(MARK_MESSAGES_AS_READ, markMessagesRead);
18865
19133
  case 15:
18866
- _context38.n = 16;
19134
+ _context39.n = 16;
18867
19135
  return takeLatest(MARK_MESSAGES_AS_DELIVERED, markMessagesDelivered);
18868
19136
  case 16:
18869
- _context38.n = 17;
19137
+ _context39.n = 17;
18870
19138
  return takeLatest(MARK_VOICE_MESSAGE_AS_PLAYED, markVoiceMessageAsPlayed);
18871
19139
  case 17:
18872
- _context38.n = 18;
19140
+ _context39.n = 18;
18873
19141
  return takeLatest(WATCH_FOR_EVENTS, watchForChannelEvents);
18874
19142
  case 18:
18875
- _context38.n = 19;
19143
+ _context39.n = 19;
18876
19144
  return takeLatest(TURN_OFF_NOTIFICATION, notificationsTurnOff);
18877
19145
  case 19:
18878
- _context38.n = 20;
19146
+ _context39.n = 20;
18879
19147
  return takeLatest(TURN_ON_NOTIFICATION, notificationsTurnOn);
18880
19148
  case 20:
18881
- _context38.n = 21;
19149
+ _context39.n = 21;
18882
19150
  return takeLatest(MARK_CHANNEL_AS_READ, markChannelAsRead);
18883
19151
  case 21:
18884
- _context38.n = 22;
19152
+ _context39.n = 22;
18885
19153
  return takeLatest(MARK_CHANNEL_AS_UNREAD, markChannelAsUnRead);
18886
19154
  case 22:
18887
- _context38.n = 23;
19155
+ _context39.n = 23;
18888
19156
  return takeLatest(CHECK_USER_STATUS, checkUsersStatus);
18889
19157
  case 23:
18890
- _context38.n = 24;
19158
+ _context39.n = 24;
18891
19159
  return takeLatest(SEND_TYPING, sendTyping);
18892
19160
  case 24:
18893
- _context38.n = 25;
19161
+ _context39.n = 25;
18894
19162
  return takeLatest(SEND_RECORDING, sendRecording);
18895
19163
  case 25:
18896
- _context38.n = 26;
19164
+ _context39.n = 26;
18897
19165
  return takeLatest(PIN_CHANNEL, pinChannel);
18898
19166
  case 26:
18899
- _context38.n = 27;
19167
+ _context39.n = 27;
18900
19168
  return takeLatest(UNPIN_CHANNEL, unpinChannel);
18901
19169
  case 27:
18902
- _context38.n = 28;
19170
+ _context39.n = 28;
18903
19171
  return takeLatest(CLEAR_HISTORY, clearHistory);
18904
19172
  case 28:
18905
- _context38.n = 29;
19173
+ _context39.n = 29;
18906
19174
  return takeLatest(JOIN_TO_CHANNEL, joinChannel);
18907
19175
  case 29:
18908
- _context38.n = 30;
19176
+ _context39.n = 30;
18909
19177
  return takeLatest(DELETE_ALL_MESSAGES, deleteAllMessages);
18910
19178
  case 30:
18911
- _context38.n = 31;
19179
+ _context39.n = 31;
18912
19180
  return takeLatest(REMOVE_CHANNEL_CACHES, removeChannelCaches);
18913
19181
  case 31:
18914
- _context38.n = 32;
19182
+ _context39.n = 32;
18915
19183
  return takeLatest(GET_CHANNEL_MENTIONS, getChannelMentions);
18916
19184
  case 32:
18917
- _context38.n = 33;
19185
+ _context39.n = 33;
18918
19186
  return takeLatest(CREATE_CHANNEL_INVITE_KEY, createChannelInviteKey);
18919
19187
  case 33:
18920
- _context38.n = 34;
19188
+ _context39.n = 34;
18921
19189
  return takeLatest(UPDATE_CHANNEL_INVITE_KEY, updateChannelInviteKey);
18922
19190
  case 34:
18923
- _context38.n = 35;
19191
+ _context39.n = 35;
18924
19192
  return takeLatest(REGENERATE_CHANNEL_INVITE_KEY, regenerateChannelInviteKey);
18925
19193
  case 35:
18926
- _context38.n = 36;
19194
+ _context39.n = 36;
18927
19195
  return takeLatest(GET_CHANNEL_INVITE_KEYS, getChannelInviteKeys);
18928
19196
  case 36:
18929
- _context38.n = 37;
19197
+ _context39.n = 37;
18930
19198
  return takeLatest(GET_CHANNEL_BY_INVITE_KEY, getChannelByInviteKey);
18931
19199
  case 37:
18932
- _context38.n = 38;
19200
+ _context39.n = 38;
18933
19201
  return takeLatest(JOIN_TO_CHANNEL_WITH_INVITE_KEY, joinChannelWithInviteKey);
18934
19202
  case 38:
18935
- _context38.n = 39;
19203
+ _context39.n = 39;
18936
19204
  return takeLatest(SET_MESSAGE_RETENTION_PERIOD, setMessageRetentionPeriod);
18937
19205
  case 39:
18938
- return _context38.a(2);
19206
+ return _context39.a(2);
18939
19207
  }
18940
- }, _marked38);
19208
+ }, _marked39);
18941
19209
  }
18942
19210
 
18943
19211
  function rgbaToThumbHash(w, h, rgba) {
@@ -19337,56 +19605,6 @@ var getFrame = function getFrame(videoSrc, time) {
19337
19605
  }
19338
19606
  };
19339
19607
 
19340
- var SDKErrorTypeEnum = {
19341
- BadRequest: {
19342
- value: 'BadRequest',
19343
- isResendable: false
19344
- },
19345
- BadParam: {
19346
- value: 'BadParam',
19347
- isResendable: false
19348
- },
19349
- NotFound: {
19350
- value: 'NotFound',
19351
- isResendable: false
19352
- },
19353
- NotAllowed: {
19354
- value: 'NotAllowed',
19355
- isResendable: false
19356
- },
19357
- TooLargeRequest: {
19358
- value: 'TooLargeRequest',
19359
- isResendable: false
19360
- },
19361
- InternalError: {
19362
- value: 'InternalError',
19363
- isResendable: true
19364
- },
19365
- TooManyRequests: {
19366
- value: 'TooManyRequests',
19367
- isResendable: true
19368
- },
19369
- Authentication: {
19370
- value: 'Authentication',
19371
- isResendable: true
19372
- }
19373
- };
19374
- var fromValue = function fromValue(value) {
19375
- if (!value) return null;
19376
- var entries = Object.values(SDKErrorTypeEnum);
19377
- return entries.find(function (entry) {
19378
- return entry.value === value;
19379
- }) || null;
19380
- };
19381
- var isResendableError = function isResendableError(value) {
19382
- var _errorType$isResendab;
19383
- if (!value) {
19384
- return true;
19385
- }
19386
- var errorType = fromValue(value);
19387
- return (_errorType$isResendab = errorType === null || errorType === void 0 ? void 0 : errorType.isResendable) != null ? _errorType$isResendab : true;
19388
- };
19389
-
19390
19608
  var _marked$3 = /*#__PURE__*/_regenerator().m(sendMessage),
19391
19609
  _marked2$2 = /*#__PURE__*/_regenerator().m(sendTextMessage),
19392
19610
  _marked3$1 = /*#__PURE__*/_regenerator().m(forwardMessage),
@@ -19582,7 +19800,7 @@ var updateMessage$1 = function updateMessage(actionType, pending, channelId, scr
19582
19800
  break;
19583
19801
  }
19584
19802
  _context.n = 7;
19585
- return put(getMessagesAC(channel, false, channel === null || channel === void 0 ? void 0 : (_channel$lastMessage3 = channel.lastMessage) === null || _channel$lastMessage3 === void 0 ? void 0 : _channel$lastMessage3.id, undefined, false, 'smooth', true));
19803
+ return put(getMessagesAC(channel, true, channel === null || channel === void 0 ? void 0 : (_channel$lastMessage3 = channel.lastMessage) === null || _channel$lastMessage3 === void 0 ? void 0 : _channel$lastMessage3.id, undefined, false, 'smooth', true));
19586
19804
  case 7:
19587
19805
  return _context.a(2);
19588
19806
  }
@@ -19610,6 +19828,9 @@ function sendMessage(action) {
19610
19828
  if (channel) {
19611
19829
  setChannelInMap(channel);
19612
19830
  }
19831
+ if (!channel) {
19832
+ channel = getChannelFromAllChannelsMap(channelId);
19833
+ }
19613
19834
  }
19614
19835
  if (!channel.isMockChannel) {
19615
19836
  _context4.n = 6;
@@ -19796,7 +20017,7 @@ function sendMessage(action) {
19796
20017
  messagesToSend.push(messageToSend);
19797
20018
  case 12:
19798
20019
  _loop2 = /*#__PURE__*/_regenerator().m(function _callee3() {
19799
- var messageAttachment, messageToSend, messageCopy, _attachmentsToSend, linkAttachmentToSend, linkAttachmentBuilder, messageResponse, k, pendingAttachment, attachmentsToUpdate, currentAttachmentsMap, messageUpdateData, stringifiedMessageUpdateData, activeChannelId, messageToUpdate, channelUpdateParam, isErrorResendable, _t;
20020
+ var messageAttachment, messageToSend, messageCopy, _attachmentsToSend, linkAttachmentToSend, linkAttachmentBuilder, messageResponse, k, pendingAttachment, attachmentsToUpdate, currentAttachmentsMap, messageUpdateData, stringifiedMessageUpdateData, activeChannelId, messageToUpdate, channelUpdateParam, _channel, _messageToSend2, _channel2, isErrorResendable, _t;
19800
20021
  return _regenerator().w(function (_context3) {
19801
20022
  while (1) switch (_context3.p = _context3.n) {
19802
20023
  case 0:
@@ -19882,22 +20103,10 @@ function sendMessage(action) {
19882
20103
  return attachment;
19883
20104
  });
19884
20105
  }
19885
- messageUpdateData = {
19886
- id: messageResponse.id,
19887
- body: messageResponse.body,
19888
- type: messageResponse.type,
19889
- state: messageResponse.state,
19890
- displayCount: messageResponse.displayCount,
19891
- deliveryStatus: messageResponse.deliveryStatus,
20106
+ messageUpdateData = _extends({}, messageResponse, {
19892
20107
  attachments: attachmentsToUpdate,
19893
- mentionedUsers: messageResponse.mentionedUsers,
19894
- bodyAttributes: messageResponse.bodyAttributes,
19895
- metadata: messageResponse.metadata,
19896
- parentMessage: messageResponse.parentMessage,
19897
- repliedInThread: messageResponse.repliedInThread,
19898
- createdAt: messageResponse.createdAt,
19899
20108
  channelId: channel.id
19900
- };
20109
+ });
19901
20110
  stringifiedMessageUpdateData = JSON.parse(JSON.stringify(messageResponse));
19902
20111
  activeChannelId = getActiveChannelId();
19903
20112
  if (!(activeChannelId === channel.id)) {
@@ -19940,7 +20149,7 @@ function sendMessage(action) {
19940
20149
  _context3.p = 15;
19941
20150
  _t = _context3.v;
19942
20151
  isErrorResendable = isResendableError(_t === null || _t === void 0 ? void 0 : _t.type);
19943
- if (isErrorResendable) {
20152
+ if (!(!isErrorResendable && (_channel = channel) !== null && _channel !== void 0 && _channel.id && (_messageToSend2 = messageToSend) !== null && _messageToSend2 !== void 0 && _messageToSend2.tid)) {
19944
20153
  _context3.n = 17;
19945
20154
  break;
19946
20155
  }
@@ -19950,6 +20159,10 @@ function sendMessage(action) {
19950
20159
  _context3.n = 19;
19951
20160
  break;
19952
20161
  case 17:
20162
+ if (!((_channel2 = channel) !== null && _channel2 !== void 0 && _channel2.id)) {
20163
+ _context3.n = 19;
20164
+ break;
20165
+ }
19953
20166
  log.error('Error on uploading attachment', messageToSend.tid, _t);
19954
20167
  if (!(messageToSend.attachments && messageToSend.attachments.length)) {
19955
20168
  _context3.n = 18;
@@ -20006,7 +20219,7 @@ function sendMessage(action) {
20006
20219
  }, _marked$3, null, [[1, 16, 17, 19]]);
20007
20220
  }
20008
20221
  function sendTextMessage(action) {
20009
- var payload, message, connectionState, channelId, channel, sendMessageTid, pendingMessage, SceytChatClient, createChannelData, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, createdMessage, messageToSend, _messageResponse, messageResponse, messageUpdateData, activeChannelId, stringifiedMessageUpdateData, messageToUpdate, channelUpdateParam, isErrorResendable, _activeChannelId, _t3;
20222
+ var payload, message, connectionState, channelId, channel, sendMessageTid, pendingMessage, SceytChatClient, createChannelData, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, createdMessage, messageToSend, messageResponse, messageUpdateData, activeChannelId, stringifiedMessageUpdateData, messageToUpdate, channelUpdateParam, _channel3, _channel4, isErrorResendable, _activeChannelId, _t3;
20010
20223
  return _regenerator().w(function (_context5) {
20011
20224
  while (1) switch (_context5.p = _context5.n) {
20012
20225
  case 0:
@@ -20024,6 +20237,9 @@ function sendTextMessage(action) {
20024
20237
  if (channel) {
20025
20238
  setChannelInMap(channel);
20026
20239
  }
20240
+ if (!channel) {
20241
+ channel = getChannelFromAllChannelsMap(channelId);
20242
+ }
20027
20243
  }
20028
20244
  sendMessageTid = null;
20029
20245
  pendingMessage = null;
@@ -20113,23 +20329,9 @@ function sendTextMessage(action) {
20113
20329
  case 11:
20114
20330
  messageResponse = _context5.v;
20115
20331
  case 12:
20116
- messageUpdateData = {
20117
- id: messageResponse.id,
20118
- body: messageResponse.body,
20119
- type: messageResponse.type,
20120
- state: messageResponse.state,
20121
- bodyAttributes: messageResponse.bodyAttributes,
20122
- displayCount: messageResponse.displayCount,
20123
- deliveryStatus: messageResponse.deliveryStatus,
20124
- attachments: messageResponse.attachments,
20125
- mentionedUsers: messageResponse.mentionedUsers,
20126
- metadata: messageResponse.metadata,
20127
- parentMessage: messageResponse.parentMessage,
20128
- repliedInThread: messageResponse.repliedInThread,
20129
- createdAt: messageResponse.createdAt,
20130
- pollDetails: (_messageResponse = messageResponse) === null || _messageResponse === void 0 ? void 0 : _messageResponse.pollDetails,
20332
+ messageUpdateData = _extends({}, messageResponse, {
20131
20333
  channelId: channel.id
20132
- };
20334
+ });
20133
20335
  activeChannelId = getActiveChannelId();
20134
20336
  if (!(activeChannelId === channel.id)) {
20135
20337
  _context5.n = 13;
@@ -20179,7 +20381,7 @@ function sendTextMessage(action) {
20179
20381
  _t3 = _context5.v;
20180
20382
  log.error('error on send text message ... ', _t3 === null || _t3 === void 0 ? void 0 : _t3.type);
20181
20383
  isErrorResendable = isResendableError(_t3 === null || _t3 === void 0 ? void 0 : _t3.type);
20182
- if (!(!isErrorResendable && channel.id && sendMessageTid)) {
20384
+ if (!(!isErrorResendable && (_channel3 = channel) !== null && _channel3 !== void 0 && _channel3.id && sendMessageTid)) {
20183
20385
  _context5.n = 22;
20184
20386
  break;
20185
20387
  }
@@ -20189,7 +20391,7 @@ function sendTextMessage(action) {
20189
20391
  _context5.n = 23;
20190
20392
  break;
20191
20393
  case 22:
20192
- if (!(channel.id && sendMessageTid)) {
20394
+ if (!((_channel4 = channel) !== null && _channel4 !== void 0 && _channel4.id && sendMessageTid)) {
20193
20395
  _context5.n = 23;
20194
20396
  break;
20195
20397
  }
@@ -20223,7 +20425,7 @@ function sendTextMessage(action) {
20223
20425
  }, _marked2$2, null, [[3, 20, 23, 25]]);
20224
20426
  }
20225
20427
  function forwardMessage(action) {
20226
- var payload, message, channelId, connectionState, isForward, pendingMessage, channel, activeChannelId, messageTid, SceytChatClient, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, pollDetails, messageToSend, hasNextMessages, messageResponse, messageUpdateData, messageToUpdate, channelUpdateParam, isErrorResendable, _activeChannelId2, _t4;
20428
+ var payload, message, channelId, connectionState, isForward, pendingMessage, channel, activeChannelId, messageTid, SceytChatClient, mentionedUserIds, attachments, attachmentBuilder, att, messageBuilder, pollDetails, messageToSend, hasNextMessages, messageResponse, messageUpdateData, messageToUpdate, channelUpdateParam, _channel5, isErrorResendable, _channel6, _activeChannelId2, _t4;
20227
20429
  return _regenerator().w(function (_context6) {
20228
20430
  while (1) switch (_context6.p = _context6.n) {
20229
20431
  case 0:
@@ -20259,6 +20461,9 @@ function forwardMessage(action) {
20259
20461
  if (channel) {
20260
20462
  setChannelInMap(channel);
20261
20463
  }
20464
+ if (!channel) {
20465
+ channel = getChannelFromAllChannelsMap(channelId);
20466
+ }
20262
20467
  case 6:
20263
20468
  if (channel) {
20264
20469
  _context6.n = 7;
@@ -20349,20 +20554,9 @@ function forwardMessage(action) {
20349
20554
  return call(channel.sendMessage, messageToSend);
20350
20555
  case 10:
20351
20556
  messageResponse = _context6.v;
20352
- messageUpdateData = {
20353
- id: messageResponse.id,
20354
- type: messageResponse.type,
20355
- state: messageResponse.state,
20356
- displayCount: messageResponse.displayCount,
20357
- deliveryStatus: messageResponse.deliveryStatus,
20358
- attachments: messageResponse.attachments,
20359
- mentionedUsers: messageResponse.mentionedUsers,
20360
- metadata: messageResponse.metadata,
20361
- parentMessage: messageResponse.parentMessage,
20362
- repliedInThread: messageResponse.repliedInThread,
20363
- createdAt: messageResponse.createdAt,
20557
+ messageUpdateData = _extends({}, messageResponse, {
20364
20558
  channelId: channel.id
20365
- };
20559
+ });
20366
20560
  if (!(channelId === activeChannelId)) {
20367
20561
  _context6.n = 12;
20368
20562
  break;
@@ -20408,7 +20602,7 @@ function forwardMessage(action) {
20408
20602
  _context6.p = 18;
20409
20603
  _t4 = _context6.v;
20410
20604
  isErrorResendable = isResendableError(_t4 === null || _t4 === void 0 ? void 0 : _t4.type);
20411
- if (isErrorResendable) {
20605
+ if (!(!isErrorResendable && (_channel5 = channel) !== null && _channel5 !== void 0 && _channel5.id && messageTid)) {
20412
20606
  _context6.n = 20;
20413
20607
  break;
20414
20608
  }
@@ -20418,7 +20612,7 @@ function forwardMessage(action) {
20418
20612
  _context6.n = 21;
20419
20613
  break;
20420
20614
  case 20:
20421
- if (!(channel && messageTid)) {
20615
+ if (!((_channel6 = channel) !== null && _channel6 !== void 0 && _channel6.id && messageTid)) {
20422
20616
  _context6.n = 21;
20423
20617
  break;
20424
20618
  }
@@ -20764,7 +20958,7 @@ var getFilteredPendingMessages = function getFilteredPendingMessages(messages) {
20764
20958
  return filteredPendingMessages;
20765
20959
  };
20766
20960
  function getMessagesQuery(action) {
20767
- var _action$payload, channel, loadWithLastMessage, messageId, limit, highlight, behavior, scrollToMessage, networkChanged, connectionState, SceytChatClient, messageQueryBuilder, messageQuery, cachedMessages, result, _result$messages$, _result$messages, _messages$Math$floor, messages, centerMessageId, loadWithMessageId, allMessages, messageIndex, maxLengthPart, _result$messages$2, _result$messages2, secondResult, thirdResult, fourthResult, _fourthResult, _result$messages$3, _result$messages3, _channel$lastMessage4, _channel$lastMessage5, _channel$lastMessage6, _updatedMessages$, _parsedMessages$, _parsedMessages, parsedMessages, _filteredPendingMessages, updatedMessages, messageIdForLoad, filteredPendingMessages, waitToSendPendingMessages, updatedChannel, _t0, _t1, _t10, _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19, _t20;
20961
+ var _action$payload, channel, loadWithLastMessage, messageId, limit, highlight, behavior, scrollToMessage, networkChanged, channelNewMessageCount, connectionState, SceytChatClient, _updatedChannel, messageQueryBuilder, messageQuery, cachedMessages, result, _result$messages$, _result$messages, _result$messages$2, _result$messages2, messages, loadNextMessageId, loadPreviousMessageId, nextLoadLimit, previousLoadLimit, centerMessageIndex, firstResult, secondResult, _result$messages$3, _result$messages3, _channel$lastMessage4, _channel$lastMessage5, _channel$lastMessage6, _result$messages4, _messages, _filteredPendingMessages, updatedMessages, messageIdForLoad, _updatedMessages$, filteredPendingMessages, waitToSendPendingMessages, updatedChannel, _t0, _t1, _t10, _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18;
20768
20962
  return _regenerator().w(function (_context10) {
20769
20963
  while (1) switch (_context10.p = _context10.n) {
20770
20964
  case 0:
@@ -20773,29 +20967,69 @@ function getMessagesQuery(action) {
20773
20967
  return put(setMessagesLoadingStateAC(LOADING_STATE.LOADING));
20774
20968
  case 1:
20775
20969
  _action$payload = action.payload, channel = _action$payload.channel, loadWithLastMessage = _action$payload.loadWithLastMessage, messageId = _action$payload.messageId, limit = _action$payload.limit, highlight = _action$payload.highlight, behavior = _action$payload.behavior, scrollToMessage = _action$payload.scrollToMessage, networkChanged = _action$payload.networkChanged;
20970
+ channelNewMessageCount = (channel === null || channel === void 0 ? void 0 : channel.newMessageCount) || 0;
20776
20971
  connectionState = store.getState().UserReducer.connectionStatus;
20777
20972
  if (!(channel !== null && channel !== void 0 && channel.id && !(channel !== null && channel !== void 0 && channel.isMockChannel))) {
20778
- _context10.n = 84;
20973
+ _context10.n = 77;
20779
20974
  break;
20780
20975
  }
20781
20976
  SceytChatClient = getClient();
20977
+ if (!networkChanged) {
20978
+ _context10.n = 8;
20979
+ break;
20980
+ }
20981
+ _context10.p = 2;
20982
+ _context10.n = 3;
20983
+ return call(SceytChatClient.getChannel, channel.id, true);
20984
+ case 3:
20985
+ _updatedChannel = _context10.v;
20986
+ if (!(_updatedChannel && _updatedChannel !== null && _updatedChannel !== void 0 && _updatedChannel.id)) {
20987
+ _context10.n = 6;
20988
+ break;
20989
+ }
20990
+ _context10.n = 4;
20991
+ return put(updateChannelDataAC(channel.id, _extends({}, _updatedChannel)));
20992
+ case 4:
20993
+ channelNewMessageCount = (_updatedChannel === null || _updatedChannel === void 0 ? void 0 : _updatedChannel.newMessageCount) || 0;
20994
+ if (!(channelNewMessageCount !== channel.newMessageCount)) {
20995
+ _context10.n = 6;
20996
+ break;
20997
+ }
20998
+ _context10.n = 5;
20999
+ return put(updateChannelDataAC(channel.id, {
21000
+ newMessageCount: channelNewMessageCount
21001
+ }));
21002
+ case 5:
21003
+ updateChannelOnAllChannels(channel.id, {
21004
+ newMessageCount: channelNewMessageCount
21005
+ });
21006
+ _context10.n = 6;
21007
+ return put(setUnreadMessageIdAC(channel.lastDisplayedMessageId));
21008
+ case 6:
21009
+ _context10.n = 8;
21010
+ break;
21011
+ case 7:
21012
+ _context10.p = 7;
21013
+ _t0 = _context10.v;
21014
+ log.error('error to get updated channel in get messages query', _t0);
21015
+ case 8:
20782
21016
  messageQueryBuilder = new SceytChatClient.MessageListQueryBuilder(channel.id);
20783
21017
  messageQueryBuilder.limit(limit || MESSAGES_MAX_LENGTH);
20784
21018
  messageQueryBuilder.reverse(true);
20785
21019
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
20786
- _context10.n = 3;
21020
+ _context10.n = 10;
20787
21021
  break;
20788
21022
  }
20789
- _context10.n = 2;
21023
+ _context10.n = 9;
20790
21024
  return call(messageQueryBuilder.build);
20791
- case 2:
20792
- _t0 = _context10.v;
20793
- _context10.n = 4;
21025
+ case 9:
21026
+ _t1 = _context10.v;
21027
+ _context10.n = 11;
20794
21028
  break;
20795
- case 3:
20796
- _t0 = null;
20797
- case 4:
20798
- messageQuery = _t0;
21029
+ case 10:
21030
+ _t1 = null;
21031
+ case 11:
21032
+ messageQuery = _t1;
20799
21033
  query.messageQuery = messageQuery;
20800
21034
  cachedMessages = Object.values(getMessagesFromMap(channel.id) || {}).sort(function (a, b) {
20801
21035
  return Number(a.id) - Number(b.id);
@@ -20805,161 +21039,126 @@ function getMessagesQuery(action) {
20805
21039
  hasNext: false
20806
21040
  };
20807
21041
  if (!loadWithLastMessage) {
20808
- _context10.n = 22;
21042
+ _context10.n = 29;
20809
21043
  break;
20810
21044
  }
20811
- if (!(channel.newMessageCount && channel.newMessageCount > 0)) {
20812
- _context10.n = 15;
21045
+ if (!(channelNewMessageCount && channelNewMessageCount > 0)) {
21046
+ _context10.n = 22;
20813
21047
  break;
20814
21048
  }
20815
21049
  setHasPrevCached(false);
20816
21050
  setAllMessages([]);
20817
21051
  messageQuery.limit = MESSAGES_MAX_LENGTH;
20818
21052
  if (!Number(channel.lastDisplayedMessageId)) {
20819
- _context10.n = 8;
21053
+ _context10.n = 15;
20820
21054
  break;
20821
21055
  }
20822
21056
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
20823
- _context10.n = 6;
21057
+ _context10.n = 13;
20824
21058
  break;
20825
21059
  }
20826
- _context10.n = 5;
21060
+ _context10.n = 12;
20827
21061
  return call(messageQuery.loadNearMessageId, channel.lastDisplayedMessageId);
20828
- case 5:
20829
- _t1 = _context10.v;
20830
- _context10.n = 7;
21062
+ case 12:
21063
+ _t10 = _context10.v;
21064
+ _context10.n = 14;
20831
21065
  break;
20832
- case 6:
20833
- _t1 = {
21066
+ case 13:
21067
+ _t10 = {
20834
21068
  messages: [],
20835
21069
  hasNext: false
20836
21070
  };
20837
- case 7:
20838
- result = _t1;
20839
- _context10.n = 12;
21071
+ case 14:
21072
+ result = _t10;
21073
+ _context10.n = 19;
20840
21074
  break;
20841
- case 8:
21075
+ case 15:
20842
21076
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
20843
- _context10.n = 10;
21077
+ _context10.n = 17;
20844
21078
  break;
20845
21079
  }
20846
- _context10.n = 9;
21080
+ _context10.n = 16;
20847
21081
  return call(messageQuery.loadPrevious);
20848
- case 9:
20849
- _t10 = _context10.v;
20850
- _context10.n = 11;
21082
+ case 16:
21083
+ _t11 = _context10.v;
21084
+ _context10.n = 18;
20851
21085
  break;
20852
- case 10:
20853
- _t10 = {
21086
+ case 17:
21087
+ _t11 = {
20854
21088
  messages: [],
20855
21089
  hasNext: false
20856
21090
  };
20857
- case 11:
20858
- result = _t10;
20859
- case 12:
20860
- _context10.n = 13;
20861
- return put(setMessagesAC(JSON.parse(JSON.stringify(result.messages))));
20862
- case 13:
20863
- setMessagesToMap(channel.id, result.messages, (_result$messages$ = result.messages[0]) === null || _result$messages$ === void 0 ? void 0 : _result$messages$.id, (_result$messages = result.messages[result.messages.length - 1]) === null || _result$messages === void 0 ? void 0 : _result$messages.id);
20864
- setAllMessages(result.messages);
20865
- _context10.n = 14;
20866
- return put(setMessagesHasPrevAC(true));
20867
- case 14:
20868
- _context10.n = 17;
20869
- break;
20870
- case 15:
20871
- result.messages = getFromAllMessagesByMessageId('', '', true);
20872
- _context10.n = 16;
20873
- return put(setMessagesAC(JSON.parse(JSON.stringify(result.messages))));
20874
- case 16:
20875
- _context10.n = 17;
20876
- return put(setMessagesHasPrevAC(true));
20877
- case 17:
20878
- _context10.n = 18;
20879
- return put(setMessagesHasNextAC(false));
20880
21091
  case 18:
20881
- setHasNextCached(false);
20882
- if (!(messageId && scrollToMessage)) {
20883
- _context10.n = 21;
20884
- break;
20885
- }
20886
- if (!(channel.newMessageCount && channel.newMessageCount > 0)) {
20887
- _context10.n = 20;
20888
- break;
20889
- }
20890
- _context10.n = 19;
20891
- return put(setScrollToMessagesAC(channel.lastDisplayedMessageId, highlight, behavior));
21092
+ result = _t11;
20892
21093
  case 19:
20893
- _context10.n = 21;
20894
- break;
21094
+ _context10.n = 20;
21095
+ return put(setMessagesAC(JSON.parse(JSON.stringify(result.messages))));
20895
21096
  case 20:
21097
+ setMessagesToMap(channel.id, result.messages, (_result$messages$ = result.messages[0]) === null || _result$messages$ === void 0 ? void 0 : _result$messages$.id, (_result$messages = result.messages[result.messages.length - 1]) === null || _result$messages === void 0 ? void 0 : _result$messages.id);
21098
+ setAllMessages(result.messages);
20896
21099
  _context10.n = 21;
20897
- return put(scrollToNewMessageAC(true));
21100
+ return put(setMessagesHasPrevAC(true));
20898
21101
  case 21:
20899
- _context10.n = 77;
21102
+ _context10.n = 24;
20900
21103
  break;
20901
21104
  case 22:
20902
- if (!messageId) {
20903
- _context10.n = 52;
20904
- break;
20905
- }
20906
- messages = store.getState().MessageReducer.activeChannelMessages;
20907
- centerMessageId = (_messages$Math$floor = messages[Math.floor(messages.length / 2)]) === null || _messages$Math$floor === void 0 ? void 0 : _messages$Math$floor.id;
20908
- loadWithMessageId = networkChanged && (messages === null || messages === void 0 ? void 0 : messages.length) > 0 ? centerMessageId : messageId;
20909
- allMessages = getAllMessages();
20910
- messageIndex = allMessages.findIndex(function (msg) {
20911
- return msg.id === loadWithMessageId;
20912
- });
20913
- maxLengthPart = MESSAGES_MAX_LENGTH / 2;
20914
- if (!(messageIndex >= maxLengthPart)) {
20915
- _context10.n = 25;
20916
- break;
20917
- }
20918
- result.messages = allMessages.slice(messageIndex - maxLengthPart, messageIndex + maxLengthPart);
21105
+ result.messages = getFromAllMessagesByMessageId('', '', true);
20919
21106
  _context10.n = 23;
20920
21107
  return put(setMessagesAC(JSON.parse(JSON.stringify(result.messages))));
20921
21108
  case 23:
20922
- setHasPrevCached(messageIndex > maxLengthPart);
20923
- setHasNextCached(allMessages.length > maxLengthPart);
20924
21109
  _context10.n = 24;
20925
21110
  return put(setMessagesHasPrevAC(true));
20926
21111
  case 24:
20927
- _context10.n = 48;
20928
- break;
21112
+ _context10.n = 25;
21113
+ return put(setMessagesHasNextAC(false));
20929
21114
  case 25:
20930
- messageQuery.limit = MESSAGES_MAX_LENGTH;
20931
- log.info('load by message id from server ...............', loadWithMessageId);
20932
- if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
21115
+ setHasNextCached(false);
21116
+ if (!(messageId && scrollToMessage)) {
21117
+ _context10.n = 28;
21118
+ break;
21119
+ }
21120
+ if (!(channelNewMessageCount && channelNewMessageCount > 0)) {
20933
21121
  _context10.n = 27;
20934
21122
  break;
20935
21123
  }
20936
21124
  _context10.n = 26;
20937
- return call(messageQuery.loadNearMessageId, loadWithMessageId);
21125
+ return put(setScrollToMessagesAC(channel.lastDisplayedMessageId, highlight, behavior));
20938
21126
  case 26:
20939
- _t11 = _context10.v;
20940
21127
  _context10.n = 28;
20941
21128
  break;
20942
21129
  case 27:
20943
- _t11 = {
20944
- messages: [],
20945
- hasNext: false
20946
- };
21130
+ _context10.n = 28;
21131
+ return put(scrollToNewMessageAC(true));
20947
21132
  case 28:
20948
- result = _t11;
20949
- _context10.n = 29;
20950
- return put(setMessagesAC(JSON.parse(JSON.stringify(result.messages))));
21133
+ _context10.n = 70;
21134
+ break;
20951
21135
  case 29:
20952
- if (!(result.messages.length === 50)) {
20953
- _context10.n = 47;
21136
+ if (!messageId) {
21137
+ _context10.n = 40;
20954
21138
  break;
20955
21139
  }
20956
- messageQuery.limit = (MESSAGES_MAX_PAGE_COUNT - 50) / 2;
21140
+ messages = store.getState().MessageReducer.activeChannelMessages;
21141
+ loadNextMessageId = '';
21142
+ loadPreviousMessageId = '';
21143
+ nextLoadLimit = MESSAGES_MAX_PAGE_COUNT / 2;
21144
+ previousLoadLimit = MESSAGES_MAX_PAGE_COUNT / 2;
21145
+ if (networkChanged) {
21146
+ centerMessageIndex = getCenterTwoMessages(messages);
21147
+ loadPreviousMessageId = centerMessageIndex.mid2.messageId;
21148
+ loadNextMessageId = centerMessageIndex.mid1.messageId;
21149
+ previousLoadLimit = centerMessageIndex.mid2.index;
21150
+ nextLoadLimit = messages.length - centerMessageIndex.mid1.index - 1;
21151
+ } else if (messageId) {
21152
+ loadPreviousMessageId = messageId;
21153
+ }
21154
+ messageQuery.limit = previousLoadLimit;
21155
+ log.info('load by message id from server ...............', messageId);
20957
21156
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
20958
21157
  _context10.n = 31;
20959
21158
  break;
20960
21159
  }
20961
21160
  _context10.n = 30;
20962
- return call(messageQuery.loadPreviousMessageId, result.messages[0].id);
21161
+ return call(messageQuery.loadPreviousMessageId, loadPreviousMessageId);
20963
21162
  case 30:
20964
21163
  _t12 = _context10.v;
20965
21164
  _context10.n = 32;
@@ -20970,234 +21169,185 @@ function getMessagesQuery(action) {
20970
21169
  hasNext: false
20971
21170
  };
20972
21171
  case 32:
20973
- secondResult = _t12;
20974
- result.messages = [].concat(secondResult.messages, result.messages);
20975
- _context10.n = 33;
20976
- return put(addMessagesAC(JSON.parse(JSON.stringify(secondResult.messages)), MESSAGE_LOAD_DIRECTION.PREV));
20977
- case 33:
20978
- messageQuery.limit = MESSAGES_MAX_PAGE_COUNT - 50 - secondResult.messages.length;
21172
+ firstResult = _t12;
21173
+ if (!networkChanged && firstResult.messages.length > 0) {
21174
+ loadNextMessageId = firstResult.messages[firstResult.messages.length - 1].id;
21175
+ } else if (!networkChanged && !firstResult.messages.length) {
21176
+ loadNextMessageId = '0';
21177
+ }
20979
21178
  messageQuery.reverse = false;
21179
+ messageQuery.limit = nextLoadLimit;
20980
21180
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
20981
- _context10.n = 35;
21181
+ _context10.n = 34;
20982
21182
  break;
20983
21183
  }
20984
- _context10.n = 34;
20985
- return call(messageQuery.loadNextMessageId, result.messages[result.messages.length - 1].id);
20986
- case 34:
21184
+ _context10.n = 33;
21185
+ return call(messageQuery.loadNextMessageId, loadNextMessageId);
21186
+ case 33:
20987
21187
  _t13 = _context10.v;
20988
- _context10.n = 36;
21188
+ _context10.n = 35;
20989
21189
  break;
20990
- case 35:
21190
+ case 34:
20991
21191
  _t13 = {
20992
21192
  messages: [],
20993
21193
  hasNext: false
20994
21194
  };
21195
+ case 35:
21196
+ secondResult = _t13;
21197
+ result.messages = [].concat(firstResult.messages, secondResult.messages);
21198
+ _context10.n = 36;
21199
+ return put(setMessagesAC(JSON.parse(JSON.stringify(result.messages))));
20995
21200
  case 36:
20996
- thirdResult = _t13;
20997
- result.messages = [].concat(result.messages, thirdResult.messages);
20998
- _context10.n = 37;
20999
- return put(addMessagesAC(JSON.parse(JSON.stringify(thirdResult.messages)), MESSAGE_LOAD_DIRECTION.NEXT));
21000
- case 37:
21001
- if (!(secondResult.hasNext && !thirdResult.hasNext)) {
21002
- _context10.n = 42;
21003
- break;
21004
- }
21005
- messageQuery.limit = MESSAGES_MAX_PAGE_COUNT - 50 - secondResult.messages.length - result.messages.length;
21006
- if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
21007
- _context10.n = 39;
21008
- break;
21009
- }
21010
- _context10.n = 38;
21011
- return call(messageQuery.loadPreviousMessageId, result.messages[0].id);
21012
- case 38:
21013
- _t14 = _context10.v;
21014
- _context10.n = 40;
21015
- break;
21016
- case 39:
21017
- _t14 = {
21018
- messages: [],
21019
- hasNext: false
21020
- };
21021
- case 40:
21022
- fourthResult = _t14;
21023
- result.messages = [].concat(fourthResult.messages, result.messages);
21024
- _context10.n = 41;
21025
- return put(addMessagesAC(JSON.parse(JSON.stringify(fourthResult.messages)), MESSAGE_LOAD_DIRECTION.PREV));
21026
- case 41:
21027
- _context10.n = 46;
21028
- break;
21029
- case 42:
21030
- if (!(!secondResult.hasNext && thirdResult.hasNext)) {
21031
- _context10.n = 46;
21032
- break;
21033
- }
21034
- messageQuery.limit = MESSAGES_MAX_PAGE_COUNT - 50 - secondResult.messages.length - result.messages.length;
21035
- if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
21036
- _context10.n = 44;
21037
- break;
21038
- }
21039
- _context10.n = 43;
21040
- return call(messageQuery.loadNextMessageId, result.messages[result.messages.length - 1].id);
21041
- case 43:
21042
- _t15 = _context10.v;
21043
- _context10.n = 45;
21044
- break;
21045
- case 44:
21046
- _t15 = {
21047
- messages: [],
21048
- hasNext: false
21049
- };
21050
- case 45:
21051
- _fourthResult = _t15;
21052
- result.messages = [].concat(result.messages, _fourthResult.messages);
21053
- _context10.n = 46;
21054
- return put(addMessagesAC(JSON.parse(JSON.stringify(_fourthResult.messages)), MESSAGE_LOAD_DIRECTION.NEXT));
21055
- case 46:
21056
- messageQuery.reverse = true;
21057
- case 47:
21058
21201
  setMessagesToMap(channel.id, result.messages, (_result$messages$2 = result.messages[0]) === null || _result$messages$2 === void 0 ? void 0 : _result$messages$2.id, (_result$messages2 = result.messages[result.messages.length - 1]) === null || _result$messages2 === void 0 ? void 0 : _result$messages2.id);
21059
21202
  setAllMessages([].concat(result.messages));
21060
21203
  setHasPrevCached(false);
21061
21204
  setHasNextCached(false);
21062
- case 48:
21063
- _context10.n = 49;
21205
+ _context10.n = 37;
21064
21206
  return put(setMessagesHasNextAC(true));
21065
- case 49:
21066
- if (!scrollToMessage) {
21067
- _context10.n = 50;
21207
+ case 37:
21208
+ if (!(scrollToMessage && !networkChanged)) {
21209
+ _context10.n = 38;
21068
21210
  break;
21069
21211
  }
21070
- _context10.n = 50;
21071
- return put(setScrollToMessagesAC(loadWithMessageId, highlight, behavior));
21072
- case 50:
21073
- _context10.n = 51;
21212
+ _context10.n = 38;
21213
+ return put(setScrollToMessagesAC(messageId, highlight, behavior));
21214
+ case 38:
21215
+ _context10.n = 39;
21074
21216
  return put(setMessagesLoadingStateAC(LOADING_STATE.LOADED));
21075
- case 51:
21076
- _context10.n = 77;
21217
+ case 39:
21218
+ _context10.n = 70;
21077
21219
  break;
21078
- case 52:
21079
- if (!(channel.newMessageCount && channel.lastDisplayedMessageId)) {
21080
- _context10.n = 64;
21220
+ case 40:
21221
+ if (!(channelNewMessageCount && channel.lastDisplayedMessageId)) {
21222
+ _context10.n = 54;
21081
21223
  break;
21082
21224
  }
21083
21225
  setAllMessages([]);
21084
21226
  messageQuery.limit = MESSAGES_MAX_LENGTH;
21085
21227
  if (!Number(channel.lastDisplayedMessageId)) {
21086
- _context10.n = 56;
21228
+ _context10.n = 44;
21087
21229
  break;
21088
21230
  }
21089
21231
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
21090
- _context10.n = 54;
21232
+ _context10.n = 42;
21091
21233
  break;
21092
21234
  }
21093
- _context10.n = 53;
21235
+ _context10.n = 41;
21094
21236
  return call(messageQuery.loadNearMessageId, channel.lastDisplayedMessageId);
21095
- case 53:
21096
- _t16 = _context10.v;
21097
- _context10.n = 55;
21237
+ case 41:
21238
+ _t14 = _context10.v;
21239
+ _context10.n = 43;
21098
21240
  break;
21099
- case 54:
21100
- _t16 = {
21241
+ case 42:
21242
+ _t14 = {
21101
21243
  messages: [],
21102
21244
  hasNext: false
21103
21245
  };
21104
- case 55:
21105
- result = _t16;
21106
- _context10.n = 60;
21246
+ case 43:
21247
+ result = _t14;
21248
+ _context10.n = 48;
21107
21249
  break;
21108
- case 56:
21250
+ case 44:
21109
21251
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
21110
- _context10.n = 58;
21252
+ _context10.n = 46;
21111
21253
  break;
21112
21254
  }
21113
- _context10.n = 57;
21255
+ _context10.n = 45;
21114
21256
  return call(messageQuery.loadPrevious);
21115
- case 57:
21116
- _t17 = _context10.v;
21117
- _context10.n = 59;
21257
+ case 45:
21258
+ _t15 = _context10.v;
21259
+ _context10.n = 47;
21118
21260
  break;
21119
- case 58:
21120
- _t17 = {
21261
+ case 46:
21262
+ _t15 = {
21121
21263
  messages: [],
21122
21264
  hasNext: false
21123
21265
  };
21124
- case 59:
21125
- result = _t17;
21126
- case 60:
21127
- _context10.n = 61;
21266
+ case 47:
21267
+ result = _t15;
21268
+ case 48:
21269
+ _context10.n = 49;
21128
21270
  return put(setMessagesHasPrevAC(true));
21129
- case 61:
21130
- _context10.n = 62;
21271
+ case 49:
21272
+ _context10.n = 50;
21131
21273
  return put(setMessagesHasNextAC(channel.lastMessage && result.messages.length > 0 && channel.lastMessage.id !== result.messages[result.messages.length - 1].id));
21132
- case 62:
21274
+ case 50:
21133
21275
  setMessagesToMap(channel.id, result.messages, (_result$messages$3 = result.messages[0]) === null || _result$messages$3 === void 0 ? void 0 : _result$messages$3.id, (_result$messages3 = result.messages[result.messages.length - 1]) === null || _result$messages3 === void 0 ? void 0 : _result$messages3.id);
21134
21276
  setAllMessages([].concat(result.messages));
21135
- _context10.n = 63;
21277
+ _context10.n = 51;
21136
21278
  return put(setMessagesAC(JSON.parse(JSON.stringify(result.messages))));
21137
- case 63:
21138
- _context10.n = 77;
21279
+ case 51:
21280
+ _context10.n = 52;
21281
+ return put(scrollToNewMessageAC(false));
21282
+ case 52:
21283
+ _context10.n = 53;
21284
+ return put(setUnreadScrollToAC(true));
21285
+ case 53:
21286
+ _context10.n = 70;
21139
21287
  break;
21140
- case 64:
21288
+ case 54:
21141
21289
  if (!(cachedMessages && cachedMessages.length)) {
21142
- _context10.n = 66;
21290
+ _context10.n = 57;
21143
21291
  break;
21144
21292
  }
21145
- parsedMessages = getFromAllMessagesByMessageId('', '', true);
21146
- setMessagesToMap(channel.id, parsedMessages, (_parsedMessages$ = parsedMessages[0]) === null || _parsedMessages$ === void 0 ? void 0 : _parsedMessages$.id, (_parsedMessages = parsedMessages[parsedMessages.length - 1]) === null || _parsedMessages === void 0 ? void 0 : _parsedMessages.id);
21147
- _context10.n = 65;
21148
- return put(setMessagesAC(JSON.parse(JSON.stringify(parsedMessages))));
21149
- case 65:
21150
- _filteredPendingMessages = getFilteredPendingMessages(parsedMessages);
21151
- _context10.n = 66;
21293
+ _messages = getFromAllMessagesByMessageId('', '', true);
21294
+ _context10.n = 55;
21295
+ return put(setMessagesAC(JSON.parse(JSON.stringify(_messages))));
21296
+ case 55:
21297
+ _context10.n = 56;
21298
+ return delay(0);
21299
+ case 56:
21300
+ _filteredPendingMessages = getFilteredPendingMessages(_messages);
21301
+ _context10.n = 57;
21152
21302
  return put(addMessagesAC(_filteredPendingMessages, MESSAGE_LOAD_DIRECTION.NEXT));
21153
- case 66:
21303
+ case 57:
21154
21304
  log.info('load message from server');
21155
21305
  result = {
21156
21306
  messages: [],
21157
21307
  hasNext: false
21158
21308
  };
21159
21309
  if (!((channel === null || channel === void 0 ? void 0 : channel.lastDisplayedMessageId) > (channel === null || channel === void 0 ? void 0 : (_channel$lastMessage4 = channel.lastMessage) === null || _channel$lastMessage4 === void 0 ? void 0 : _channel$lastMessage4.id))) {
21160
- _context10.n = 70;
21310
+ _context10.n = 61;
21161
21311
  break;
21162
21312
  }
21163
21313
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
21164
- _context10.n = 68;
21314
+ _context10.n = 59;
21165
21315
  break;
21166
21316
  }
21167
- _context10.n = 67;
21317
+ _context10.n = 58;
21168
21318
  return call(messageQuery.loadPreviousMessageId, channel === null || channel === void 0 ? void 0 : channel.lastDisplayedMessageId);
21169
- case 67:
21170
- _t18 = _context10.v;
21171
- _context10.n = 69;
21319
+ case 58:
21320
+ _t16 = _context10.v;
21321
+ _context10.n = 60;
21172
21322
  break;
21173
- case 68:
21174
- _t18 = {
21323
+ case 59:
21324
+ _t16 = {
21175
21325
  messages: [],
21176
21326
  hasNext: false
21177
21327
  };
21178
- case 69:
21179
- result = _t18;
21180
- _context10.n = 74;
21328
+ case 60:
21329
+ result = _t16;
21330
+ _context10.n = 65;
21181
21331
  break;
21182
- case 70:
21332
+ case 61:
21183
21333
  if (!(connectionState === CONNECTION_STATUS.CONNECTED)) {
21184
- _context10.n = 72;
21334
+ _context10.n = 63;
21185
21335
  break;
21186
21336
  }
21187
- _context10.n = 71;
21337
+ _context10.n = 62;
21188
21338
  return call(messageQuery.loadPrevious);
21189
- case 71:
21190
- _t19 = _context10.v;
21191
- _context10.n = 73;
21339
+ case 62:
21340
+ _t17 = _context10.v;
21341
+ _context10.n = 64;
21192
21342
  break;
21193
- case 72:
21194
- _t19 = {
21343
+ case 63:
21344
+ _t17 = {
21195
21345
  messages: [],
21196
21346
  hasNext: false
21197
21347
  };
21198
- case 73:
21199
- result = _t19;
21200
- case 74:
21348
+ case 64:
21349
+ result = _t17;
21350
+ case 65:
21201
21351
  updatedMessages = [];
21202
21352
  result.messages.forEach(function (msg) {
21203
21353
  var updatedMessage = updateMessageOnMap(channel.id, {
@@ -21208,72 +21358,86 @@ function getMessagesQuery(action) {
21208
21358
  updatedMessages.push(updatedMessage || msg);
21209
21359
  });
21210
21360
  messageIdForLoad = (channel === null || channel === void 0 ? void 0 : channel.lastDisplayedMessageId) > (channel === null || channel === void 0 ? void 0 : (_channel$lastMessage5 = channel.lastMessage) === null || _channel$lastMessage5 === void 0 ? void 0 : _channel$lastMessage5.id) ? (channel === null || channel === void 0 ? void 0 : channel.lastDisplayedMessageId) || '0' : (channel === null || channel === void 0 ? void 0 : (_channel$lastMessage6 = channel.lastMessage) === null || _channel$lastMessage6 === void 0 ? void 0 : _channel$lastMessage6.id) || '0';
21211
- _context10.n = 75;
21361
+ if (!updatedMessages.length) {
21362
+ _context10.n = 69;
21363
+ break;
21364
+ }
21365
+ _context10.n = 66;
21212
21366
  return call(updateMessages, channel, updatedMessages, (_updatedMessages$ = updatedMessages[0]) === null || _updatedMessages$ === void 0 ? void 0 : _updatedMessages$.id, messageIdForLoad);
21213
- case 75:
21214
- _context10.n = 76;
21367
+ case 66:
21368
+ _context10.n = 67;
21215
21369
  return put(setMessagesHasPrevAC(true));
21216
- case 76:
21217
- _context10.n = 77;
21370
+ case 67:
21371
+ _context10.n = 68;
21218
21372
  return put(setMessagesHasNextAC(false));
21219
- case 77:
21373
+ case 68:
21374
+ _context10.n = 70;
21375
+ break;
21376
+ case 69:
21377
+ if (!(!(cachedMessages !== null && cachedMessages !== void 0 && cachedMessages.length) && !((_result$messages4 = result.messages) !== null && _result$messages4 !== void 0 && _result$messages4.length))) {
21378
+ _context10.n = 70;
21379
+ break;
21380
+ }
21381
+ _context10.n = 70;
21382
+ return put(setMessagesAC([]));
21383
+ case 70:
21220
21384
  filteredPendingMessages = getFilteredPendingMessages(result.messages);
21221
- _context10.n = 78;
21385
+ _context10.n = 71;
21222
21386
  return put(addMessagesAC(filteredPendingMessages, MESSAGE_LOAD_DIRECTION.NEXT));
21223
- case 78:
21387
+ case 71:
21224
21388
  waitToSendPendingMessages = store.getState().UserReducer.waitToSendPendingMessages;
21225
21389
  if (!(connectionState === CONNECTION_STATUS.CONNECTED && waitToSendPendingMessages)) {
21226
- _context10.n = 80;
21390
+ _context10.n = 73;
21227
21391
  break;
21228
21392
  }
21229
- _context10.n = 79;
21393
+ _context10.n = 72;
21230
21394
  return put(setWaitToSendPendingMessagesAC(false));
21231
- case 79:
21232
- _context10.n = 80;
21395
+ case 72:
21396
+ _context10.n = 73;
21233
21397
  return spawn(sendPendingMessages, connectionState);
21234
- case 80:
21235
- _context10.n = 81;
21398
+ case 73:
21399
+ _context10.n = 74;
21236
21400
  return call(SceytChatClient.getChannel, channel.id, true);
21237
- case 81:
21401
+ case 74:
21238
21402
  updatedChannel = _context10.v;
21239
- if (!updatedChannel) {
21240
- _context10.n = 83;
21403
+ if (!(updatedChannel && updatedChannel !== null && updatedChannel !== void 0 && updatedChannel.lastMessage)) {
21404
+ _context10.n = 76;
21241
21405
  break;
21242
21406
  }
21243
- _context10.n = 82;
21407
+ _context10.n = 75;
21244
21408
  return put(updateChannelLastMessageAC(updatedChannel.lastMessage, updatedChannel));
21245
- case 82:
21409
+ case 75:
21246
21410
  updateChannelLastMessageOnAllChannels(channel.id, updatedChannel.lastMessage);
21247
- case 83:
21248
- _context10.n = 85;
21411
+ case 76:
21412
+ _context10.n = 78;
21249
21413
  break;
21250
- case 84:
21414
+ case 77:
21251
21415
  if (!(channel !== null && channel !== void 0 && channel.isMockChannel)) {
21252
- _context10.n = 85;
21416
+ _context10.n = 78;
21253
21417
  break;
21254
21418
  }
21255
- _context10.n = 85;
21419
+ _context10.n = 78;
21256
21420
  return put(setMessagesAC([]));
21257
- case 85:
21258
- _context10.n = 87;
21421
+ case 78:
21422
+ _context10.n = 80;
21259
21423
  break;
21260
- case 86:
21261
- _context10.p = 86;
21262
- _t20 = _context10.v;
21263
- log.error('error in message query', _t20);
21264
- case 87:
21265
- _context10.p = 87;
21266
- _context10.n = 88;
21424
+ case 79:
21425
+ _context10.p = 79;
21426
+ _t18 = _context10.v;
21427
+ log.error('error in message query', _t18);
21428
+ case 80:
21429
+ _context10.p = 80;
21430
+ _context10.n = 81;
21267
21431
  return put(setMessagesLoadingStateAC(LOADING_STATE.LOADED));
21268
- case 88:
21269
- return _context10.f(87);
21270
- case 89:
21432
+ case 81:
21433
+ return _context10.f(80);
21434
+ case 82:
21271
21435
  return _context10.a(2);
21272
21436
  }
21273
- }, _marked7$1, null, [[0, 86, 87, 89]]);
21437
+ }, _marked7$1, null, [[2, 7], [0, 79, 80, 82]]);
21274
21438
  }
21275
21439
  function getMessageQuery(action) {
21276
- var payload, channelId, messageId, channel, connectionState, messages, fetchedMessage, _t21;
21440
+ var payload, channelId, messageId, channel, connectionState, messages, fetchedMessage, _t19;
21277
21441
  return _regenerator().w(function (_context11) {
21278
21442
  while (1) switch (_context11.p = _context11.n) {
21279
21443
  case 0:
@@ -21323,15 +21487,15 @@ function getMessageQuery(action) {
21323
21487
  break;
21324
21488
  case 7:
21325
21489
  _context11.p = 7;
21326
- _t21 = _context11.v;
21327
- log.error('error in message query', _t21);
21490
+ _t19 = _context11.v;
21491
+ log.error('error in message query', _t19);
21328
21492
  case 8:
21329
21493
  return _context11.a(2);
21330
21494
  }
21331
21495
  }, _marked8$1, null, [[0, 7]]);
21332
21496
  }
21333
21497
  function loadMoreMessages(action) {
21334
- var payload, limit, direction, channelId, messageId, hasNext, SceytChatClient, messageQueryBuilder, messageQuery, result, _result$messages$4, _result$messages4, _result$messages$5, _result$messages5, _t22;
21498
+ var payload, limit, direction, channelId, messageId, hasNext, SceytChatClient, messageQueryBuilder, messageQuery, result, _result$messages$4, _result$messages5, _result$messages$5, _result$messages6, _t20;
21335
21499
  return _regenerator().w(function (_context12) {
21336
21500
  while (1) switch (_context12.p = _context12.n) {
21337
21501
  case 0:
@@ -21375,7 +21539,7 @@ function loadMoreMessages(action) {
21375
21539
  result = _context12.v;
21376
21540
  if (result.messages.length) {
21377
21541
  addAllMessages(result.messages, MESSAGE_LOAD_DIRECTION.PREV);
21378
- setMessagesToMap(channelId, result.messages, (_result$messages$4 = result.messages[0]) === null || _result$messages$4 === void 0 ? void 0 : _result$messages$4.id, (_result$messages4 = result.messages[result.messages.length - 1]) === null || _result$messages4 === void 0 ? void 0 : _result$messages4.id);
21542
+ setMessagesToMap(channelId, result.messages, (_result$messages$4 = result.messages[0]) === null || _result$messages$4 === void 0 ? void 0 : _result$messages$4.id, (_result$messages5 = result.messages[result.messages.length - 1]) === null || _result$messages5 === void 0 ? void 0 : _result$messages5.id);
21379
21543
  }
21380
21544
  _context12.n = 5;
21381
21545
  return put(setMessagesHasPrevAC(result.hasNext));
@@ -21403,7 +21567,7 @@ function loadMoreMessages(action) {
21403
21567
  result = _context12.v;
21404
21568
  if (result.messages.length) {
21405
21569
  addAllMessages(result.messages, MESSAGE_LOAD_DIRECTION.NEXT);
21406
- setMessagesToMap(channelId, result.messages, (_result$messages$5 = result.messages[0]) === null || _result$messages$5 === void 0 ? void 0 : _result$messages$5.id, (_result$messages5 = result.messages[result.messages.length - 1]) === null || _result$messages5 === void 0 ? void 0 : _result$messages5.id);
21570
+ setMessagesToMap(channelId, result.messages, (_result$messages$5 = result.messages[0]) === null || _result$messages$5 === void 0 ? void 0 : _result$messages$5.id, (_result$messages6 = result.messages[result.messages.length - 1]) === null || _result$messages6 === void 0 ? void 0 : _result$messages6.id);
21407
21571
  }
21408
21572
  _context12.n = 9;
21409
21573
  return put(setMessagesHasNextAC(result.hasNext));
@@ -21444,15 +21608,15 @@ function loadMoreMessages(action) {
21444
21608
  break;
21445
21609
  case 18:
21446
21610
  _context12.p = 18;
21447
- _t22 = _context12.v;
21448
- log.error('error in load more messages', _t22);
21611
+ _t20 = _context12.v;
21612
+ log.error('error in load more messages', _t20);
21449
21613
  case 19:
21450
21614
  return _context12.a(2);
21451
21615
  }
21452
21616
  }, _marked9$1, null, [[0, 18]]);
21453
21617
  }
21454
21618
  function addReaction(action) {
21455
- var payload, channelId, messageId, key, score, reason, enforceUnique, user, channel, _yield$call, message, reaction, channelUpdateParam, _t23;
21619
+ var payload, channelId, messageId, key, score, reason, enforceUnique, user, channel, _yield$call, message, reaction, channelUpdateParam, _t21;
21456
21620
  return _regenerator().w(function (_context13) {
21457
21621
  while (1) switch (_context13.p = _context13.n) {
21458
21622
  case 0:
@@ -21505,15 +21669,15 @@ function addReaction(action) {
21505
21669
  break;
21506
21670
  case 8:
21507
21671
  _context13.p = 8;
21508
- _t23 = _context13.v;
21509
- log.error('ERROR in add reaction', _t23.message);
21672
+ _t21 = _context13.v;
21673
+ log.error('ERROR in add reaction', _t21.message);
21510
21674
  case 9:
21511
21675
  return _context13.a(2);
21512
21676
  }
21513
21677
  }, _marked0$1, null, [[0, 8]]);
21514
21678
  }
21515
21679
  function deleteReaction(action) {
21516
- var payload, channelId, messageId, key, isLastReaction, channel, _yield$call2, message, reaction, channelUpdateParam, _t24;
21680
+ var payload, channelId, messageId, key, isLastReaction, channel, _yield$call2, message, reaction, channelUpdateParam, _t22;
21517
21681
  return _regenerator().w(function (_context14) {
21518
21682
  while (1) switch (_context14.p = _context14.n) {
21519
21683
  case 0:
@@ -21561,15 +21725,15 @@ function deleteReaction(action) {
21561
21725
  break;
21562
21726
  case 7:
21563
21727
  _context14.p = 7;
21564
- _t24 = _context14.v;
21565
- log.error('ERROR in delete reaction', _t24.message);
21728
+ _t22 = _context14.v;
21729
+ log.error('ERROR in delete reaction', _t22.message);
21566
21730
  case 8:
21567
21731
  return _context14.a(2);
21568
21732
  }
21569
21733
  }, _marked1$1, null, [[0, 7]]);
21570
21734
  }
21571
21735
  function getReactions(action) {
21572
- var payload, messageId, key, limit, SceytChatClient, reactionQueryBuilder, reactionQuery, result, _t25;
21736
+ var payload, messageId, key, limit, SceytChatClient, reactionQueryBuilder, reactionQuery, result, _t23;
21573
21737
  return _regenerator().w(function (_context15) {
21574
21738
  while (1) switch (_context15.p = _context15.n) {
21575
21739
  case 0:
@@ -21604,15 +21768,15 @@ function getReactions(action) {
21604
21768
  break;
21605
21769
  case 6:
21606
21770
  _context15.p = 6;
21607
- _t25 = _context15.v;
21608
- log.error('ERROR in get reactions', _t25.message);
21771
+ _t23 = _context15.v;
21772
+ log.error('ERROR in get reactions', _t23.message);
21609
21773
  case 7:
21610
21774
  return _context15.a(2);
21611
21775
  }
21612
21776
  }, _marked10$1, null, [[0, 6]]);
21613
21777
  }
21614
21778
  function loadMoreReactions(action) {
21615
- var payload, limit, ReactionQuery, result, _t26;
21779
+ var payload, limit, ReactionQuery, result, _t24;
21616
21780
  return _regenerator().w(function (_context16) {
21617
21781
  while (1) switch (_context16.p = _context16.n) {
21618
21782
  case 0:
@@ -21640,15 +21804,15 @@ function loadMoreReactions(action) {
21640
21804
  break;
21641
21805
  case 5:
21642
21806
  _context16.p = 5;
21643
- _t26 = _context16.v;
21644
- log.error('ERROR in load more reactions', _t26.message);
21807
+ _t24 = _context16.v;
21808
+ log.error('ERROR in load more reactions', _t24.message);
21645
21809
  case 6:
21646
21810
  return _context16.a(2);
21647
21811
  }
21648
21812
  }, _marked11$1, null, [[0, 5]]);
21649
21813
  }
21650
21814
  function getMessageAttachments(action) {
21651
- var _action$payload2, channelId, attachmentType, limit, direction, attachmentId, forPopup, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, _t27;
21815
+ var _action$payload2, channelId, attachmentType, limit, direction, attachmentId, forPopup, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, _t25;
21652
21816
  return _regenerator().w(function (_context17) {
21653
21817
  while (1) switch (_context17.p = _context17.n) {
21654
21818
  case 0:
@@ -21726,15 +21890,15 @@ function getMessageAttachments(action) {
21726
21890
  break;
21727
21891
  case 13:
21728
21892
  _context17.p = 13;
21729
- _t27 = _context17.v;
21730
- log.error('error in message attachment query', _t27);
21893
+ _t25 = _context17.v;
21894
+ log.error('error in message attachment query', _t25);
21731
21895
  case 14:
21732
21896
  return _context17.a(2);
21733
21897
  }
21734
21898
  }, _marked12$1, null, [[0, 13]]);
21735
21899
  }
21736
21900
  function loadMoreMessageAttachments(action) {
21737
- var _action$payload3, limit, direction, forPopup, AttachmentQuery, _yield$call3, attachments, hasNext, _t28;
21901
+ var _action$payload3, limit, direction, forPopup, AttachmentQuery, _yield$call3, attachments, hasNext, _t26;
21738
21902
  return _regenerator().w(function (_context18) {
21739
21903
  while (1) switch (_context18.p = _context18.n) {
21740
21904
  case 0:
@@ -21778,15 +21942,15 @@ function loadMoreMessageAttachments(action) {
21778
21942
  break;
21779
21943
  case 8:
21780
21944
  _context18.p = 8;
21781
- _t28 = _context18.v;
21782
- log.error('error in message attachment query', _t28);
21945
+ _t26 = _context18.v;
21946
+ log.error('error in message attachment query', _t26);
21783
21947
  case 9:
21784
21948
  return _context18.a(2);
21785
21949
  }
21786
21950
  }, _marked13$1, null, [[0, 8]]);
21787
21951
  }
21788
21952
  function pauseAttachmentUploading(action) {
21789
- var attachmentId, isPaused, _t29;
21953
+ var attachmentId, isPaused, _t27;
21790
21954
  return _regenerator().w(function (_context19) {
21791
21955
  while (1) switch (_context19.p = _context19.n) {
21792
21956
  case 0:
@@ -21808,15 +21972,15 @@ function pauseAttachmentUploading(action) {
21808
21972
  break;
21809
21973
  case 2:
21810
21974
  _context19.p = 2;
21811
- _t29 = _context19.v;
21812
- log.error('error in pause attachment uploading', _t29);
21975
+ _t27 = _context19.v;
21976
+ log.error('error in pause attachment uploading', _t27);
21813
21977
  case 3:
21814
21978
  return _context19.a(2);
21815
21979
  }
21816
21980
  }, _marked14$1, null, [[0, 2]]);
21817
21981
  }
21818
21982
  function resumeAttachmentUploading(action) {
21819
- var attachmentId, isResumed, _t30;
21983
+ var attachmentId, isResumed, _t28;
21820
21984
  return _regenerator().w(function (_context20) {
21821
21985
  while (1) switch (_context20.p = _context20.n) {
21822
21986
  case 0:
@@ -21839,15 +22003,15 @@ function resumeAttachmentUploading(action) {
21839
22003
  break;
21840
22004
  case 2:
21841
22005
  _context20.p = 2;
21842
- _t30 = _context20.v;
21843
- log.error('error in resume attachment uploading', _t30);
22006
+ _t28 = _context20.v;
22007
+ log.error('error in resume attachment uploading', _t28);
21844
22008
  case 3:
21845
22009
  return _context20.a(2);
21846
22010
  }
21847
22011
  }, _marked15$1, null, [[0, 2]]);
21848
22012
  }
21849
22013
  function getMessageMarkers(action) {
21850
- var _action$payload4, messageId, channelId, deliveryStatus, sceytChatClient, messageMarkerListQueryBuilder, messageMarkerListQuery, messageMarkers, _t31;
22014
+ var _action$payload4, messageId, channelId, deliveryStatus, sceytChatClient, messageMarkerListQueryBuilder, messageMarkerListQuery, messageMarkers, _t29;
21851
22015
  return _regenerator().w(function (_context21) {
21852
22016
  while (1) switch (_context21.p = _context21.n) {
21853
22017
  case 0:
@@ -21877,8 +22041,8 @@ function getMessageMarkers(action) {
21877
22041
  break;
21878
22042
  case 5:
21879
22043
  _context21.p = 5;
21880
- _t31 = _context21.v;
21881
- log.error('error in get message markers', _t31);
22044
+ _t29 = _context21.v;
22045
+ log.error('error in get message markers', _t29);
21882
22046
  case 6:
21883
22047
  _context21.p = 6;
21884
22048
  _context21.n = 7;
@@ -21891,8 +22055,7 @@ function getMessageMarkers(action) {
21891
22055
  }, _marked16$1, null, [[0, 5, 6, 8]]);
21892
22056
  }
21893
22057
  function executeAddPollVote(channelId, pollId, optionId, message) {
21894
- var _user$presence, _message$pollDetails, _message$pollDetails2, _message$pollDetails3, _message$pollDetails4;
21895
- var channel, user, vote, objs, _message$pollDetails5, _message$pollDetails6, _message$pollDetails7;
22058
+ var channel;
21896
22059
  return _regenerator().w(function (_context22) {
21897
22060
  while (1) switch (_context22.n) {
21898
22061
  case 0:
@@ -21906,41 +22069,6 @@ function executeAddPollVote(channelId, pollId, optionId, message) {
21906
22069
  }
21907
22070
  return _context22.a(2);
21908
22071
  case 2:
21909
- user = getClient().user;
21910
- vote = {
21911
- optionId: optionId,
21912
- createdAt: new Date().getTime(),
21913
- user: {
21914
- id: user.id,
21915
- presence: {
21916
- status: ((_user$presence = user.presence) === null || _user$presence === void 0 ? void 0 : _user$presence.status) || 'online'
21917
- },
21918
- profile: {
21919
- avatar: user.avatarUrl || '',
21920
- firstName: user.firstName,
21921
- lastName: user.lastName,
21922
- metadata: user.metadata || '',
21923
- metadataMap: user.metadataMap || {},
21924
- updatedAt: new Date().getTime(),
21925
- username: user.username || '',
21926
- createdAt: new Date().getTime()
21927
- },
21928
- createdAt: new Date().getTime()
21929
- }
21930
- };
21931
- objs = [];
21932
- if (!((_message$pollDetails = message.pollDetails) !== null && _message$pollDetails !== void 0 && _message$pollDetails.allowMultipleVotes) && ((_message$pollDetails2 = message.pollDetails) === null || _message$pollDetails2 === void 0 ? void 0 : (_message$pollDetails3 = _message$pollDetails2.voteDetails) === null || _message$pollDetails3 === void 0 ? void 0 : (_message$pollDetails4 = _message$pollDetails3.ownVotes) === null || _message$pollDetails4 === void 0 ? void 0 : _message$pollDetails4.length) > 0) {
21933
- objs.push({
21934
- type: 'deleteOwn',
21935
- vote: (_message$pollDetails5 = message.pollDetails) === null || _message$pollDetails5 === void 0 ? void 0 : (_message$pollDetails6 = _message$pollDetails5.voteDetails) === null || _message$pollDetails6 === void 0 ? void 0 : (_message$pollDetails7 = _message$pollDetails6.ownVotes) === null || _message$pollDetails7 === void 0 ? void 0 : _message$pollDetails7[0],
21936
- incrementVotesPerOptionCount: -1
21937
- });
21938
- }
21939
- objs.push({
21940
- type: 'addOwn',
21941
- vote: vote,
21942
- incrementVotesPerOptionCount: 1
21943
- });
21944
22072
  if (!(channel && message.id)) {
21945
22073
  _context22.n = 4;
21946
22074
  break;
@@ -21956,7 +22084,8 @@ function executeAddPollVote(channelId, pollId, optionId, message) {
21956
22084
  }, _marked17$1);
21957
22085
  }
21958
22086
  function updateMessageOptimisticallyForAddPollVote(channelId, message, vote) {
21959
- var channel, obj;
22087
+ var _message$pollDetails, _message$pollDetails2, _message$pollDetails3, _message$pollDetails4;
22088
+ var channel, objs, _message$pollDetails5, _message$pollDetails6, _message$pollDetails7, _i2, _objs, obj;
21960
22089
  return _regenerator().w(function (_context23) {
21961
22090
  while (1) switch (_context23.n) {
21962
22091
  case 0:
@@ -21976,25 +22105,42 @@ function updateMessageOptimisticallyForAddPollVote(channelId, message, vote) {
21976
22105
  }
21977
22106
  return _context23.a(2);
21978
22107
  case 3:
21979
- obj = {
22108
+ objs = [];
22109
+ if (!((_message$pollDetails = message.pollDetails) !== null && _message$pollDetails !== void 0 && _message$pollDetails.allowMultipleVotes) && ((_message$pollDetails2 = message.pollDetails) === null || _message$pollDetails2 === void 0 ? void 0 : (_message$pollDetails3 = _message$pollDetails2.voteDetails) === null || _message$pollDetails3 === void 0 ? void 0 : (_message$pollDetails4 = _message$pollDetails3.ownVotes) === null || _message$pollDetails4 === void 0 ? void 0 : _message$pollDetails4.length) > 0) {
22110
+ objs.push({
22111
+ type: 'deleteOwn',
22112
+ vote: (_message$pollDetails5 = message.pollDetails) === null || _message$pollDetails5 === void 0 ? void 0 : (_message$pollDetails6 = _message$pollDetails5.voteDetails) === null || _message$pollDetails6 === void 0 ? void 0 : (_message$pollDetails7 = _message$pollDetails6.ownVotes) === null || _message$pollDetails7 === void 0 ? void 0 : _message$pollDetails7[0]
22113
+ });
22114
+ }
22115
+ objs.push({
21980
22116
  type: 'addOwn',
21981
- vote: vote,
21982
- incrementVotesPerOptionCount: 1
21983
- };
22117
+ vote: vote
22118
+ });
22119
+ _i2 = 0, _objs = objs;
22120
+ case 4:
22121
+ if (!(_i2 < _objs.length)) {
22122
+ _context23.n = 6;
22123
+ break;
22124
+ }
22125
+ obj = _objs[_i2];
21984
22126
  updateMessageOnMap(channel.id, {
21985
22127
  messageId: message.id,
21986
22128
  params: {}
21987
22129
  }, obj);
21988
22130
  updateMessageOnAllMessages(message.id, {}, obj);
21989
- _context23.n = 4;
22131
+ _context23.n = 5;
21990
22132
  return put(updateMessageAC(message.id, {}, undefined, obj));
21991
- case 4:
22133
+ case 5:
22134
+ _i2++;
22135
+ _context23.n = 4;
22136
+ break;
22137
+ case 6:
21992
22138
  return _context23.a(2);
21993
22139
  }
21994
22140
  }, _marked18$1);
21995
22141
  }
21996
22142
  function addPollVote(action) {
21997
- var payload, channelId, pollId, optionId, message, isResend, sceytChatClient, _user$presence2, user, vote, pendingAction, conflictCheck, channel, _Object$values, _store$getState$Messa, _currentMessage$pollD, _currentMessage$pollD2, _currentMessage$pollD3, currentMessage, hasNext, obj, _t32;
22143
+ var payload, channelId, pollId, optionId, message, isResend, sceytChatClient, _user$presence, user, vote, pendingAction, conflictCheck, channel, _Object$values, _store$getState$Messa, _currentMessage$pollD, _currentMessage$pollD2, _currentMessage$pollD3, currentMessage, hasNext, obj, _t30;
21998
22144
  return _regenerator().w(function (_context24) {
21999
22145
  while (1) switch (_context24.p = _context24.n) {
22000
22146
  case 0:
@@ -22013,7 +22159,7 @@ function addPollVote(action) {
22013
22159
  user: {
22014
22160
  id: user.id,
22015
22161
  presence: {
22016
- status: ((_user$presence2 = user.presence) === null || _user$presence2 === void 0 ? void 0 : _user$presence2.status) || 'online'
22162
+ status: ((_user$presence = user.presence) === null || _user$presence === void 0 ? void 0 : _user$presence.status) || 'online'
22017
22163
  },
22018
22164
  profile: {
22019
22165
  avatar: user.avatarUrl || '',
@@ -22057,8 +22203,7 @@ function addPollVote(action) {
22057
22203
  case 2:
22058
22204
  obj = {
22059
22205
  type: 'addOwn',
22060
- vote: vote,
22061
- incrementVotesPerOptionCount: 1
22206
+ vote: vote
22062
22207
  };
22063
22208
  updateMessageOnMap(channel.id, {
22064
22209
  messageId: message.id,
@@ -22075,19 +22220,21 @@ function addPollVote(action) {
22075
22220
  _context24.n = 5;
22076
22221
  break;
22077
22222
  }
22078
- return _context24.d(_regeneratorValues(updateMessageOptimisticallyForAddPollVote(channelId, message, vote)), 5);
22223
+ _context24.n = 5;
22224
+ return call(updateMessageOptimisticallyForAddPollVote, channelId, message, vote);
22079
22225
  case 5:
22080
22226
  if (!conflictCheck.shouldSkip && !isResend) {
22081
22227
  setPendingPollAction(pendingAction);
22082
22228
  }
22083
- return _context24.d(_regeneratorValues(executeAddPollVote(channelId, pollId, optionId, message)), 6);
22229
+ _context24.n = 6;
22230
+ return call(executeAddPollVote, channelId, pollId, optionId, message);
22084
22231
  case 6:
22085
22232
  _context24.n = 8;
22086
22233
  break;
22087
22234
  case 7:
22088
22235
  _context24.p = 7;
22089
- _t32 = _context24.v;
22090
- log.error('error in add poll vote', _t32);
22236
+ _t30 = _context24.v;
22237
+ log.error('error in add poll vote', _t30);
22091
22238
  case 8:
22092
22239
  return _context24.a(2);
22093
22240
  }
@@ -22155,8 +22302,7 @@ function updateMessageOptimisticallyForDeletePollVote(channelId, message, vote)
22155
22302
  case 3:
22156
22303
  obj = {
22157
22304
  type: 'deleteOwn',
22158
- vote: vote,
22159
- incrementVotesPerOptionCount: -1
22305
+ vote: vote
22160
22306
  };
22161
22307
  updateMessageOnMap(channel.id, {
22162
22308
  messageId: message.id,
@@ -22171,7 +22317,7 @@ function updateMessageOptimisticallyForDeletePollVote(channelId, message, vote)
22171
22317
  }, _marked21$1);
22172
22318
  }
22173
22319
  function deletePollVote(action) {
22174
- var payload, channelId, pollId, optionId, message, isResend, sceytChatClient, _message$pollDetails1, _message$pollDetails10, _message$pollDetails11, vote, pendingAction, conflictCheck, channel, _Object$values2, _currentMessage$pollD4, _currentMessage$pollD5, _currentMessage$pollD6, currentMessage, obj, _t33;
22320
+ var payload, channelId, pollId, optionId, message, isResend, sceytChatClient, _message$pollDetails1, _message$pollDetails10, _message$pollDetails11, vote, pendingAction, conflictCheck, channel, _Object$values2, _currentMessage$pollD4, _currentMessage$pollD5, _currentMessage$pollD6, currentMessage, obj, _t31;
22175
22321
  return _regenerator().w(function (_context27) {
22176
22322
  while (1) switch (_context27.p = _context27.n) {
22177
22323
  case 0:
@@ -22220,8 +22366,7 @@ function deletePollVote(action) {
22220
22366
  case 3:
22221
22367
  obj = {
22222
22368
  type: 'deleteOwn',
22223
- vote: vote,
22224
- incrementVotesPerOptionCount: -1
22369
+ vote: vote
22225
22370
  };
22226
22371
  updateMessageOnMap(channel.id, {
22227
22372
  messageId: message.id,
@@ -22238,19 +22383,21 @@ function deletePollVote(action) {
22238
22383
  _context27.n = 6;
22239
22384
  break;
22240
22385
  }
22241
- return _context27.d(_regeneratorValues(updateMessageOptimisticallyForDeletePollVote(channelId, message, vote)), 6);
22386
+ _context27.n = 6;
22387
+ return call(updateMessageOptimisticallyForDeletePollVote, channelId, message, vote);
22242
22388
  case 6:
22243
22389
  if (!conflictCheck.shouldSkip && !isResend) {
22244
22390
  setPendingPollAction(pendingAction);
22245
22391
  }
22246
- return _context27.d(_regeneratorValues(executeDeletePollVote(channelId, pollId, optionId, message)), 7);
22392
+ _context27.n = 7;
22393
+ return call(executeDeletePollVote, channelId, pollId, optionId, message);
22247
22394
  case 7:
22248
22395
  _context27.n = 9;
22249
22396
  break;
22250
22397
  case 8:
22251
22398
  _context27.p = 8;
22252
- _t33 = _context27.v;
22253
- log.error('error in delete poll vote', _t33);
22399
+ _t31 = _context27.v;
22400
+ log.error('error in delete poll vote', _t31);
22254
22401
  case 9:
22255
22402
  return _context27.a(2);
22256
22403
  }
@@ -22266,8 +22413,7 @@ function executeClosePoll(channelId, pollId, message) {
22266
22413
  case 1:
22267
22414
  channel = _context28.v;
22268
22415
  obj = {
22269
- type: 'close',
22270
- incrementVotesPerOptionCount: 0
22416
+ type: 'close'
22271
22417
  };
22272
22418
  updateMessageOnMap(channel.id, {
22273
22419
  messageId: message.id,
@@ -22328,7 +22474,7 @@ function updateMessageOptimisticallyForClosePoll(channelId, message) {
22328
22474
  }, _marked24$1);
22329
22475
  }
22330
22476
  function closePoll(action) {
22331
- var payload, channelId, pollId, message, sceytChatClient, connectionState, _t34;
22477
+ var payload, channelId, pollId, message, sceytChatClient, connectionState, _t32;
22332
22478
  return _regenerator().w(function (_context30) {
22333
22479
  while (1) switch (_context30.p = _context30.n) {
22334
22480
  case 0:
@@ -22345,7 +22491,8 @@ function closePoll(action) {
22345
22491
  _context30.n = 2;
22346
22492
  break;
22347
22493
  }
22348
- return _context30.d(_regeneratorValues(updateMessageOptimisticallyForClosePoll(channelId, message)), 1);
22494
+ _context30.n = 1;
22495
+ return call(updateMessageOptimisticallyForClosePoll, channelId, message);
22349
22496
  case 1:
22350
22497
  setPendingPollAction({
22351
22498
  type: 'CLOSE_POLL',
@@ -22355,14 +22502,15 @@ function closePoll(action) {
22355
22502
  });
22356
22503
  return _context30.a(2);
22357
22504
  case 2:
22358
- return _context30.d(_regeneratorValues(executeClosePoll(channelId, pollId, message)), 3);
22505
+ _context30.n = 3;
22506
+ return call(executeClosePoll, channelId, pollId, message);
22359
22507
  case 3:
22360
22508
  _context30.n = 5;
22361
22509
  break;
22362
22510
  case 4:
22363
22511
  _context30.p = 4;
22364
- _t34 = _context30.v;
22365
- log.error('error in close poll', _t34);
22512
+ _t32 = _context30.v;
22513
+ log.error('error in close poll', _t32);
22366
22514
  case 5:
22367
22515
  return _context30.a(2);
22368
22516
  }
@@ -22451,7 +22599,7 @@ function updateMessageOptimisticallyForRetractPollVote(channelId, message, objs)
22451
22599
  }, _marked27$1);
22452
22600
  }
22453
22601
  function retractPollVote(action) {
22454
- var payload, channelId, pollId, message, isResend, sceytChatClient, connectionState, objs, _iterator4, _step4, _message$pollDetails12, _message$pollDetails13, vote, _t35;
22602
+ var payload, channelId, pollId, message, isResend, sceytChatClient, connectionState, objs, _iterator4, _step4, _message$pollDetails12, _message$pollDetails13, vote, _t33;
22455
22603
  return _regenerator().w(function (_context33) {
22456
22604
  while (1) switch (_context33.p = _context33.n) {
22457
22605
  case 0:
@@ -22469,15 +22617,15 @@ function retractPollVote(action) {
22469
22617
  vote = _step4.value;
22470
22618
  objs.push({
22471
22619
  type: 'deleteOwn',
22472
- vote: vote,
22473
- incrementVotesPerOptionCount: -1
22620
+ vote: vote
22474
22621
  });
22475
22622
  }
22476
22623
  if (!(connectionState !== CONNECTION_STATUS.CONNECTED)) {
22477
22624
  _context33.n = 2;
22478
22625
  break;
22479
22626
  }
22480
- return _context33.d(_regeneratorValues(updateMessageOptimisticallyForRetractPollVote(channelId, message, objs)), 1);
22627
+ _context33.n = 1;
22628
+ return call(updateMessageOptimisticallyForRetractPollVote, channelId, message, objs);
22481
22629
  case 1:
22482
22630
  setPendingPollAction({
22483
22631
  type: 'RETRACT_POLL_VOTE',
@@ -22487,21 +22635,22 @@ function retractPollVote(action) {
22487
22635
  });
22488
22636
  return _context33.a(2);
22489
22637
  case 2:
22490
- return _context33.d(_regeneratorValues(executeRetractPollVote(channelId, pollId, message, objs, isResend)), 3);
22638
+ _context33.n = 3;
22639
+ return call(executeRetractPollVote, channelId, pollId, message, objs, isResend);
22491
22640
  case 3:
22492
22641
  _context33.n = 5;
22493
22642
  break;
22494
22643
  case 4:
22495
22644
  _context33.p = 4;
22496
- _t35 = _context33.v;
22497
- log.error('error in retract poll vote', _t35);
22645
+ _t33 = _context33.v;
22646
+ log.error('error in retract poll vote', _t33);
22498
22647
  case 5:
22499
22648
  return _context33.a(2);
22500
22649
  }
22501
22650
  }, _marked28$1, null, [[0, 4]]);
22502
22651
  }
22503
22652
  function resendPendingPollActions(action) {
22504
- var payload, connectionState, sceytChatClient, pendingPollActionsMap, pendingPollActionsMapCopy, _t36;
22653
+ var payload, connectionState, sceytChatClient, pendingPollActionsMap, pendingPollActionsMapCopy, _t34;
22505
22654
  return _regenerator().w(function (_context34) {
22506
22655
  while (1) switch (_context34.p = _context34.n) {
22507
22656
  case 0:
@@ -22550,15 +22699,15 @@ function resendPendingPollActions(action) {
22550
22699
  break;
22551
22700
  case 2:
22552
22701
  _context34.p = 2;
22553
- _t36 = _context34.v;
22554
- log.error('error in resend pending poll actions', _t36);
22702
+ _t34 = _context34.v;
22703
+ log.error('error in resend pending poll actions', _t34);
22555
22704
  case 3:
22556
22705
  return _context34.a(2);
22557
22706
  }
22558
22707
  }, _marked29$1, null, [[0, 2]]);
22559
22708
  }
22560
22709
  function getPollVotes(action) {
22561
- var payload, messageId, pollId, optionId, limit, key, SceytChatClient, queryBuilder, pollVotesQuery, result, formattedVotes, _t37;
22710
+ var payload, messageId, pollId, optionId, limit, key, SceytChatClient, queryBuilder, pollVotesQuery, result, formattedVotes, _t35;
22562
22711
  return _regenerator().w(function (_context35) {
22563
22712
  while (1) switch (_context35.p = _context35.n) {
22564
22713
  case 0:
@@ -22624,8 +22773,8 @@ function getPollVotes(action) {
22624
22773
  break;
22625
22774
  case 7:
22626
22775
  _context35.p = 7;
22627
- _t37 = _context35.v;
22628
- log.error('ERROR in get poll votes', _t37);
22776
+ _t35 = _context35.v;
22777
+ log.error('ERROR in get poll votes', _t35);
22629
22778
  _context35.n = 8;
22630
22779
  return put(setPollVotesLoadingStateAC(action.payload.pollId, action.payload.optionId, LOADING_STATE.LOADED));
22631
22780
  case 8:
@@ -22634,7 +22783,7 @@ function getPollVotes(action) {
22634
22783
  }, _marked30$1, null, [[0, 7]]);
22635
22784
  }
22636
22785
  function loadMorePollVotes(action) {
22637
- var payload, pollId, optionId, limit, key, pollVotesQuery, result, formattedVotes, _t38;
22786
+ var payload, pollId, optionId, limit, key, pollVotesQuery, result, formattedVotes, _t36;
22638
22787
  return _regenerator().w(function (_context36) {
22639
22788
  while (1) switch (_context36.p = _context36.n) {
22640
22789
  case 0:
@@ -22692,8 +22841,8 @@ function loadMorePollVotes(action) {
22692
22841
  break;
22693
22842
  case 6:
22694
22843
  _context36.p = 6;
22695
- _t38 = _context36.v;
22696
- log.error('ERROR in load more poll votes', _t38);
22844
+ _t36 = _context36.v;
22845
+ log.error('ERROR in load more poll votes', _t36);
22697
22846
  _context36.n = 7;
22698
22847
  return put(setPollVotesLoadingStateAC(action.payload.pollId, action.payload.optionId, LOADING_STATE.LOADED));
22699
22848
  case 7:
@@ -22909,7 +23058,7 @@ function loadMoreMembers(action) {
22909
23058
  }, _marked2$3, null, [[0, 7, 8, 10]]);
22910
23059
  }
22911
23060
  function addMembers(action) {
22912
- var payload, members, channelId, channel, membersToAdd, addedMembers, membersIds, messageToSend, updateChannelData, _action$payload, _t3;
23061
+ var payload, members, channelId, channel, membersToAdd, addedMembers, whoDoesNotAdded, membersIds, messageToSend, updateChannelData, _t3;
22913
23062
  return _regenerator().w(function (_context3) {
22914
23063
  while (1) switch (_context3.p = _context3.n) {
22915
23064
  case 0:
@@ -22921,7 +23070,7 @@ function addMembers(action) {
22921
23070
  case 1:
22922
23071
  channel = _context3.v;
22923
23072
  if (!channel) {
22924
- _context3.n = 6;
23073
+ _context3.n = 7;
22925
23074
  break;
22926
23075
  }
22927
23076
  membersToAdd = members.map(function (mem) {
@@ -22932,14 +23081,30 @@ function addMembers(action) {
22932
23081
  return call(channel.addMembers, membersToAdd);
22933
23082
  case 2:
22934
23083
  addedMembers = _context3.v;
22935
- if (!(channel.type === DEFAULT_CHANNEL_TYPE.GROUP || channel.type === DEFAULT_CHANNEL_TYPE.PRIVATE)) {
23084
+ whoDoesNotAdded = members.filter(function (mem) {
23085
+ return !addedMembers.some(function (addedMem) {
23086
+ return addedMem.id === mem.id;
23087
+ });
23088
+ });
23089
+ if (!whoDoesNotAdded.length) {
22936
23090
  _context3.n = 3;
22937
23091
  break;
22938
23092
  }
23093
+ _context3.n = 3;
23094
+ return put(setActionIsRestrictedAC(true, true, whoDoesNotAdded));
23095
+ case 3:
23096
+ if (!(channel.type === DEFAULT_CHANNEL_TYPE.GROUP || channel.type === DEFAULT_CHANNEL_TYPE.PRIVATE)) {
23097
+ _context3.n = 4;
23098
+ break;
23099
+ }
22939
23100
  membersIds = [];
22940
23101
  addedMembers.forEach(function (mem) {
22941
23102
  membersIds.push(mem.id);
22942
23103
  });
23104
+ if (!membersIds.length) {
23105
+ _context3.n = 4;
23106
+ break;
23107
+ }
22943
23108
  messageToSend = {
22944
23109
  metadata: {
22945
23110
  m: membersIds
@@ -22949,41 +23114,34 @@ function addMembers(action) {
22949
23114
  attachments: [],
22950
23115
  type: 'system'
22951
23116
  };
22952
- _context3.n = 3;
22953
- return put(sendTextMessageAC(messageToSend, channelId, CONNECTION_STATUS.CONNECTED));
22954
- case 3:
22955
23117
  _context3.n = 4;
22956
- return put(addMembersToListAC(addedMembers));
23118
+ return put(sendTextMessageAC(messageToSend, channelId, CONNECTION_STATUS.CONNECTED));
22957
23119
  case 4:
23120
+ _context3.n = 5;
23121
+ return put(addMembersToListAC(addedMembers));
23122
+ case 5:
22958
23123
  updateChannelOnAllChannels(channel.id, {
22959
23124
  memberCount: channel.memberCount + addedMembers.length
22960
23125
  });
22961
- _context3.n = 5;
23126
+ _context3.n = 6;
22962
23127
  return call(updateActiveChannelMembersAdd, addedMembers) || {};
22963
- case 5:
23128
+ case 6:
22964
23129
  updateChannelData = _context3.v;
22965
- _context3.n = 6;
23130
+ _context3.n = 7;
22966
23131
  return put(updateChannelDataAC(channel.id, _extends({
22967
23132
  memberCount: channel.memberCount + addedMembers.length
22968
23133
  }, updateChannelData)));
22969
- case 6:
23134
+ case 7:
22970
23135
  _context3.n = 9;
22971
23136
  break;
22972
- case 7:
22973
- _context3.p = 7;
22974
- _t3 = _context3.v;
22975
- if (!(_t3.code === 1041)) {
22976
- _context3.n = 8;
22977
- break;
22978
- }
22979
- _context3.n = 8;
22980
- return put(setActionIsRestrictedAC(true, true, (action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.members) || []));
22981
23137
  case 8:
23138
+ _context3.p = 8;
23139
+ _t3 = _context3.v;
22982
23140
  log.error('error on add members... ', _t3);
22983
23141
  case 9:
22984
23142
  return _context3.a(2);
22985
23143
  }
22986
- }, _marked3$2, null, [[0, 7]]);
23144
+ }, _marked3$2, null, [[0, 8]]);
22987
23145
  }
22988
23146
  function kickMemberFromChannel(action) {
22989
23147
  var payload, memberId, channelId, channel, removedMembers, membersIds, messageToSend, updateChannelData;
@@ -23138,11 +23296,11 @@ function reportMember(action) {
23138
23296
  }, _marked7$2, null, [[1, 3]]);
23139
23297
  }
23140
23298
  function getRoles(action) {
23141
- var _action$payload2, timeout, attempts, SceytChatClient, roles, _t8;
23299
+ var _action$payload, timeout, attempts, SceytChatClient, roles, _t8;
23142
23300
  return _regenerator().w(function (_context8) {
23143
23301
  while (1) switch (_context8.p = _context8.n) {
23144
23302
  case 0:
23145
- _action$payload2 = action.payload, timeout = _action$payload2.timeout, attempts = _action$payload2.attempts;
23303
+ _action$payload = action.payload, timeout = _action$payload.timeout, attempts = _action$payload.attempts;
23146
23304
  _context8.p = 1;
23147
23305
  SceytChatClient = getClient();
23148
23306
  if (!(store.getState().UserReducer.connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
@@ -24291,7 +24449,9 @@ var MembersText = styled.div(_templateObject7$1 || (_templateObject7$1 = _tagged
24291
24449
  var Center = styled.div(_templateObject8$1 || (_templateObject8$1 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n margin-top: 24px;\n"])));
24292
24450
 
24293
24451
  var ActionRestrictedPopup = function ActionRestrictedPopup(_ref) {
24294
- var fromChannel = _ref.fromChannel;
24452
+ var fromChannel = _ref.fromChannel,
24453
+ members = _ref.members,
24454
+ contactsMap = _ref.contactsMap;
24295
24455
  var dispatch = useDispatch();
24296
24456
  var _useColor = useColors(),
24297
24457
  background = _useColor[THEME_COLORS.BACKGROUND],
@@ -24308,6 +24468,29 @@ var ActionRestrictedPopup = function ActionRestrictedPopup(_ref) {
24308
24468
  dispatch(setOpenInviteModalAC(true));
24309
24469
  handleClose();
24310
24470
  };
24471
+ var getExcludedContactsMessage = function getExcludedContactsMessage(fromChannel) {
24472
+ var excludedContacts = members || [];
24473
+ var count = excludedContacts.length;
24474
+ var fromContact = getShowOnlyContactUsers() || false;
24475
+ var makeName = function makeName(member) {
24476
+ return makeUsername(contactsMap[member.id], member, fromContact, false);
24477
+ };
24478
+ var prefix = fromChannel ? '' : 'The group was created, but ';
24479
+ var suffix = fromChannel ? " couldn't be added to the group. You can share an invite link with them." : " couldn't be added. You can share an invite link with them.";
24480
+ if (count === 1) {
24481
+ var name = makeName(excludedContacts[0]);
24482
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, prefix, /*#__PURE__*/React__default.createElement(BoltText, null, name), suffix);
24483
+ } else if (count === 2) {
24484
+ var name1 = makeName(excludedContacts[0]);
24485
+ var name2 = makeName(excludedContacts[1]);
24486
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, prefix, /*#__PURE__*/React__default.createElement(BoltText, null, name1), " and ", /*#__PURE__*/React__default.createElement(BoltText, null, name2), suffix);
24487
+ } else if (count > 2) {
24488
+ var firstName = makeName(excludedContacts[0]);
24489
+ var othersCount = count - 1;
24490
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, prefix, /*#__PURE__*/React__default.createElement(BoltText, null, firstName, " and ", othersCount, " others"), suffix);
24491
+ }
24492
+ return null;
24493
+ };
24311
24494
  return /*#__PURE__*/React__default.createElement(PopupContainer, null, /*#__PURE__*/React__default.createElement(Popup, {
24312
24495
  backgroundColor: background,
24313
24496
  maxWidth: '520px',
@@ -24322,23 +24505,23 @@ var ActionRestrictedPopup = function ActionRestrictedPopup(_ref) {
24322
24505
  }), /*#__PURE__*/React__default.createElement(PopupName, {
24323
24506
  color: textPrimary,
24324
24507
  marginBottom: '20px'
24325
- }, fromChannel ? 'Privacy note' : "Can't create group"), /*#__PURE__*/React__default.createElement(PopupDescription, {
24508
+ }, "Privacy note"), /*#__PURE__*/React__default.createElement(PopupDescription, {
24326
24509
  color: textPrimary,
24327
24510
  highlightColor: linkColor
24328
- }, fromChannel ? 'Couldn’t add the user. Please invite them directly instead.' : 'Not everyone can be added to this group.')), /*#__PURE__*/React__default.createElement(PopupFooter, {
24511
+ }, getExcludedContactsMessage(fromChannel))), /*#__PURE__*/React__default.createElement(PopupFooter, {
24329
24512
  backgroundColor: surface1
24330
- }, fromChannel && (/*#__PURE__*/React__default.createElement(Button, {
24513
+ }, /*#__PURE__*/React__default.createElement(Button, {
24331
24514
  type: 'button',
24332
24515
  color: textPrimary,
24333
24516
  backgroundColor: 'transparent',
24334
24517
  onClick: handleClose
24335
- }, "Cancel")), /*#__PURE__*/React__default.createElement(Button, {
24518
+ }, "Cancel"), /*#__PURE__*/React__default.createElement(Button, {
24336
24519
  type: 'button',
24337
24520
  backgroundColor: accentColor,
24338
24521
  color: textOnPrimary,
24339
24522
  borderRadius: '8px',
24340
- onClick: fromChannel ? handleInvite : handleClose
24341
- }, fromChannel ? 'Invite' : 'Cancel'))));
24523
+ onClick: handleInvite
24524
+ }, "Invite"))));
24342
24525
  };
24343
24526
 
24344
24527
  var UnavailableInviteKeyPopup = function UnavailableInviteKeyPopup() {
@@ -24671,9 +24854,11 @@ var SceytChat = function SceytChat(_ref) {
24671
24854
  highlightedBackground: highlightedBackground,
24672
24855
  id: 'sceyt_chat_container',
24673
24856
  chatMinWidth: chatMinWidth
24674
- }, children, embeddedJoinGroupPopup && joinPopup && /*#__PURE__*/React__default.createElement(EmbeddedPopupWrapper, null, joinPopup), (restricted === null || restricted === void 0 ? void 0 : restricted.isRestricted) && /*#__PURE__*/React__default.createElement(ActionRestrictedPopup, {
24675
- fromChannel: restricted === null || restricted === void 0 ? void 0 : restricted.fromChannel
24676
- }), !channelInviteKeyAvailable && /*#__PURE__*/React__default.createElement(UnavailableInviteKeyPopup, null))) : '', !embeddedJoinGroupPopup && joinPopup);
24857
+ }, children, embeddedJoinGroupPopup && joinPopup && /*#__PURE__*/React__default.createElement(EmbeddedPopupWrapper, null, joinPopup), (restricted === null || restricted === void 0 ? void 0 : restricted.isRestricted) && (/*#__PURE__*/React__default.createElement(ActionRestrictedPopup, {
24858
+ fromChannel: restricted === null || restricted === void 0 ? void 0 : restricted.fromChannel,
24859
+ members: restricted === null || restricted === void 0 ? void 0 : restricted.members,
24860
+ contactsMap: contactsMap
24861
+ })), !channelInviteKeyAvailable && /*#__PURE__*/React__default.createElement(UnavailableInviteKeyPopup, null))) : '', !embeddedJoinGroupPopup && joinPopup);
24677
24862
  };
24678
24863
  var Container$2 = styled.div(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteralLoose(["\n display: flex;\n height: 100vh;\n"])));
24679
24864
  var ChatContainer = styled.div(_templateObject2$4 || (_templateObject2$4 = _taggedTemplateLiteralLoose(["\n display: flex;\n height: 100%;\n max-height: 100vh;\n min-width: ", ";\n background-color: ", ";\n position: relative;\n\n /* Global highlighted background styles */\n ::selection {\n background-color: ", ";\n }\n\n ::-moz-selection {\n background-color: ", ";\n }\n\n /* For text selection highlighting */\n *::selection {\n background-color: ", ";\n }\n\n *::-moz-selection {\n background-color: ", ";\n }\n"])), function (props) {
@@ -27799,7 +27984,7 @@ var ChannelList = function ChannelList(_ref) {
27799
27984
  loadMoreChannels: handleLoadMoreChannels,
27800
27985
  searchValue: searchValue
27801
27986
  }, !searchValue ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, channels.map(function (channel) {
27802
- return ListItem ? (/*#__PURE__*/React__default.createElement(ListItem, {
27987
+ return !getPendingDeleteChannel(channel.id) && (ListItem ? (/*#__PURE__*/React__default.createElement(ListItem, {
27803
27988
  channel: channel,
27804
27989
  setSelectedChannel: setSelectedChannel,
27805
27990
  key: channel.id
@@ -27832,7 +28017,7 @@ var ChannelList = function ChannelList(_ref) {
27832
28017
  getCustomLatestMessage: getCustomLatestMessage,
27833
28018
  doNotShowMessageDeliveryTypes: doNotShowMessageDeliveryTypes,
27834
28019
  showPhoneNumber: showPhoneNumber
27835
- }));
28020
+ })));
27836
28021
  }))) : channelsLoading === LOADING_STATE.LOADED && searchValue ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, searchedChannels !== null && searchedChannels !== void 0 && (_searchedChannels$cha = searchedChannels.chats_groups) !== null && _searchedChannels$cha !== void 0 && _searchedChannels$cha.length || searchedChannels !== null && searchedChannels !== void 0 && (_searchedChannels$cha2 = searchedChannels.channels) !== null && _searchedChannels$cha2 !== void 0 && _searchedChannels$cha2.length || searchedChannels !== null && searchedChannels !== void 0 && (_searchedChannels$con = searchedChannels.contacts) !== null && _searchedChannels$con !== void 0 && _searchedChannels$con.length ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, !!(searchedChannels.chats_groups && searchedChannels.chats_groups.length) && (/*#__PURE__*/React__default.createElement(DirectChannels, null, /*#__PURE__*/React__default.createElement(SearchedChannelsHeader, {
27837
28022
  color: textSecondary,
27838
28023
  fontSize: searchedChannelsTitleFontSize
@@ -28516,6 +28701,9 @@ var pollVotesLoadingStateSelector = function pollVotesLoadingStateSelector(store
28516
28701
  var unreadScrollToSelector = function unreadScrollToSelector(store) {
28517
28702
  return store.MessageReducer.unreadScrollTo;
28518
28703
  };
28704
+ var unreadMessageIdSelector = function unreadMessageIdSelector(store) {
28705
+ return store.MessageReducer.unreadMessageId;
28706
+ };
28519
28707
 
28520
28708
  var _path$v;
28521
28709
  function _extends$w() {
@@ -31061,6 +31249,10 @@ var _templateObject$t, _templateObject2$p, _templateObject3$k;
31061
31249
  function MessageActions(_ref) {
31062
31250
  var _ref$isPollMessage = _ref.isPollMessage,
31063
31251
  isPollMessage = _ref$isPollMessage === void 0 ? false : _ref$isPollMessage,
31252
+ _ref$allowVoteRetract = _ref.allowVoteRetract,
31253
+ allowVoteRetract = _ref$allowVoteRetract === void 0 ? false : _ref$allowVoteRetract,
31254
+ _ref$pollClosed = _ref.pollClosed,
31255
+ pollClosed = _ref$pollClosed === void 0 ? false : _ref$pollClosed,
31064
31256
  editModeToggle = _ref.editModeToggle,
31065
31257
  channel = _ref.channel,
31066
31258
  handleResendMessage = _ref.handleResendMessage,
@@ -31153,7 +31345,7 @@ function MessageActions(_ref) {
31153
31345
  }, /*#__PURE__*/React__default.createElement(EditMessageContainer, {
31154
31346
  backgroundColor: backgroundSections,
31155
31347
  className: 'message_actions_cont '
31156
- }, showMessageReaction && !isPollMessage && messageStatus !== MESSAGE_DELIVERY_STATUS.PENDING && checkActionPermission('addMessageReaction') && (/*#__PURE__*/React__default.createElement(Action, {
31348
+ }, showMessageReaction && messageStatus !== MESSAGE_DELIVERY_STATUS.PENDING && checkActionPermission('addMessageReaction') && (/*#__PURE__*/React__default.createElement(Action, {
31157
31349
  order: reactionIconOrder || 0,
31158
31350
  iconColor: messageActionIconsColor || iconInactive,
31159
31351
  hoverBackgroundColor: backgroundHovered,
@@ -31222,7 +31414,7 @@ function MessageActions(_ref) {
31222
31414
  disabledColor: textSecondary,
31223
31415
  bgColor: tooltipBackground,
31224
31416
  direction: 'top'
31225
- }, copyIconTooltipText || 'Copy', /*#__PURE__*/React__default.createElement(SvgArrowDown, null)), copyIcon || /*#__PURE__*/React__default.createElement(SvgCopyIcon, null))), isPollMessage && (/*#__PURE__*/React__default.createElement(Action, {
31417
+ }, copyIconTooltipText || 'Copy', /*#__PURE__*/React__default.createElement(SvgArrowDown, null)), copyIcon || /*#__PURE__*/React__default.createElement(SvgCopyIcon, null))), isPollMessage && allowVoteRetract && !pollClosed && (/*#__PURE__*/React__default.createElement(Action, {
31226
31418
  onClick: handleRetractVote,
31227
31419
  iconColor: messageActionIconsColor || iconInactive,
31228
31420
  hoverBackgroundColor: backgroundHovered,
@@ -31231,7 +31423,7 @@ function MessageActions(_ref) {
31231
31423
  disabledColor: textSecondary,
31232
31424
  bgColor: tooltipBackground,
31233
31425
  direction: 'top'
31234
- }, "Retract Vote", /*#__PURE__*/React__default.createElement(SvgArrowDown, null)), retractVoteIcon || /*#__PURE__*/React__default.createElement(SvgRetractVote, null))), !isPollMessage && (/*#__PURE__*/React__default.createElement(Action, {
31426
+ }, "Retract Vote", /*#__PURE__*/React__default.createElement(SvgArrowDown, null)), retractVoteIcon || /*#__PURE__*/React__default.createElement(SvgRetractVote, null))), isPollMessage && !isIncoming && !pollClosed && (/*#__PURE__*/React__default.createElement(Action, {
31235
31427
  onClick: handleEndVote,
31236
31428
  iconColor: messageActionIconsColor || iconInactive,
31237
31429
  hoverBackgroundColor: backgroundHovered,
@@ -31240,7 +31432,7 @@ function MessageActions(_ref) {
31240
31432
  disabledColor: textSecondary,
31241
31433
  bgColor: tooltipBackground,
31242
31434
  direction: 'top'
31243
- }, "End Vote", /*#__PURE__*/React__default.createElement(SvgArrowDown, null)), endVoteIcon || /*#__PURE__*/React__default.createElement(SvgEndVote, null))), showForwardMessage && forwardMessagePermitted && messageStatus !== MESSAGE_DELIVERY_STATUS.PENDING && (/*#__PURE__*/React__default.createElement(Action, {
31435
+ }, "End Vote", /*#__PURE__*/React__default.createElement(SvgArrowDown, null)), endVoteIcon || /*#__PURE__*/React__default.createElement(SvgEndVote, null))), showForwardMessage && forwardMessagePermitted && messageStatus !== MESSAGE_DELIVERY_STATUS.PENDING && !isPollMessage && (/*#__PURE__*/React__default.createElement(Action, {
31244
31436
  order: forwardIconOrder || 5,
31245
31437
  iconColor: messageActionIconsColor || iconInactive,
31246
31438
  hoverBackgroundColor: backgroundHovered,
@@ -36124,11 +36316,11 @@ var PollMessage = function PollMessage(_ref) {
36124
36316
  onClick: handleResultsClick,
36125
36317
  cursor: poll.anonymous ? 'default' : 'pointer'
36126
36318
  }, optionVotesUsers.map(function (vote) {
36127
- var _vote$user, _vote$user2, _vote$user2$profile, _vote$user3, _vote$user3$profile;
36319
+ var _vote$user, _vote$user2, _vote$user2$profile, _vote$user3, _vote$user3$profile, _vote$user4;
36128
36320
  return /*#__PURE__*/React__default.createElement(Avatar, {
36129
36321
  key: vote === null || vote === void 0 ? void 0 : (_vote$user = vote.user) === null || _vote$user === void 0 ? void 0 : _vote$user.id,
36130
36322
  image: vote === null || vote === void 0 ? void 0 : (_vote$user2 = vote.user) === null || _vote$user2 === void 0 ? void 0 : (_vote$user2$profile = _vote$user2.profile) === null || _vote$user2$profile === void 0 ? void 0 : _vote$user2$profile.avatar,
36131
- name: vote === null || vote === void 0 ? void 0 : (_vote$user3 = vote.user) === null || _vote$user3 === void 0 ? void 0 : (_vote$user3$profile = _vote$user3.profile) === null || _vote$user3$profile === void 0 ? void 0 : _vote$user3$profile.firstName,
36323
+ name: (vote === null || vote === void 0 ? void 0 : (_vote$user3 = vote.user) === null || _vote$user3 === void 0 ? void 0 : (_vote$user3$profile = _vote$user3.profile) === null || _vote$user3$profile === void 0 ? void 0 : _vote$user3$profile.firstName) || (vote === null || vote === void 0 ? void 0 : (_vote$user4 = vote.user) === null || _vote$user4 === void 0 ? void 0 : _vote$user4.id),
36132
36324
  size: 18,
36133
36325
  textSize: 12,
36134
36326
  setDefaultAvatar: true,
@@ -36674,6 +36866,7 @@ var FaviconImg = styled.img(_templateObject1$a || (_templateObject1$a = _taggedT
36674
36866
 
36675
36867
  var _templateObject$H, _templateObject2$C, _templateObject3$w, _templateObject4$r, _templateObject5$m, _templateObject6$k, _templateObject7$j;
36676
36868
  var MessageBody = function MessageBody(_ref) {
36869
+ var _message$pollDetails, _message$pollDetails2;
36677
36870
  var message = _ref.message,
36678
36871
  channel = _ref.channel,
36679
36872
  MessageActionsMenu = _ref.MessageActionsMenu,
@@ -37049,6 +37242,8 @@ var MessageBody = function MessageBody(_ref) {
37049
37242
  handleEndVote: handleEndVote
37050
37243
  })) : (/*#__PURE__*/React__default.createElement(MessageActions, {
37051
37244
  isPollMessage: (message === null || message === void 0 ? void 0 : message.type) === MESSAGE_TYPE.POLL,
37245
+ allowVoteRetract: message === null || message === void 0 ? void 0 : (_message$pollDetails = message.pollDetails) === null || _message$pollDetails === void 0 ? void 0 : _message$pollDetails.allowVoteRetract,
37246
+ pollClosed: message === null || message === void 0 ? void 0 : (_message$pollDetails2 = message.pollDetails) === null || _message$pollDetails2 === void 0 ? void 0 : _message$pollDetails2.closed,
37052
37247
  messageFrom: message.user,
37053
37248
  channel: channel,
37054
37249
  editModeToggle: toggleEditMode,
@@ -39070,42 +39265,40 @@ var MessageList = function MessageList(_ref2) {
39070
39265
  var showScrollToNewMessageButton = useSelector(showScrollToNewMessageButtonSelector, shallowEqual);
39071
39266
  var unreadScrollTo = useSelector(unreadScrollToSelector, shallowEqual);
39072
39267
  var messages = useSelector(activeChannelMessagesSelector, shallowEqual) || [];
39073
- var _useState2 = useState(''),
39074
- unreadMessageId = _useState2[0],
39075
- setUnreadMessageId = _useState2[1];
39268
+ var unreadMessageId = useSelector(unreadMessageIdSelector, shallowEqual);
39269
+ var _useState2 = useState(null),
39270
+ mediaFile = _useState2[0],
39271
+ setMediaFile = _useState2[1];
39076
39272
  var _useState3 = useState(null),
39077
- mediaFile = _useState3[0],
39078
- setMediaFile = _useState3[1];
39273
+ isDragging = _useState3[0],
39274
+ setIsDragging = _useState3[1];
39079
39275
  var _useState4 = useState(null),
39080
- isDragging = _useState4[0],
39081
- setIsDragging = _useState4[1];
39082
- var _useState5 = useState(null),
39083
- showTopDate = _useState5[0],
39084
- setShowTopDate = _useState5[1];
39276
+ showTopDate = _useState4[0],
39277
+ setShowTopDate = _useState4[1];
39278
+ var _useState5 = useState(false),
39279
+ stopScrolling = _useState5[0],
39280
+ setStopScrolling = _useState5[1];
39085
39281
  var _useState6 = useState(false),
39086
- stopScrolling = _useState6[0],
39087
- setStopScrolling = _useState6[1];
39088
- var _useState7 = useState(false),
39089
- isScrolling = _useState7[0],
39090
- setIsScrolling = _useState7[1];
39282
+ isScrolling = _useState6[0],
39283
+ setIsScrolling = _useState6[1];
39091
39284
  var hideTopDateTimeout = useRef(null);
39092
- var _useState8 = useState(''),
39093
- lastVisibleMessageId = _useState8[0],
39094
- _setLastVisibleMessageId = _useState8[1];
39095
- var _useState9 = useState(null),
39096
- scrollToReply = _useState9[0],
39097
- setScrollToReply = _useState9[1];
39098
- var _useState0 = useState(0),
39099
- previousScrollTop = _useState0[0],
39100
- setPreviousScrollTop = _useState0[1];
39101
- var _useState1 = useState(false),
39102
- shouldPreserveScroll = _useState1[0],
39103
- setShouldPreserveScroll = _useState1[1];
39285
+ var _useState7 = useState(''),
39286
+ lastVisibleMessageId = _useState7[0],
39287
+ _setLastVisibleMessageId = _useState7[1];
39288
+ var _useState8 = useState(null),
39289
+ scrollToReply = _useState8[0],
39290
+ setScrollToReply = _useState8[1];
39291
+ var _useState9 = useState(0),
39292
+ previousScrollTop = _useState9[0],
39293
+ setPreviousScrollTop = _useState9[1];
39294
+ var _useState0 = useState(false),
39295
+ shouldPreserveScroll = _useState0[0],
39296
+ setShouldPreserveScroll = _useState0[1];
39104
39297
  var messageForReply = {};
39105
39298
  var attachmentsSelected = false;
39106
- var _useState10 = useState(''),
39107
- topDateLabel = _useState10[0],
39108
- setTopDateLabel = _useState10[1];
39299
+ var _useState1 = useState(''),
39300
+ topDateLabel = _useState1[0],
39301
+ setTopDateLabel = _useState1[1];
39109
39302
  var scrollRef = useRef(null);
39110
39303
  var loadFromServerRef = useRef(false);
39111
39304
  var loadDirectionRef = useRef('');
@@ -39440,7 +39633,7 @@ var MessageList = function MessageList(_ref2) {
39440
39633
  var visibleMessagesIds = Object.keys(visibleMessages);
39441
39634
  var messageId = visibleMessagesIds[visibleMessagesIds.length - 1];
39442
39635
  dispatch(getMessagesAC(channel, undefined, messageId, undefined, undefined, 'instant'));
39443
- setUnreadMessageId(messageId);
39636
+ dispatch(setUnreadMessageIdAC(messageId));
39444
39637
  } else {
39445
39638
  if (!channel.isLinkedChannel) {
39446
39639
  clearVisibleMessagesMap();
@@ -39450,9 +39643,9 @@ var MessageList = function MessageList(_ref2) {
39450
39643
  }
39451
39644
  if (channel.id) {
39452
39645
  if (channel.newMessageCount && channel.newMessageCount > 0) {
39453
- setUnreadMessageId(channel.lastDisplayedMessageId);
39646
+ dispatch(setUnreadMessageIdAC(channel.lastDisplayedMessageId));
39454
39647
  } else {
39455
- setUnreadMessageId('');
39648
+ dispatch(setUnreadMessageIdAC(''));
39456
39649
  }
39457
39650
  }
39458
39651
  }
@@ -39476,7 +39669,7 @@ var MessageList = function MessageList(_ref2) {
39476
39669
  if (messages.length > 0 && hiddenMessagesProperties !== null && hiddenMessagesProperties !== void 0 && hiddenMessagesProperties.includes(HiddenMessageProperty.hideAfterSendMessage)) {
39477
39670
  var lastMessage = messages[messages.length - 1];
39478
39671
  if (lastMessage.user.id === user.id) {
39479
- setUnreadMessageId('');
39672
+ dispatch(setUnreadMessageIdAC(''));
39480
39673
  }
39481
39674
  }
39482
39675
  }, [messages, hiddenMessagesProperties, user === null || user === void 0 ? void 0 : user.id]);
@@ -39597,12 +39790,14 @@ var MessageList = function MessageList(_ref2) {
39597
39790
  useEffect(function () {
39598
39791
  log.info('connection status is changed.. .... ', connectionStatus, 'channel ... ', channel);
39599
39792
  if (connectionStatus === CONNECTION_STATUS.CONNECTED && channel !== null && channel !== void 0 && channel.id) {
39793
+ var _channel$lastMessage4;
39600
39794
  loadingRef.current = false;
39601
39795
  prevDisableRef.current = false;
39602
39796
  nextDisableRef.current = false;
39603
39797
  clearMessagesMap();
39604
39798
  removeAllMessages();
39605
- dispatch(getMessagesAC(channel, false, lastVisibleMessageId, 0, false, 'instant', false, true));
39799
+ var isWithLastVisibleMessageId = lastVisibleMessageId !== ((_channel$lastMessage4 = channel.lastMessage) === null || _channel$lastMessage4 === void 0 ? void 0 : _channel$lastMessage4.id) && lastVisibleMessageId ? lastVisibleMessageId : '';
39800
+ dispatch(getMessagesAC(channel, false, isWithLastVisibleMessageId, 0, false, 'instant', false, true));
39606
39801
  }
39607
39802
  }, [connectionStatus]);
39608
39803
  useEffect(function () {
@@ -45696,7 +45891,8 @@ var GroupsInCommonPopup = function GroupsInCommonPopup(_ref2) {
45696
45891
  textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
45697
45892
  background = _useColor[THEME_COLORS.BACKGROUND],
45698
45893
  iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
45699
- backgroundHovered = _useColor[THEME_COLORS.BACKGROUND_HOVERED];
45894
+ backgroundHovered = _useColor[THEME_COLORS.BACKGROUND_HOVERED],
45895
+ surface2 = _useColor[THEME_COLORS.SURFACE_2];
45700
45896
  var contactsMap = useSelector(contactsMapSelector);
45701
45897
  var getFromContacts = getShowOnlyContactUsers();
45702
45898
  var dispatch = useDispatch();
@@ -45761,7 +45957,7 @@ var GroupsInCommonPopup = function GroupsInCommonPopup(_ref2) {
45761
45957
  onMouseLeave: function onMouseLeave() {
45762
45958
  return setIsScrolling(false);
45763
45959
  },
45764
- thumbColor: background
45960
+ thumbColor: surface2
45765
45961
  }, isLoadingInitial ? (/*#__PURE__*/React__default.createElement(LoadingText$1, {
45766
45962
  color: textSecondary
45767
45963
  }, "Loading...")) : mutualChannels.length > 0 ? mutualChannels.map(function (channel) {
@@ -45784,7 +45980,7 @@ var GroupsInCommonPopup = function GroupsInCommonPopup(_ref2) {
45784
45980
  color: textSecondary
45785
45981
  }, "Loading more...")))));
45786
45982
  };
45787
- var ChannelsList$1 = styled.div(_templateObject$U || (_templateObject$U = _taggedTemplateLiteralLoose(["\n max-height: 400px;\n overflow-y: auto;\n overflow-x: hidden;\n\n &::-webkit-scrollbar {\n width: 6px;\n }\n\n &::-webkit-scrollbar-track {\n background: transparent;\n }\n\n &::-webkit-scrollbar-thumb {\n background: ", ";\n border-radius: 3px;\n opacity: 0.3;\n }\n\n &.show-scrollbar::-webkit-scrollbar-thumb {\n opacity: 0.6;\n }\n"])), function (props) {
45983
+ var ChannelsList$1 = styled.div(_templateObject$U || (_templateObject$U = _taggedTemplateLiteralLoose(["\n max-height: 400px;\n overflow-y: auto;\n overflow-x: hidden;\n\n &::-webkit-scrollbar {\n width: 8px;\n background: transparent;\n }\n &::-webkit-scrollbar-thumb {\n background: transparent;\n }\n\n &.show-scrollbar::-webkit-scrollbar-thumb {\n background: ", ";\n border-radius: 4px;\n }\n &.show-scrollbar::-webkit-scrollbar-track {\n background: transparent;\n }\n"])), function (props) {
45788
45984
  return props.thumbColor;
45789
45985
  });
45790
45986
  var ChannelItem$1 = styled.div(_templateObject2$P || (_templateObject2$P = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n padding: 6px 2px 6px 6px;\n border-radius: 8px;\n cursor: pointer;\n transition: background-color 0.2s;\n\n &:hover {\n background-color: ", ";\n }\n"])), function (props) {
@@ -48774,6 +48970,12 @@ var Details = function Details(_ref) {
48774
48970
  return Promise.reject(e);
48775
48971
  }
48776
48972
  };
48973
+ var channelMetadata = useMemo(function () {
48974
+ if (isJSON(activeChannel === null || activeChannel === void 0 ? void 0 : activeChannel.metadata)) {
48975
+ return JSON.parse(activeChannel === null || activeChannel === void 0 ? void 0 : activeChannel.metadata);
48976
+ }
48977
+ return activeChannel === null || activeChannel === void 0 ? void 0 : activeChannel.metadata;
48978
+ }, [activeChannel]);
48777
48979
  return /*#__PURE__*/React__default.createElement(Container$v, {
48778
48980
  backgroundColor: backgroundColor,
48779
48981
  mounted: mounted,
@@ -48859,11 +49061,11 @@ var Details = function Details(_ref) {
48859
49061
  color: textSecondary,
48860
49062
  fontSize: channelMembersFontSize,
48861
49063
  lineHeight: channelMembersLineHeight
48862
- }, activeChannel && activeChannel.memberCount, " ", displayMemberText)))), showAboutChannel && activeChannel && activeChannel.metadata && activeChannel.metadata.d && (/*#__PURE__*/React__default.createElement(AboutChannel, null, showAboutChannelTitle && /*#__PURE__*/React__default.createElement(AboutChannelTitle, {
49064
+ }, activeChannel && activeChannel.memberCount, " ", displayMemberText)))), showAboutChannel && activeChannel && channelMetadata && (channelMetadata === null || channelMetadata === void 0 ? void 0 : channelMetadata.d) && (/*#__PURE__*/React__default.createElement(AboutChannel, null, showAboutChannelTitle && /*#__PURE__*/React__default.createElement(AboutChannelTitle, {
48863
49065
  color: textFootnote
48864
49066
  }, "About"), /*#__PURE__*/React__default.createElement(AboutChannelText, {
48865
49067
  color: textPrimary
48866
- }, activeChannel && activeChannel.metadata && activeChannel.metadata.d ? activeChannel.metadata.d : '')))), activeChannel && activeChannel.userRole && (/*#__PURE__*/React__default.createElement(Actions, {
49068
+ }, channelMetadata !== null && channelMetadata !== void 0 && channelMetadata.d ? channelMetadata === null || channelMetadata === void 0 ? void 0 : channelMetadata.d : '')))), activeChannel && activeChannel.userRole && (/*#__PURE__*/React__default.createElement(Actions, {
48867
49069
  setActionsHeight: setActionsHeight,
48868
49070
  theme: theme,
48869
49071
  showMuteUnmuteNotifications: showMuteUnmuteNotifications,