sceyt-chat-react-uikit 1.7.7-beta.1 → 1.7.7-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +128 -67
  2. package/index.modern.js +128 -67
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -8999,7 +8999,8 @@ var handleVoteDetails = function handleVoteDetails(voteDetails, message) {
8999
8999
  var vote = voteDetails.vote;
9000
9000
  var optionId = vote.optionId;
9001
9001
  var currentVotesPerOption = existingVoteDetails.votesPerOption || {};
9002
- var newVotesPerOption = _extends({}, currentVotesPerOption, (_extends2 = {}, _extends2[optionId] = (currentVotesPerOption[optionId] || 0) + voteDetails.incrementVotesPerOptionCount, _extends2));
9002
+ var optionVotesCount = (currentVotesPerOption[optionId] || 0) + voteDetails.incrementVotesPerOptionCount;
9003
+ var newVotesPerOption = _extends({}, currentVotesPerOption, (_extends2 = {}, _extends2[optionId] = optionVotesCount >= 0 ? optionVotesCount : 0, _extends2));
9003
9004
  var newVotes = existingVoteDetails.votes || [];
9004
9005
  var newOwnVotes = existingVoteDetails.ownVotes || [];
9005
9006
  if (voteDetails.type === 'add') {
@@ -10884,7 +10885,7 @@ function updateMessageOnMap(channelId, updatedMessage, voteDetails) {
10884
10885
  } else {
10885
10886
  var statusUpdatedMessage = updateMessageDeliveryStatusAndMarkers(mes, updatedMessage.params.deliveryStatus);
10886
10887
  updatedMessageData = _extends({}, mes, updatedMessage.params, statusUpdatedMessage);
10887
- var voteDetailsData = void 0;
10888
+ var voteDetailsData = mes === null || mes === void 0 ? void 0 : mes.pollDetails;
10888
10889
  if (voteDetails) {
10889
10890
  voteDetailsData = handleVoteDetails(voteDetails, updatedMessageData);
10890
10891
  }
@@ -15268,7 +15269,7 @@ function watchForEvents() {
15268
15269
  objs.push({
15269
15270
  type: vote.user.id === SceytChatClient.user.id ? 'deleteOwn' : 'delete',
15270
15271
  vote: vote,
15271
- incrementVotesPerOptionCount: -((deletedVotes === null || deletedVotes === void 0 ? void 0 : deletedVotes.length) || 0)
15272
+ incrementVotesPerOptionCount: -1
15272
15273
  });
15273
15274
  }
15274
15275
  for (_iterator3 = _createForOfIteratorHelperLoose(addedVotes); !(_step3 = _iterator3()).done;) {
@@ -15276,7 +15277,7 @@ function watchForEvents() {
15276
15277
  objs.push({
15277
15278
  type: _vote.user.id === SceytChatClient.user.id ? 'addOwn' : 'add',
15278
15279
  vote: _vote,
15279
- incrementVotesPerOptionCount: (addedVotes === null || addedVotes === void 0 ? void 0 : addedVotes.length) || 0
15280
+ incrementVotesPerOptionCount: 1
15280
15281
  });
15281
15282
  }
15282
15283
  _i = 0, _objs = objs;
@@ -15351,7 +15352,7 @@ function watchForEvents() {
15351
15352
  _objs3.push({
15352
15353
  type: _vote2.user.id === SceytChatClient.user.id ? 'deleteOwn' : 'delete',
15353
15354
  vote: _vote2,
15354
- incrementVotesPerOptionCount: -((_deletedVotes === null || _deletedVotes === void 0 ? void 0 : _deletedVotes.length) || 0)
15355
+ incrementVotesPerOptionCount: -1
15355
15356
  });
15356
15357
  }
15357
15358
  _i3 = 0, _objs4 = _objs3;
@@ -15410,7 +15411,7 @@ function watchForEvents() {
15410
15411
  _objs6.push({
15411
15412
  type: _vote4.user.id === SceytChatClient.user.id ? 'deleteOwn' : 'delete',
15412
15413
  vote: _vote4,
15413
- incrementVotesPerOptionCount: -((retractedVotes === null || retractedVotes === void 0 ? void 0 : retractedVotes.length) || 0)
15414
+ incrementVotesPerOptionCount: -1
15414
15415
  });
15415
15416
  }
15416
15417
  _i5 = 0, _objs7 = _objs6;
@@ -16064,25 +16065,31 @@ function createChannel(action) {
16064
16065
  }, _marked$2, null, [[0, 17]]);
16065
16066
  }
16066
16067
  function getChannels(action) {
16067
- var _params$filter, _types, payload, params, SceytChatClient, channelQueryBuilder, channelTypesFilter, types, channelQuery, channelsData, channelList, channelId, activeChannel, _yield$call, mappedChannels, channelsForUpdateLastReactionMessage, channelMessageMap, hiddenList, allChannelsQueryBuilder, allChannelsQuery, hasNext, i, allChannelsData, allChannelList, _t2, _t3, _t4;
16068
+ 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, allChannelsData, allChannelList, _t2, _t3, _t4;
16068
16069
  return _regenerator().w(function (_context2) {
16069
16070
  while (1) switch (_context2.p = _context2.n) {
16070
16071
  case 0:
16071
- _context2.p = 0;
16072
+ log.info('[getChannels] start get channels');
16073
+ _context2.p = 1;
16072
16074
  payload = action.payload;
16073
16075
  params = payload.params;
16076
+ log.info('[getChannels] input params:', JSON.stringify(params));
16074
16077
  SceytChatClient = getClient();
16075
- if (!(store.getState().UserReducer.connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
16076
- _context2.n = 1;
16078
+ connectionStatus = store.getState().UserReducer.connectionStatus;
16079
+ log.info('[getChannels] connection status:', connectionStatus);
16080
+ if (!(connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
16081
+ _context2.n = 2;
16077
16082
  break;
16078
16083
  }
16084
+ log.warn('[getChannels] connection not ready, aborting. Status:', connectionStatus);
16079
16085
  return _context2.a(2);
16080
- case 1:
16081
- _context2.n = 2;
16082
- return effects.put(setChannelsLoadingStateAC(LOADING_STATE.LOADING));
16083
16086
  case 2:
16087
+ _context2.n = 3;
16088
+ return effects.put(setChannelsLoadingStateAC(LOADING_STATE.LOADING));
16089
+ case 3:
16084
16090
  channelQueryBuilder = new SceytChatClient.ChannelListQueryBuilder();
16085
16091
  channelTypesFilter = getChannelTypesFilter();
16092
+ log.info('[getChannels] channelTypesFilter:', JSON.stringify(channelTypesFilter));
16086
16093
  types = [];
16087
16094
  if (channelTypesFilter !== null && channelTypesFilter !== void 0 && channelTypesFilter.length) {
16088
16095
  types = channelTypesFilter;
@@ -16090,59 +16097,77 @@ function getChannels(action) {
16090
16097
  if (params !== null && params !== void 0 && (_params$filter = params.filter) !== null && _params$filter !== void 0 && _params$filter.channelType) {
16091
16098
  types.push(params.filter.channelType);
16092
16099
  }
16100
+ log.info('[getChannels] final types array:', JSON.stringify(types));
16093
16101
  if ((_types = types) !== null && _types !== void 0 && _types.length) {
16094
16102
  channelQueryBuilder.types(types);
16095
16103
  }
16096
16104
  if (params.memberCount) {
16105
+ log.info('[getChannels] setting memberCount filter:', params === null || params === void 0 ? void 0 : params.memberCount);
16097
16106
  channelQueryBuilder.memberCount(params.memberCount);
16098
16107
  }
16099
16108
  channelQueryBuilder.order('lastMessage');
16100
- channelQueryBuilder.limit(params.limit || 50);
16101
- _context2.n = 3;
16109
+ limit = params.limit || 50;
16110
+ log.info('[getChannels] query limit:', limit);
16111
+ channelQueryBuilder.limit(limit);
16112
+ _context2.n = 4;
16102
16113
  return effects.call(channelQueryBuilder.build);
16103
- case 3:
16114
+ case 4:
16104
16115
  channelQuery = _context2.v;
16105
- _context2.n = 4;
16116
+ log.info('[getChannels] query built successfully');
16117
+ _context2.n = 5;
16106
16118
  return effects.call(channelQuery.loadNextPage);
16107
- case 4:
16119
+ case 5:
16108
16120
  channelsData = _context2.v;
16109
16121
  channelList = channelsData.channels;
16110
- _context2.n = 5;
16111
- return effects.put(channelHasNextAC(channelsData.hasNext));
16112
- case 5:
16122
+ log.info('[getChannels] channelsData received:', JSON.stringify({
16123
+ channelsCount: (channelList === null || channelList === void 0 ? void 0 : channelList.length) || 0,
16124
+ hasNext: channelsData.hasNext
16125
+ }));
16113
16126
  _context2.n = 6;
16114
- return effects.call(getActiveChannelId);
16127
+ return effects.put(channelHasNextAC(channelsData.hasNext));
16115
16128
  case 6:
16129
+ _context2.n = 7;
16130
+ return effects.call(getActiveChannelId);
16131
+ case 7:
16116
16132
  channelId = _context2.v;
16133
+ log.info('[getChannels] active channelId:', channelId);
16117
16134
  if (!channelId) {
16118
- _context2.n = 8;
16135
+ _context2.n = 9;
16119
16136
  break;
16120
16137
  }
16121
- _context2.n = 7;
16138
+ _context2.n = 8;
16122
16139
  return effects.call(getChannelFromMap, channelId);
16123
- case 7:
16140
+ case 8:
16124
16141
  _t2 = _context2.v;
16125
- _context2.n = 9;
16142
+ _context2.n = 10;
16126
16143
  break;
16127
- case 8:
16128
- _t2 = null;
16129
16144
  case 9:
16130
- activeChannel = _t2;
16131
- _context2.n = 10;
16132
- return effects.call(destroyChannelsMap);
16145
+ _t2 = null;
16133
16146
  case 10:
16147
+ activeChannel = _t2;
16148
+ log.info('[getChannels] activeChannel from map:', activeChannel ? (_activeChannel = activeChannel) === null || _activeChannel === void 0 ? void 0 : _activeChannel.id : 'null');
16134
16149
  _context2.n = 11;
16135
- return effects.call(setChannelsInMap, channelList);
16150
+ return effects.call(destroyChannelsMap);
16136
16151
  case 11:
16152
+ log.info('[getChannels] channels map destroyed');
16153
+ _context2.n = 12;
16154
+ return effects.call(setChannelsInMap, channelList);
16155
+ case 12:
16137
16156
  _yield$call = _context2.v;
16138
16157
  mappedChannels = _yield$call.channels;
16139
16158
  channelsForUpdateLastReactionMessage = _yield$call.channelsForUpdateLastReactionMessage;
16140
- if (!channelsForUpdateLastReactionMessage.length) {
16141
- _context2.n = 13;
16159
+ log.info('[getChannels] setChannelsInMap result:', JSON.stringify({
16160
+ mappedChannelsCount: ((_mappedChannels = mappedChannels) === null || _mappedChannels === void 0 ? void 0 : _mappedChannels.length) || 0,
16161
+ channelsForUpdateLastReactionMessageCount: (channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length) || 0
16162
+ }));
16163
+ log.info('channelsForUpdateLastReactionMessage', channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length);
16164
+ if (!(channelsForUpdateLastReactionMessage !== null && channelsForUpdateLastReactionMessage !== void 0 && channelsForUpdateLastReactionMessage.length)) {
16165
+ _context2.n = 14;
16142
16166
  break;
16143
16167
  }
16168
+ log.info('[getChannels] processing channels for reaction message update:', channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length);
16144
16169
  channelMessageMap = {};
16145
- _context2.n = 12;
16170
+ _context2.n = 13;
16146
16171
  return effects.call(function () {
16147
16172
  try {
16148
16173
  return Promise.resolve(Promise.all(channelsForUpdateLastReactionMessage.map(function (channel) {
@@ -16150,9 +16175,10 @@ function getChannels(action) {
16150
16175
  return Promise.resolve(new Promise(function (resolve) {
16151
16176
  channel.getMessagesById([channel.newReactions[0].messageId]).then(function (messages) {
16152
16177
  channelMessageMap[channel.id] = messages[0];
16178
+ log.info('[getChannels] successfully fetched reaction message for channel:', channel === null || channel === void 0 ? void 0 : channel.id);
16153
16179
  resolve(true);
16154
16180
  })["catch"](function (e) {
16155
- log.error(e, 'Error on getMessagesById');
16181
+ log.error(e, 'Error on getMessagesById for channel:', channel === null || channel === void 0 ? void 0 : channel.id);
16156
16182
  resolve(true);
16157
16183
  });
16158
16184
  }));
@@ -16164,89 +16190,124 @@ function getChannels(action) {
16164
16190
  return Promise.reject(e);
16165
16191
  }
16166
16192
  });
16167
- case 12:
16193
+ case 13:
16194
+ log.info('[getChannels] reaction messages fetched:', channelMessageMap ? (_Object$keys = Object.keys(channelMessageMap)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length : 0);
16168
16195
  mappedChannels = mappedChannels.map(function (channel) {
16169
16196
  if (channelMessageMap[channel.id]) {
16170
16197
  channel.lastReactedMessage = channelMessageMap[channel.id];
16171
16198
  }
16172
16199
  return channel;
16173
16200
  });
16174
- case 13:
16175
- _context2.n = 14;
16176
- return effects.put(setChannelsAC(mappedChannels));
16201
+ log.info('[getChannels] mappedChannels updated with reaction messages, final count:', ((_mappedChannels2 = mappedChannels) === null || _mappedChannels2 === void 0 ? void 0 : _mappedChannels2.length) || 0);
16177
16202
  case 14:
16203
+ log.info('[getChannels] setting channels in state, count:', ((_mappedChannels3 = mappedChannels) === null || _mappedChannels3 === void 0 ? void 0 : _mappedChannels3.length) || 0);
16204
+ _context2.n = 15;
16205
+ return effects.put(setChannelsAC(mappedChannels));
16206
+ case 15:
16178
16207
  if (!channelId) {
16179
16208
  activeChannel = channelList[0];
16209
+ log.info('[getChannels] no active channelId, setting first channel as active:', (_activeChannel2 = activeChannel) === null || _activeChannel2 === void 0 ? void 0 : _activeChannel2.id);
16180
16210
  }
16181
16211
  query.channelQuery = channelQuery;
16182
16212
  if (!(activeChannel && getAutoSelectFitsChannel())) {
16183
- _context2.n = 15;
16213
+ _context2.n = 16;
16184
16214
  break;
16185
16215
  }
16186
- _context2.n = 15;
16187
- return effects.put(switchChannelActionAC(JSON.parse(JSON.stringify(activeChannel))));
16188
- case 15:
16216
+ log.info('[getChannels] auto-selecting channel:', (_activeChannel3 = activeChannel) === null || _activeChannel3 === void 0 ? void 0 : _activeChannel3.id);
16189
16217
  _context2.n = 16;
16190
- return effects.put(setChannelsLoadingStateAC(LOADING_STATE.LOADED));
16218
+ return effects.put(switchChannelActionAC(JSON.parse(JSON.stringify(activeChannel))));
16191
16219
  case 16:
16220
+ _context2.n = 17;
16221
+ return effects.put(setChannelsLoadingStateAC(LOADING_STATE.LOADED));
16222
+ case 17:
16192
16223
  hiddenList = store.getState().ChannelReducer.hideChannelList;
16224
+ log.info('[getChannels] hiddenList state:', hiddenList);
16193
16225
  if (hiddenList) {
16194
- _context2.n = 23;
16226
+ _context2.n = 27;
16195
16227
  break;
16196
16228
  }
16229
+ log.info('[getChannels] starting all channels query (hiddenList is false)');
16197
16230
  allChannelsQueryBuilder = new SceytChatClient.ChannelListQueryBuilder();
16198
16231
  allChannelsQueryBuilder.order('lastMessage');
16199
16232
  if (channelTypesFilter !== null && channelTypesFilter !== void 0 && channelTypesFilter.length) {
16200
16233
  allChannelsQueryBuilder.types(channelTypesFilter);
16234
+ log.info('[getChannels] allChannelsQuery types:', JSON.stringify(channelTypesFilter));
16201
16235
  }
16202
16236
  if (params !== null && params !== void 0 && params.memberCount) {
16203
16237
  allChannelsQueryBuilder.memberCount(params.memberCount);
16238
+ log.info('[getChannels] allChannelsQuery memberCount:', params === null || params === void 0 ? void 0 : params.memberCount);
16204
16239
  }
16205
16240
  allChannelsQueryBuilder.limit(50);
16206
- _context2.n = 17;
16241
+ _context2.n = 18;
16207
16242
  return effects.call(allChannelsQueryBuilder.build);
16208
- case 17:
16243
+ case 18:
16209
16244
  allChannelsQuery = _context2.v;
16245
+ log.info('[getChannels] allChannelsQuery built');
16210
16246
  hasNext = true;
16247
+ totalAllChannelsAdded = 0;
16211
16248
  i = 0;
16212
- case 18:
16249
+ case 19:
16213
16250
  if (!(i <= 4)) {
16214
- _context2.n = 23;
16251
+ _context2.n = 26;
16215
16252
  break;
16216
16253
  }
16217
16254
  if (!hasNext) {
16218
- _context2.n = 22;
16255
+ _context2.n = 24;
16219
16256
  break;
16220
16257
  }
16221
- _context2.p = 19;
16222
- _context2.n = 20;
16258
+ _context2.p = 20;
16259
+ log.info('[getChannels] loading all channels page:', i + 1);
16260
+ _context2.n = 21;
16223
16261
  return effects.call(allChannelsQuery.loadNextPage);
16224
- case 20:
16262
+ case 21:
16225
16263
  allChannelsData = _context2.v;
16226
16264
  hasNext = allChannelsData.hasNext;
16227
16265
  allChannelList = allChannelsData.channels;
16266
+ log.info('[getChannels] all channels page', i + 1, 'loaded:', JSON.stringify({
16267
+ channelsCount: (allChannelList === null || allChannelList === void 0 ? void 0 : allChannelList.length) || 0,
16268
+ hasNext: hasNext
16269
+ }));
16228
16270
  addChannelsToAllChannels(allChannelList);
16229
- _context2.n = 22;
16271
+ totalAllChannelsAdded += (allChannelList === null || allChannelList === void 0 ? void 0 : allChannelList.length) || 0;
16272
+ log.info('[getChannels] total all channels added so far:', totalAllChannelsAdded);
16273
+ _context2.n = 23;
16230
16274
  break;
16231
- case 21:
16232
- _context2.p = 21;
16233
- _t3 = _context2.v;
16234
- log.error(_t3, 'Error on get all channels');
16235
16275
  case 22:
16236
- i++;
16237
- _context2.n = 18;
16238
- break;
16276
+ _context2.p = 22;
16277
+ _t3 = _context2.v;
16278
+ log.error(_t3, 'Error on get all channels page:', i + 1);
16239
16279
  case 23:
16240
16280
  _context2.n = 25;
16241
16281
  break;
16242
16282
  case 24:
16243
- _context2.p = 24;
16244
- _t4 = _context2.v;
16245
- log.error(JSON.stringify(_t4), 'Error on get channels');
16283
+ log.info('[getChannels] no more pages available, stopping at iteration:', i);
16246
16284
  case 25:
16285
+ i++;
16286
+ _context2.n = 19;
16287
+ break;
16288
+ case 26:
16289
+ log.info('[getChannels] all channels query completed, total channels added:', totalAllChannelsAdded);
16290
+ _context2.n = 28;
16291
+ break;
16292
+ case 27:
16293
+ log.info('[getChannels] skipping all channels query (hiddenList is true)');
16294
+ case 28:
16295
+ log.info('[getChannels] completed successfully. Final mapped channels count:', ((_mappedChannels4 = mappedChannels) === null || _mappedChannels4 === void 0 ? void 0 : _mappedChannels4.length) || 0);
16296
+ _context2.n = 30;
16297
+ break;
16298
+ case 29:
16299
+ _context2.p = 29;
16300
+ _t4 = _context2.v;
16301
+ log.error('[getChannels] error occurred:', JSON.stringify(_t4), 'Error on get channels');
16302
+ log.error('[getChannels] error details:', {
16303
+ message: _t4.message,
16304
+ code: _t4.code,
16305
+ stack: _t4.stack
16306
+ });
16307
+ case 30:
16247
16308
  return _context2.a(2);
16248
16309
  }
16249
- }, _marked2$1, null, [[19, 21], [0, 24]]);
16310
+ }, _marked2$1, null, [[20, 22], [1, 29]]);
16250
16311
  }
16251
16312
  function searchChannels(action) {
16252
16313
  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;
@@ -19389,7 +19450,7 @@ function forwardMessage(action) {
19389
19450
  allowVoteRetract: message.pollDetails.allowVoteRetract
19390
19451
  };
19391
19452
  }
19392
- messageBuilder.setBody(message.body).setBodyAttributes(message.bodyAttributes).setAttachments(attachments).setMentionUserIds(mentionedUserIds).setType(message.type).setDisableMentionsCount(getDisableFrowardMentionsCount()).setMetadata(message.metadata ? JSON.stringify(message.metadata) : '').setForwardingMessageId(message.forwardingDetails ? message.forwardingDetails.messageId : message.id).setPollDetails(pollDetails);
19453
+ messageBuilder.setBody(message.body).setBodyAttributes(message.bodyAttributes).setAttachments(attachments).setMentionUserIds(mentionedUserIds).setType(message.type).setDisableMentionsCount(getDisableFrowardMentionsCount()).setMetadata(message.metadata ? isJSON(message.metadata) ? message.metadata : JSON.stringify(message.metadata) : '').setForwardingMessageId(message.forwardingDetails ? message.forwardingDetails.messageId : message.id).setPollDetails(pollDetails);
19393
19454
  messageToSend = messageBuilder.create();
19394
19455
  pendingMessage = _extends({}, messageToSend, {
19395
19456
  createdAt: new Date(Date.now())
package/index.modern.js CHANGED
@@ -8998,7 +8998,8 @@ var handleVoteDetails = function handleVoteDetails(voteDetails, message) {
8998
8998
  var vote = voteDetails.vote;
8999
8999
  var optionId = vote.optionId;
9000
9000
  var currentVotesPerOption = existingVoteDetails.votesPerOption || {};
9001
- var newVotesPerOption = _extends({}, currentVotesPerOption, (_extends2 = {}, _extends2[optionId] = (currentVotesPerOption[optionId] || 0) + voteDetails.incrementVotesPerOptionCount, _extends2));
9001
+ var optionVotesCount = (currentVotesPerOption[optionId] || 0) + voteDetails.incrementVotesPerOptionCount;
9002
+ var newVotesPerOption = _extends({}, currentVotesPerOption, (_extends2 = {}, _extends2[optionId] = optionVotesCount >= 0 ? optionVotesCount : 0, _extends2));
9002
9003
  var newVotes = existingVoteDetails.votes || [];
9003
9004
  var newOwnVotes = existingVoteDetails.ownVotes || [];
9004
9005
  if (voteDetails.type === 'add') {
@@ -10883,7 +10884,7 @@ function updateMessageOnMap(channelId, updatedMessage, voteDetails) {
10883
10884
  } else {
10884
10885
  var statusUpdatedMessage = updateMessageDeliveryStatusAndMarkers(mes, updatedMessage.params.deliveryStatus);
10885
10886
  updatedMessageData = _extends({}, mes, updatedMessage.params, statusUpdatedMessage);
10886
- var voteDetailsData = void 0;
10887
+ var voteDetailsData = mes === null || mes === void 0 ? void 0 : mes.pollDetails;
10887
10888
  if (voteDetails) {
10888
10889
  voteDetailsData = handleVoteDetails(voteDetails, updatedMessageData);
10889
10890
  }
@@ -15267,7 +15268,7 @@ function watchForEvents() {
15267
15268
  objs.push({
15268
15269
  type: vote.user.id === SceytChatClient.user.id ? 'deleteOwn' : 'delete',
15269
15270
  vote: vote,
15270
- incrementVotesPerOptionCount: -((deletedVotes === null || deletedVotes === void 0 ? void 0 : deletedVotes.length) || 0)
15271
+ incrementVotesPerOptionCount: -1
15271
15272
  });
15272
15273
  }
15273
15274
  for (_iterator3 = _createForOfIteratorHelperLoose(addedVotes); !(_step3 = _iterator3()).done;) {
@@ -15275,7 +15276,7 @@ function watchForEvents() {
15275
15276
  objs.push({
15276
15277
  type: _vote.user.id === SceytChatClient.user.id ? 'addOwn' : 'add',
15277
15278
  vote: _vote,
15278
- incrementVotesPerOptionCount: (addedVotes === null || addedVotes === void 0 ? void 0 : addedVotes.length) || 0
15279
+ incrementVotesPerOptionCount: 1
15279
15280
  });
15280
15281
  }
15281
15282
  _i = 0, _objs = objs;
@@ -15350,7 +15351,7 @@ function watchForEvents() {
15350
15351
  _objs3.push({
15351
15352
  type: _vote2.user.id === SceytChatClient.user.id ? 'deleteOwn' : 'delete',
15352
15353
  vote: _vote2,
15353
- incrementVotesPerOptionCount: -((_deletedVotes === null || _deletedVotes === void 0 ? void 0 : _deletedVotes.length) || 0)
15354
+ incrementVotesPerOptionCount: -1
15354
15355
  });
15355
15356
  }
15356
15357
  _i3 = 0, _objs4 = _objs3;
@@ -15409,7 +15410,7 @@ function watchForEvents() {
15409
15410
  _objs6.push({
15410
15411
  type: _vote4.user.id === SceytChatClient.user.id ? 'deleteOwn' : 'delete',
15411
15412
  vote: _vote4,
15412
- incrementVotesPerOptionCount: -((retractedVotes === null || retractedVotes === void 0 ? void 0 : retractedVotes.length) || 0)
15413
+ incrementVotesPerOptionCount: -1
15413
15414
  });
15414
15415
  }
15415
15416
  _i5 = 0, _objs7 = _objs6;
@@ -16063,25 +16064,31 @@ function createChannel(action) {
16063
16064
  }, _marked$2, null, [[0, 17]]);
16064
16065
  }
16065
16066
  function getChannels(action) {
16066
- var _params$filter, _types, payload, params, SceytChatClient, channelQueryBuilder, channelTypesFilter, types, channelQuery, channelsData, channelList, channelId, activeChannel, _yield$call, mappedChannels, channelsForUpdateLastReactionMessage, channelMessageMap, hiddenList, allChannelsQueryBuilder, allChannelsQuery, hasNext, i, allChannelsData, allChannelList, _t2, _t3, _t4;
16067
+ 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, allChannelsData, allChannelList, _t2, _t3, _t4;
16067
16068
  return _regenerator().w(function (_context2) {
16068
16069
  while (1) switch (_context2.p = _context2.n) {
16069
16070
  case 0:
16070
- _context2.p = 0;
16071
+ log.info('[getChannels] start get channels');
16072
+ _context2.p = 1;
16071
16073
  payload = action.payload;
16072
16074
  params = payload.params;
16075
+ log.info('[getChannels] input params:', JSON.stringify(params));
16073
16076
  SceytChatClient = getClient();
16074
- if (!(store.getState().UserReducer.connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
16075
- _context2.n = 1;
16077
+ connectionStatus = store.getState().UserReducer.connectionStatus;
16078
+ log.info('[getChannels] connection status:', connectionStatus);
16079
+ if (!(connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
16080
+ _context2.n = 2;
16076
16081
  break;
16077
16082
  }
16083
+ log.warn('[getChannels] connection not ready, aborting. Status:', connectionStatus);
16078
16084
  return _context2.a(2);
16079
- case 1:
16080
- _context2.n = 2;
16081
- return put(setChannelsLoadingStateAC(LOADING_STATE.LOADING));
16082
16085
  case 2:
16086
+ _context2.n = 3;
16087
+ return put(setChannelsLoadingStateAC(LOADING_STATE.LOADING));
16088
+ case 3:
16083
16089
  channelQueryBuilder = new SceytChatClient.ChannelListQueryBuilder();
16084
16090
  channelTypesFilter = getChannelTypesFilter();
16091
+ log.info('[getChannels] channelTypesFilter:', JSON.stringify(channelTypesFilter));
16085
16092
  types = [];
16086
16093
  if (channelTypesFilter !== null && channelTypesFilter !== void 0 && channelTypesFilter.length) {
16087
16094
  types = channelTypesFilter;
@@ -16089,59 +16096,77 @@ function getChannels(action) {
16089
16096
  if (params !== null && params !== void 0 && (_params$filter = params.filter) !== null && _params$filter !== void 0 && _params$filter.channelType) {
16090
16097
  types.push(params.filter.channelType);
16091
16098
  }
16099
+ log.info('[getChannels] final types array:', JSON.stringify(types));
16092
16100
  if ((_types = types) !== null && _types !== void 0 && _types.length) {
16093
16101
  channelQueryBuilder.types(types);
16094
16102
  }
16095
16103
  if (params.memberCount) {
16104
+ log.info('[getChannels] setting memberCount filter:', params === null || params === void 0 ? void 0 : params.memberCount);
16096
16105
  channelQueryBuilder.memberCount(params.memberCount);
16097
16106
  }
16098
16107
  channelQueryBuilder.order('lastMessage');
16099
- channelQueryBuilder.limit(params.limit || 50);
16100
- _context2.n = 3;
16108
+ limit = params.limit || 50;
16109
+ log.info('[getChannels] query limit:', limit);
16110
+ channelQueryBuilder.limit(limit);
16111
+ _context2.n = 4;
16101
16112
  return call(channelQueryBuilder.build);
16102
- case 3:
16113
+ case 4:
16103
16114
  channelQuery = _context2.v;
16104
- _context2.n = 4;
16115
+ log.info('[getChannels] query built successfully');
16116
+ _context2.n = 5;
16105
16117
  return call(channelQuery.loadNextPage);
16106
- case 4:
16118
+ case 5:
16107
16119
  channelsData = _context2.v;
16108
16120
  channelList = channelsData.channels;
16109
- _context2.n = 5;
16110
- return put(channelHasNextAC(channelsData.hasNext));
16111
- case 5:
16121
+ log.info('[getChannels] channelsData received:', JSON.stringify({
16122
+ channelsCount: (channelList === null || channelList === void 0 ? void 0 : channelList.length) || 0,
16123
+ hasNext: channelsData.hasNext
16124
+ }));
16112
16125
  _context2.n = 6;
16113
- return call(getActiveChannelId);
16126
+ return put(channelHasNextAC(channelsData.hasNext));
16114
16127
  case 6:
16128
+ _context2.n = 7;
16129
+ return call(getActiveChannelId);
16130
+ case 7:
16115
16131
  channelId = _context2.v;
16132
+ log.info('[getChannels] active channelId:', channelId);
16116
16133
  if (!channelId) {
16117
- _context2.n = 8;
16134
+ _context2.n = 9;
16118
16135
  break;
16119
16136
  }
16120
- _context2.n = 7;
16137
+ _context2.n = 8;
16121
16138
  return call(getChannelFromMap, channelId);
16122
- case 7:
16139
+ case 8:
16123
16140
  _t2 = _context2.v;
16124
- _context2.n = 9;
16141
+ _context2.n = 10;
16125
16142
  break;
16126
- case 8:
16127
- _t2 = null;
16128
16143
  case 9:
16129
- activeChannel = _t2;
16130
- _context2.n = 10;
16131
- return call(destroyChannelsMap);
16144
+ _t2 = null;
16132
16145
  case 10:
16146
+ activeChannel = _t2;
16147
+ log.info('[getChannels] activeChannel from map:', activeChannel ? (_activeChannel = activeChannel) === null || _activeChannel === void 0 ? void 0 : _activeChannel.id : 'null');
16133
16148
  _context2.n = 11;
16134
- return call(setChannelsInMap, channelList);
16149
+ return call(destroyChannelsMap);
16135
16150
  case 11:
16151
+ log.info('[getChannels] channels map destroyed');
16152
+ _context2.n = 12;
16153
+ return call(setChannelsInMap, channelList);
16154
+ case 12:
16136
16155
  _yield$call = _context2.v;
16137
16156
  mappedChannels = _yield$call.channels;
16138
16157
  channelsForUpdateLastReactionMessage = _yield$call.channelsForUpdateLastReactionMessage;
16139
- if (!channelsForUpdateLastReactionMessage.length) {
16140
- _context2.n = 13;
16158
+ log.info('[getChannels] setChannelsInMap result:', JSON.stringify({
16159
+ mappedChannelsCount: ((_mappedChannels = mappedChannels) === null || _mappedChannels === void 0 ? void 0 : _mappedChannels.length) || 0,
16160
+ channelsForUpdateLastReactionMessageCount: (channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length) || 0
16161
+ }));
16162
+ log.info('channelsForUpdateLastReactionMessage', channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length);
16163
+ if (!(channelsForUpdateLastReactionMessage !== null && channelsForUpdateLastReactionMessage !== void 0 && channelsForUpdateLastReactionMessage.length)) {
16164
+ _context2.n = 14;
16141
16165
  break;
16142
16166
  }
16167
+ log.info('[getChannels] processing channels for reaction message update:', channelsForUpdateLastReactionMessage === null || channelsForUpdateLastReactionMessage === void 0 ? void 0 : channelsForUpdateLastReactionMessage.length);
16143
16168
  channelMessageMap = {};
16144
- _context2.n = 12;
16169
+ _context2.n = 13;
16145
16170
  return call(function () {
16146
16171
  try {
16147
16172
  return Promise.resolve(Promise.all(channelsForUpdateLastReactionMessage.map(function (channel) {
@@ -16149,9 +16174,10 @@ function getChannels(action) {
16149
16174
  return Promise.resolve(new Promise(function (resolve) {
16150
16175
  channel.getMessagesById([channel.newReactions[0].messageId]).then(function (messages) {
16151
16176
  channelMessageMap[channel.id] = messages[0];
16177
+ log.info('[getChannels] successfully fetched reaction message for channel:', channel === null || channel === void 0 ? void 0 : channel.id);
16152
16178
  resolve(true);
16153
16179
  })["catch"](function (e) {
16154
- log.error(e, 'Error on getMessagesById');
16180
+ log.error(e, 'Error on getMessagesById for channel:', channel === null || channel === void 0 ? void 0 : channel.id);
16155
16181
  resolve(true);
16156
16182
  });
16157
16183
  }));
@@ -16163,89 +16189,124 @@ function getChannels(action) {
16163
16189
  return Promise.reject(e);
16164
16190
  }
16165
16191
  });
16166
- case 12:
16192
+ case 13:
16193
+ log.info('[getChannels] reaction messages fetched:', channelMessageMap ? (_Object$keys = Object.keys(channelMessageMap)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length : 0);
16167
16194
  mappedChannels = mappedChannels.map(function (channel) {
16168
16195
  if (channelMessageMap[channel.id]) {
16169
16196
  channel.lastReactedMessage = channelMessageMap[channel.id];
16170
16197
  }
16171
16198
  return channel;
16172
16199
  });
16173
- case 13:
16174
- _context2.n = 14;
16175
- return put(setChannelsAC(mappedChannels));
16200
+ log.info('[getChannels] mappedChannels updated with reaction messages, final count:', ((_mappedChannels2 = mappedChannels) === null || _mappedChannels2 === void 0 ? void 0 : _mappedChannels2.length) || 0);
16176
16201
  case 14:
16202
+ log.info('[getChannels] setting channels in state, count:', ((_mappedChannels3 = mappedChannels) === null || _mappedChannels3 === void 0 ? void 0 : _mappedChannels3.length) || 0);
16203
+ _context2.n = 15;
16204
+ return put(setChannelsAC(mappedChannels));
16205
+ case 15:
16177
16206
  if (!channelId) {
16178
16207
  activeChannel = channelList[0];
16208
+ log.info('[getChannels] no active channelId, setting first channel as active:', (_activeChannel2 = activeChannel) === null || _activeChannel2 === void 0 ? void 0 : _activeChannel2.id);
16179
16209
  }
16180
16210
  query.channelQuery = channelQuery;
16181
16211
  if (!(activeChannel && getAutoSelectFitsChannel())) {
16182
- _context2.n = 15;
16212
+ _context2.n = 16;
16183
16213
  break;
16184
16214
  }
16185
- _context2.n = 15;
16186
- return put(switchChannelActionAC(JSON.parse(JSON.stringify(activeChannel))));
16187
- case 15:
16215
+ log.info('[getChannels] auto-selecting channel:', (_activeChannel3 = activeChannel) === null || _activeChannel3 === void 0 ? void 0 : _activeChannel3.id);
16188
16216
  _context2.n = 16;
16189
- return put(setChannelsLoadingStateAC(LOADING_STATE.LOADED));
16217
+ return put(switchChannelActionAC(JSON.parse(JSON.stringify(activeChannel))));
16190
16218
  case 16:
16219
+ _context2.n = 17;
16220
+ return put(setChannelsLoadingStateAC(LOADING_STATE.LOADED));
16221
+ case 17:
16191
16222
  hiddenList = store.getState().ChannelReducer.hideChannelList;
16223
+ log.info('[getChannels] hiddenList state:', hiddenList);
16192
16224
  if (hiddenList) {
16193
- _context2.n = 23;
16225
+ _context2.n = 27;
16194
16226
  break;
16195
16227
  }
16228
+ log.info('[getChannels] starting all channels query (hiddenList is false)');
16196
16229
  allChannelsQueryBuilder = new SceytChatClient.ChannelListQueryBuilder();
16197
16230
  allChannelsQueryBuilder.order('lastMessage');
16198
16231
  if (channelTypesFilter !== null && channelTypesFilter !== void 0 && channelTypesFilter.length) {
16199
16232
  allChannelsQueryBuilder.types(channelTypesFilter);
16233
+ log.info('[getChannels] allChannelsQuery types:', JSON.stringify(channelTypesFilter));
16200
16234
  }
16201
16235
  if (params !== null && params !== void 0 && params.memberCount) {
16202
16236
  allChannelsQueryBuilder.memberCount(params.memberCount);
16237
+ log.info('[getChannels] allChannelsQuery memberCount:', params === null || params === void 0 ? void 0 : params.memberCount);
16203
16238
  }
16204
16239
  allChannelsQueryBuilder.limit(50);
16205
- _context2.n = 17;
16240
+ _context2.n = 18;
16206
16241
  return call(allChannelsQueryBuilder.build);
16207
- case 17:
16242
+ case 18:
16208
16243
  allChannelsQuery = _context2.v;
16244
+ log.info('[getChannels] allChannelsQuery built');
16209
16245
  hasNext = true;
16246
+ totalAllChannelsAdded = 0;
16210
16247
  i = 0;
16211
- case 18:
16248
+ case 19:
16212
16249
  if (!(i <= 4)) {
16213
- _context2.n = 23;
16250
+ _context2.n = 26;
16214
16251
  break;
16215
16252
  }
16216
16253
  if (!hasNext) {
16217
- _context2.n = 22;
16254
+ _context2.n = 24;
16218
16255
  break;
16219
16256
  }
16220
- _context2.p = 19;
16221
- _context2.n = 20;
16257
+ _context2.p = 20;
16258
+ log.info('[getChannels] loading all channels page:', i + 1);
16259
+ _context2.n = 21;
16222
16260
  return call(allChannelsQuery.loadNextPage);
16223
- case 20:
16261
+ case 21:
16224
16262
  allChannelsData = _context2.v;
16225
16263
  hasNext = allChannelsData.hasNext;
16226
16264
  allChannelList = allChannelsData.channels;
16265
+ log.info('[getChannels] all channels page', i + 1, 'loaded:', JSON.stringify({
16266
+ channelsCount: (allChannelList === null || allChannelList === void 0 ? void 0 : allChannelList.length) || 0,
16267
+ hasNext: hasNext
16268
+ }));
16227
16269
  addChannelsToAllChannels(allChannelList);
16228
- _context2.n = 22;
16270
+ totalAllChannelsAdded += (allChannelList === null || allChannelList === void 0 ? void 0 : allChannelList.length) || 0;
16271
+ log.info('[getChannels] total all channels added so far:', totalAllChannelsAdded);
16272
+ _context2.n = 23;
16229
16273
  break;
16230
- case 21:
16231
- _context2.p = 21;
16232
- _t3 = _context2.v;
16233
- log.error(_t3, 'Error on get all channels');
16234
16274
  case 22:
16235
- i++;
16236
- _context2.n = 18;
16237
- break;
16275
+ _context2.p = 22;
16276
+ _t3 = _context2.v;
16277
+ log.error(_t3, 'Error on get all channels page:', i + 1);
16238
16278
  case 23:
16239
16279
  _context2.n = 25;
16240
16280
  break;
16241
16281
  case 24:
16242
- _context2.p = 24;
16243
- _t4 = _context2.v;
16244
- log.error(JSON.stringify(_t4), 'Error on get channels');
16282
+ log.info('[getChannels] no more pages available, stopping at iteration:', i);
16245
16283
  case 25:
16284
+ i++;
16285
+ _context2.n = 19;
16286
+ break;
16287
+ case 26:
16288
+ log.info('[getChannels] all channels query completed, total channels added:', totalAllChannelsAdded);
16289
+ _context2.n = 28;
16290
+ break;
16291
+ case 27:
16292
+ log.info('[getChannels] skipping all channels query (hiddenList is true)');
16293
+ case 28:
16294
+ log.info('[getChannels] completed successfully. Final mapped channels count:', ((_mappedChannels4 = mappedChannels) === null || _mappedChannels4 === void 0 ? void 0 : _mappedChannels4.length) || 0);
16295
+ _context2.n = 30;
16296
+ break;
16297
+ case 29:
16298
+ _context2.p = 29;
16299
+ _t4 = _context2.v;
16300
+ log.error('[getChannels] error occurred:', JSON.stringify(_t4), 'Error on get channels');
16301
+ log.error('[getChannels] error details:', {
16302
+ message: _t4.message,
16303
+ code: _t4.code,
16304
+ stack: _t4.stack
16305
+ });
16306
+ case 30:
16246
16307
  return _context2.a(2);
16247
16308
  }
16248
- }, _marked2$1, null, [[19, 21], [0, 24]]);
16309
+ }, _marked2$1, null, [[20, 22], [1, 29]]);
16249
16310
  }
16250
16311
  function searchChannels(action) {
16251
16312
  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;
@@ -19388,7 +19449,7 @@ function forwardMessage(action) {
19388
19449
  allowVoteRetract: message.pollDetails.allowVoteRetract
19389
19450
  };
19390
19451
  }
19391
- messageBuilder.setBody(message.body).setBodyAttributes(message.bodyAttributes).setAttachments(attachments).setMentionUserIds(mentionedUserIds).setType(message.type).setDisableMentionsCount(getDisableFrowardMentionsCount()).setMetadata(message.metadata ? JSON.stringify(message.metadata) : '').setForwardingMessageId(message.forwardingDetails ? message.forwardingDetails.messageId : message.id).setPollDetails(pollDetails);
19452
+ messageBuilder.setBody(message.body).setBodyAttributes(message.bodyAttributes).setAttachments(attachments).setMentionUserIds(mentionedUserIds).setType(message.type).setDisableMentionsCount(getDisableFrowardMentionsCount()).setMetadata(message.metadata ? isJSON(message.metadata) ? message.metadata : JSON.stringify(message.metadata) : '').setForwardingMessageId(message.forwardingDetails ? message.forwardingDetails.messageId : message.id).setPollDetails(pollDetails);
19392
19453
  messageToSend = messageBuilder.create();
19393
19454
  pendingMessage = _extends({}, messageToSend, {
19394
19455
  createdAt: new Date(Date.now())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.7.7-beta.1",
3
+ "version": "1.7.7-beta.3",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",