sceyt-chat-react-uikit 1.8.8-beta.18 → 1.8.8-beta.19

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 +445 -235
  2. package/index.modern.js +445 -235
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -12121,9 +12121,20 @@ function getLatestMessagesFromMap(channelId, limit) {
12121
12121
  return !!m.id || m.tid;
12122
12122
  }).sort(compareMessagesForList).slice(-limit);
12123
12123
  }
12124
- function getLatestCachedConfirmedMessageId(channelId) {
12124
+ function getLatestContiguousMessagesFromMap(channelId, limit) {
12125
12125
  var _loadedSegmentsMap$ch;
12126
12126
  var latestSegment = (_loadedSegmentsMap$ch = loadedSegmentsMap[channelId]) === null || _loadedSegmentsMap$ch === void 0 ? void 0 : _loadedSegmentsMap$ch.at(-1);
12127
+ var messages = Object.values(messagesMap[channelId] || {}).filter(function (m) {
12128
+ return !!m.id || m.tid;
12129
+ });
12130
+ var contiguousMessages = latestSegment ? messages.filter(function (m) {
12131
+ return !m.id || compareMessageIds(m.id, latestSegment.startId) >= 0 && compareMessageIds(m.id, latestSegment.endId) <= 0;
12132
+ }) : messages;
12133
+ return contiguousMessages.sort(compareMessagesForList).slice(-limit);
12134
+ }
12135
+ function getLatestCachedConfirmedMessageId(channelId) {
12136
+ var _loadedSegmentsMap$ch2;
12137
+ var latestSegment = (_loadedSegmentsMap$ch2 = loadedSegmentsMap[channelId]) === null || _loadedSegmentsMap$ch2 === void 0 ? void 0 : _loadedSegmentsMap$ch2.at(-1);
12127
12138
  if (latestSegment !== null && latestSegment !== void 0 && latestSegment.endId) {
12128
12139
  return latestSegment.endId;
12129
12140
  }
@@ -19494,7 +19505,7 @@ function loadDefaultMessages(action) {
19494
19505
  case 4:
19495
19506
  messageQuery = _t24;
19496
19507
  query.messageQuery = messageQuery;
19497
- cachedMessages = getLatestMessagesFromMap(channel.id, MESSAGES_MAX_PAGE_COUNT);
19508
+ cachedMessages = getLatestContiguousMessagesFromMap(channel.id, MESSAGES_MAX_PAGE_COUNT);
19498
19509
  if (!(cachedMessages && cachedMessages.length)) {
19499
19510
  _context32.n = 9;
19500
19511
  break;
@@ -19798,7 +19809,7 @@ function getMessagesQuery(action) {
19798
19809
  _context33.n = 22;
19799
19810
  break;
19800
19811
  case 17:
19801
- cachedMessages = getLatestMessagesFromMap(channel.id, MESSAGES_MAX_PAGE_COUNT);
19812
+ cachedMessages = getLatestContiguousMessagesFromMap(channel.id, MESSAGES_MAX_PAGE_COUNT);
19802
19813
  cacheIsCurrent = !networkChanged && cachedMessages.length > 0 && getLastConfirmedMessageId(cachedMessages) === ((_channel$lastMessage1 = channel.lastMessage) === null || _channel$lastMessage1 === void 0 ? void 0 : _channel$lastMessage1.id);
19803
19814
  if (!cacheIsCurrent) {
19804
19815
  _context33.n = 18;
@@ -25374,52 +25385,81 @@ function watchForEvents() {
25374
25385
  }, _marked8$1);
25375
25386
  }
25376
25387
 
25388
+ var READ_MESSAGE_LOG_KEY_ALIASES = {
25389
+ source: 's',
25390
+ channelId: 'ch',
25391
+ readAll: 'ra',
25392
+ messageIds: 'mi',
25393
+ messageId: 'm',
25394
+ connectionStatus: 'cs',
25395
+ attempts: 'at',
25396
+ retryDelayMs: 'rd',
25397
+ requestedMessageIds: 'rq',
25398
+ confirmedMessageIds: 'cf',
25399
+ isVisible: 'iv',
25400
+ alreadyRead: 'ar',
25401
+ disableAutoReadTracking: 'da',
25402
+ isTabActive: 'ta',
25403
+ newMessageCount: 'nm',
25404
+ queued: 'q',
25405
+ localRef: 'lr',
25406
+ visibleCandidateIds: 'vc',
25407
+ unreadScrollTo: 'us',
25408
+ pendingFrameScheduled: 'pf'
25409
+ };
25410
+ var compactReadMessageLogData = function compactReadMessageLogData(data) {
25411
+ return JSON.stringify(Object.fromEntries(Object.entries(data).map(function (_ref) {
25412
+ var key = _ref[0],
25413
+ value = _ref[1];
25414
+ return [READ_MESSAGE_LOG_KEY_ALIASES[key] || key.slice(0, 2), value];
25415
+ })));
25416
+ };
25417
+
25377
25418
  var _marked$3 = /*#__PURE__*/_regenerator().m(applyChannelReadProgress),
25378
- _marked2$3 = /*#__PURE__*/_regenerator().m(confirmDisplayedRead),
25379
- _marked3$2 = /*#__PURE__*/_regenerator().m(createChannel),
25380
- _marked4$2 = /*#__PURE__*/_regenerator().m(getChannels),
25381
- _marked5$2 = /*#__PURE__*/_regenerator().m(searchChannels),
25382
- _marked6$2 = /*#__PURE__*/_regenerator().m(getChannelsForForward),
25383
- _marked7$2 = /*#__PURE__*/_regenerator().m(searchChannelsForForward),
25384
- _marked8$2 = /*#__PURE__*/_regenerator().m(channelsLoadMore),
25385
- _marked9$1 = /*#__PURE__*/_regenerator().m(getChannelMentions),
25386
- _marked0$1 = /*#__PURE__*/_regenerator().m(channelsForForwardLoadMore),
25387
- _marked1$1 = /*#__PURE__*/_regenerator().m(markMessagesRead),
25388
- _marked10$1 = /*#__PURE__*/_regenerator().m(markVoiceMessageAsPlayed),
25389
- _marked11$1 = /*#__PURE__*/_regenerator().m(updateMessageAsOpened),
25390
- _marked12$1 = /*#__PURE__*/_regenerator().m(markMessageAsOpened),
25391
- _marked13$1 = /*#__PURE__*/_regenerator().m(markMessagesDelivered),
25392
- _marked14$1 = /*#__PURE__*/_regenerator().m(switchChannel),
25393
- _marked15$1 = /*#__PURE__*/_regenerator().m(notificationsTurnOff),
25394
- _marked16$1 = /*#__PURE__*/_regenerator().m(notificationsTurnOn),
25395
- _marked17$1 = /*#__PURE__*/_regenerator().m(markChannelAsRead),
25396
- _marked18$1 = /*#__PURE__*/_regenerator().m(resendPendingChannelReads),
25397
- _marked19$1 = /*#__PURE__*/_regenerator().m(markChannelAsUnRead),
25398
- _marked20$1 = /*#__PURE__*/_regenerator().m(pinChannel),
25399
- _marked21$1 = /*#__PURE__*/_regenerator().m(unpinChannel),
25400
- _marked22$1 = /*#__PURE__*/_regenerator().m(removeChannelCaches),
25401
- _marked23$1 = /*#__PURE__*/_regenerator().m(leaveChannel),
25402
- _marked24$1 = /*#__PURE__*/_regenerator().m(deletePendingDeleteChannels),
25403
- _marked25$1 = /*#__PURE__*/_regenerator().m(deleteChannel),
25404
- _marked26$1 = /*#__PURE__*/_regenerator().m(blockChannel),
25405
- _marked27$1 = /*#__PURE__*/_regenerator().m(updateChannel),
25406
- _marked28$1 = /*#__PURE__*/_regenerator().m(checkUsersStatus),
25407
- _marked29$1 = /*#__PURE__*/_regenerator().m(sendTyping),
25408
- _marked30$1 = /*#__PURE__*/_regenerator().m(sendRecording),
25409
- _marked31$1 = /*#__PURE__*/_regenerator().m(clearHistory),
25410
- _marked32$1 = /*#__PURE__*/_regenerator().m(deleteAllMessages),
25411
- _marked33$1 = /*#__PURE__*/_regenerator().m(joinChannel),
25412
- _marked34$1 = /*#__PURE__*/_regenerator().m(watchForChannelEvents),
25413
- _marked35$1 = /*#__PURE__*/_regenerator().m(createChannelInviteKey),
25414
- _marked36$1 = /*#__PURE__*/_regenerator().m(getChannelInviteKeys),
25415
- _marked37$1 = /*#__PURE__*/_regenerator().m(regenerateChannelInviteKey),
25416
- _marked38$1 = /*#__PURE__*/_regenerator().m(updateChannelInviteKey),
25417
- _marked39$1 = /*#__PURE__*/_regenerator().m(getChannelByInviteKey),
25418
- _marked40$1 = /*#__PURE__*/_regenerator().m(joinChannelWithInviteKey),
25419
- _marked41$1 = /*#__PURE__*/_regenerator().m(setMessageRetentionPeriod),
25420
- _marked42$1 = /*#__PURE__*/_regenerator().m(getChannelsWithUser),
25421
- _marked43$1 = /*#__PURE__*/_regenerator().m(loadMoreMutualChannels),
25422
- _marked44$1 = /*#__PURE__*/_regenerator().m(ChannelsSaga);
25419
+ _marked2$3 = /*#__PURE__*/_regenerator().m(createChannel),
25420
+ _marked3$2 = /*#__PURE__*/_regenerator().m(getChannels),
25421
+ _marked4$2 = /*#__PURE__*/_regenerator().m(searchChannels),
25422
+ _marked5$2 = /*#__PURE__*/_regenerator().m(getChannelsForForward),
25423
+ _marked6$2 = /*#__PURE__*/_regenerator().m(searchChannelsForForward),
25424
+ _marked7$2 = /*#__PURE__*/_regenerator().m(channelsLoadMore),
25425
+ _marked8$2 = /*#__PURE__*/_regenerator().m(getChannelMentions),
25426
+ _marked9$1 = /*#__PURE__*/_regenerator().m(channelsForForwardLoadMore),
25427
+ _marked0$1 = /*#__PURE__*/_regenerator().m(markMessagesRead),
25428
+ _marked1$1 = /*#__PURE__*/_regenerator().m(markVoiceMessageAsPlayed),
25429
+ _marked10$1 = /*#__PURE__*/_regenerator().m(updateMessageAsOpened),
25430
+ _marked11$1 = /*#__PURE__*/_regenerator().m(markMessageAsOpened),
25431
+ _marked12$1 = /*#__PURE__*/_regenerator().m(markMessagesDelivered),
25432
+ _marked13$1 = /*#__PURE__*/_regenerator().m(switchChannel),
25433
+ _marked14$1 = /*#__PURE__*/_regenerator().m(notificationsTurnOff),
25434
+ _marked15$1 = /*#__PURE__*/_regenerator().m(notificationsTurnOn),
25435
+ _marked16$1 = /*#__PURE__*/_regenerator().m(markChannelAsRead),
25436
+ _marked17$1 = /*#__PURE__*/_regenerator().m(resendPendingChannelReads),
25437
+ _marked18$1 = /*#__PURE__*/_regenerator().m(markChannelAsUnRead),
25438
+ _marked19$1 = /*#__PURE__*/_regenerator().m(pinChannel),
25439
+ _marked20$1 = /*#__PURE__*/_regenerator().m(unpinChannel),
25440
+ _marked21$1 = /*#__PURE__*/_regenerator().m(removeChannelCaches),
25441
+ _marked22$1 = /*#__PURE__*/_regenerator().m(leaveChannel),
25442
+ _marked23$1 = /*#__PURE__*/_regenerator().m(deletePendingDeleteChannels),
25443
+ _marked24$1 = /*#__PURE__*/_regenerator().m(deleteChannel),
25444
+ _marked25$1 = /*#__PURE__*/_regenerator().m(blockChannel),
25445
+ _marked26$1 = /*#__PURE__*/_regenerator().m(updateChannel),
25446
+ _marked27$1 = /*#__PURE__*/_regenerator().m(checkUsersStatus),
25447
+ _marked28$1 = /*#__PURE__*/_regenerator().m(sendTyping),
25448
+ _marked29$1 = /*#__PURE__*/_regenerator().m(sendRecording),
25449
+ _marked30$1 = /*#__PURE__*/_regenerator().m(clearHistory),
25450
+ _marked31$1 = /*#__PURE__*/_regenerator().m(deleteAllMessages),
25451
+ _marked32$1 = /*#__PURE__*/_regenerator().m(joinChannel),
25452
+ _marked33$1 = /*#__PURE__*/_regenerator().m(watchForChannelEvents),
25453
+ _marked34$1 = /*#__PURE__*/_regenerator().m(createChannelInviteKey),
25454
+ _marked35$1 = /*#__PURE__*/_regenerator().m(getChannelInviteKeys),
25455
+ _marked36$1 = /*#__PURE__*/_regenerator().m(regenerateChannelInviteKey),
25456
+ _marked37$1 = /*#__PURE__*/_regenerator().m(updateChannelInviteKey),
25457
+ _marked38$1 = /*#__PURE__*/_regenerator().m(getChannelByInviteKey),
25458
+ _marked39$1 = /*#__PURE__*/_regenerator().m(joinChannelWithInviteKey),
25459
+ _marked40$1 = /*#__PURE__*/_regenerator().m(setMessageRetentionPeriod),
25460
+ _marked41$1 = /*#__PURE__*/_regenerator().m(getChannelsWithUser),
25461
+ _marked42$1 = /*#__PURE__*/_regenerator().m(loadMoreMutualChannels),
25462
+ _marked43$1 = /*#__PURE__*/_regenerator().m(ChannelsSaga);
25423
25463
  var getUniqueMessageIds = function getUniqueMessageIds(messageIds) {
25424
25464
  if (messageIds === void 0) {
25425
25465
  messageIds = [];
@@ -25521,80 +25561,104 @@ function applyChannelReadProgress(channelId, updateData) {
25521
25561
  var shouldKeepQueuedPendingRead = function shouldKeepQueuedPendingRead(error) {
25522
25562
  return isResendableError(error === null || error === void 0 ? void 0 : error.type);
25523
25563
  };
25524
- function confirmDisplayedRead(channel, pendingRead) {
25525
- var messageIds, attempt, connectionStatus, messageListMarker, _t;
25526
- return _regenerator().w(function (_context2) {
25527
- while (1) switch (_context2.p = _context2.n) {
25528
- case 0:
25529
- messageIds = getUniqueMessageIds(pendingRead.messageIds);
25530
- attempt = 0;
25531
- case 1:
25532
- if (!(attempt <= READ_MARKER_RETRY_DELAYS_MS.length)) {
25533
- _context2.n = 10;
25534
- break;
25535
- }
25536
- connectionStatus = store.getState().UserReducer.connectionStatus;
25537
- if (!(connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
25538
- _context2.n = 2;
25539
- break;
25540
- }
25541
- return _context2.a(2, {
25542
- status: 'queued'
25543
- });
25544
- case 2:
25545
- _context2.p = 2;
25546
- if (!pendingRead.readAll) {
25547
- _context2.n = 4;
25548
- break;
25549
- }
25550
- _context2.n = 3;
25551
- return effects.call(channel.markAsRead);
25552
- case 3:
25553
- return _context2.a(2, {
25554
- status: 'success'
25555
- });
25556
- case 4:
25557
- _context2.n = 5;
25558
- return effects.call(channel.markMessagesAsDisplayed, messageIds);
25559
- case 5:
25560
- messageListMarker = _context2.v;
25561
- return _context2.a(2, {
25562
- status: 'success',
25563
- messageListMarker: messageListMarker
25564
- });
25565
- case 6:
25566
- _context2.p = 6;
25567
- _t = _context2.v;
25568
- if (shouldKeepQueuedPendingRead(_t)) {
25569
- _context2.n = 7;
25570
- break;
25571
- }
25572
- return _context2.a(2, {
25573
- status: 'drop',
25574
- error: _t
25575
- });
25576
- case 7:
25577
- if (!(attempt === READ_MARKER_RETRY_DELAYS_MS.length)) {
25578
- _context2.n = 8;
25564
+ var getReadMarkerLogContext = function getReadMarkerLogContext(pendingRead, source, messageIds) {
25565
+ return {
25566
+ source: source,
25567
+ channelId: pendingRead.channelId,
25568
+ readAll: pendingRead.readAll,
25569
+ messageIds: messageIds
25570
+ };
25571
+ };
25572
+ function confirmDisplayedRead(channel, pendingRead, source) {
25573
+ if (source === void 0) {
25574
+ source = 'initial';
25575
+ }
25576
+ return /*#__PURE__*/_regenerator().m(function _callee() {
25577
+ var messageIds, logContext, attempt, connectionStatus, messageListMarker, _t;
25578
+ return _regenerator().w(function (_context2) {
25579
+ while (1) switch (_context2.p = _context2.n) {
25580
+ case 0:
25581
+ messageIds = getUniqueMessageIds(pendingRead.messageIds);
25582
+ logContext = getReadMarkerLogContext(pendingRead, source, messageIds);
25583
+ attempt = 0;
25584
+ case 1:
25585
+ if (!(attempt <= READ_MARKER_RETRY_DELAYS_MS.length)) {
25586
+ _context2.n = 10;
25587
+ break;
25588
+ }
25589
+ connectionStatus = store.getState().UserReducer.connectionStatus;
25590
+ if (!(connectionStatus !== CONNECTION_STATUS.CONNECTED)) {
25591
+ _context2.n = 2;
25592
+ break;
25593
+ }
25594
+ log.warn('[READ_MESSAGE] Queued read marker because connection is not ready', compactReadMessageLogData(_extends({}, logContext, {
25595
+ connectionStatus: connectionStatus
25596
+ })));
25597
+ return _context2.a(2, {
25598
+ status: 'queued'
25599
+ });
25600
+ case 2:
25601
+ _context2.p = 2;
25602
+ if (!pendingRead.readAll) {
25603
+ _context2.n = 4;
25604
+ break;
25605
+ }
25606
+ _context2.n = 3;
25607
+ return effects.call(channel.markAsRead);
25608
+ case 3:
25609
+ return _context2.a(2, {
25610
+ status: 'success'
25611
+ });
25612
+ case 4:
25613
+ _context2.n = 5;
25614
+ return effects.call(channel.markMessagesAsDisplayed, messageIds);
25615
+ case 5:
25616
+ messageListMarker = _context2.v;
25617
+ return _context2.a(2, {
25618
+ status: 'success',
25619
+ messageListMarker: messageListMarker
25620
+ });
25621
+ case 6:
25622
+ _context2.p = 6;
25623
+ _t = _context2.v;
25624
+ if (shouldKeepQueuedPendingRead(_t)) {
25625
+ _context2.n = 7;
25626
+ break;
25627
+ }
25628
+ log.error(_t, '[READ_MESSAGE] Dropping read marker after non-resendable error', compactReadMessageLogData(logContext));
25629
+ return _context2.a(2, {
25630
+ status: 'drop',
25631
+ error: _t
25632
+ });
25633
+ case 7:
25634
+ if (!(attempt === READ_MARKER_RETRY_DELAYS_MS.length)) {
25635
+ _context2.n = 8;
25636
+ break;
25637
+ }
25638
+ log.error(_t, '[READ_MESSAGE] Exhausted read marker retries; keeping queued for replay', compactReadMessageLogData(_extends({}, logContext, {
25639
+ attempts: attempt + 1
25640
+ })));
25641
+ return _context2.a(2, {
25642
+ status: 'queued',
25643
+ error: _t
25644
+ });
25645
+ case 8:
25646
+ log.warn(_t, "[READ_MESSAGE] Retrying read marker (" + (attempt + 1) + "/" + READ_MARKER_RETRY_DELAYS_MS.length + ")", compactReadMessageLogData(_extends({}, logContext, {
25647
+ retryDelayMs: READ_MARKER_RETRY_DELAYS_MS[attempt]
25648
+ })));
25649
+ _context2.n = 9;
25650
+ return effects.call(waitForReadMarkerRetry, READ_MARKER_RETRY_DELAYS_MS[attempt]);
25651
+ case 9:
25652
+ attempt++;
25653
+ _context2.n = 1;
25579
25654
  break;
25580
- }
25581
- return _context2.a(2, {
25582
- status: 'queued',
25583
- error: _t
25584
- });
25585
- case 8:
25586
- _context2.n = 9;
25587
- return effects.call(waitForReadMarkerRetry, READ_MARKER_RETRY_DELAYS_MS[attempt]);
25588
- case 9:
25589
- attempt++;
25590
- _context2.n = 1;
25591
- break;
25592
- case 10:
25593
- return _context2.a(2, {
25594
- status: 'queued'
25595
- });
25596
- }
25597
- }, _marked2$3, null, [[2, 6]]);
25655
+ case 10:
25656
+ return _context2.a(2, {
25657
+ status: 'queued'
25658
+ });
25659
+ }
25660
+ }, _callee, null, [[2, 6]]);
25661
+ })();
25598
25662
  }
25599
25663
  function createChannel(action) {
25600
25664
  var payload, channelData, dontCreateIfNotExists, callback, SceytChatClient, createChannelData, fileToUpload, isSelfChannel, channelIsExistOnAllChannels, createdChannel, allChannels, memberId, whoDoesNotAdded, checkChannelExist, messageToSend, _allChannels, _memberId, _t2;
@@ -25792,7 +25856,7 @@ function createChannel(action) {
25792
25856
  case 19:
25793
25857
  return _context3.a(2);
25794
25858
  }
25795
- }, _marked3$2, null, [[0, 18]]);
25859
+ }, _marked2$3, null, [[0, 18]]);
25796
25860
  }
25797
25861
  function getChannels(action) {
25798
25862
  var _params$filter, _types, _activeChannel, _mappedChannels, _mappedChannels3, _mappedChannels4, payload, params, SceytChatClient, connectionStatus, channelQueryBuilder, channelTypesFilter, types, limit, channelQuery, channelsData, channelList, channelId, activeChannel, pendingLastMessages, _yield$call, mappedChannels, channelsForUpdateLastReactionMessage, _loop, _i, _Object$keys, _Object$keys2, _Object$keys3, _mappedChannels2, channelMessageMap, _iterator, _step, _lastMsg$userMarkers, ch, lastMsg, _activeChannel2, _activeChannel3, hiddenList, allChannelsQueryBuilder, allChannelsQuery, hasNext, totalAllChannelsAdded, i, _connectionStatus, allChannelsData, allChannelList, _t3, _t4, _t5;
@@ -25890,7 +25954,7 @@ function getChannels(action) {
25890
25954
  _yield$call = _context5.v;
25891
25955
  mappedChannels = _yield$call.channels;
25892
25956
  channelsForUpdateLastReactionMessage = _yield$call.channelsForUpdateLastReactionMessage;
25893
- _loop = /*#__PURE__*/_regenerator().m(function _callee() {
25957
+ _loop = /*#__PURE__*/_regenerator().m(function _callee2() {
25894
25958
  var _store$getState$Chann;
25895
25959
  var channelId, pendingLastMessage, currentReduxLastMessage, resolvedLastMessage, mappedChannel, mapEntry;
25896
25960
  return _regenerator().w(function (_context4) {
@@ -25917,7 +25981,7 @@ function getChannels(action) {
25917
25981
  case 1:
25918
25982
  return _context4.a(2);
25919
25983
  }
25920
- }, _callee);
25984
+ }, _callee2);
25921
25985
  });
25922
25986
  _i = 0, _Object$keys = Object.keys(pendingLastMessages);
25923
25987
  case 14:
@@ -26111,7 +26175,7 @@ function getChannels(action) {
26111
26175
  case 38:
26112
26176
  return _context5.a(2);
26113
26177
  }
26114
- }, _marked4$2, null, [[27, 30], [1, 37]]);
26178
+ }, _marked3$2, null, [[27, 30], [1, 37]]);
26115
26179
  }
26116
26180
  function searchChannels(action) {
26117
26181
  var payload, params, contactsMap, SceytChatClient, getFromContacts, searchBy, _params$filter2, _types2, channelQueryBuilder, channelTypesFilter, types, allChannels, publicChannels, chatsGroups, contactsList, contactsWithChannelsMap, lowerCaseSearchBy, handleChannels, channelsMap, _iterator2, _step2, channel, channelQuery, channelsData, _iterator3, _step3, _channel, channelsToAdd, _t6;
@@ -26244,7 +26308,7 @@ function searchChannels(action) {
26244
26308
  case 8:
26245
26309
  return _context6.a(2);
26246
26310
  }
26247
- }, _marked5$2, null, [[0, 7]]);
26311
+ }, _marked4$2, null, [[0, 7]]);
26248
26312
  }
26249
26313
  function getChannelsForForward() {
26250
26314
  var _SceytChatClient, channelQueryBuilder, channelTypesFilter, channelQuery, channelsData, channelsToAdd, _yield$call2, mappedChannels, _t7;
@@ -26302,7 +26366,7 @@ function getChannelsForForward() {
26302
26366
  case 9:
26303
26367
  return _context7.a(2);
26304
26368
  }
26305
- }, _marked6$2, null, [[0, 8]]);
26369
+ }, _marked5$2, null, [[0, 8]]);
26306
26370
  }
26307
26371
  function searchChannelsForForward(action) {
26308
26372
  var payload, params, _contactsMap, _SceytChatClient2, _getFromContacts, searchBy, _params$filter3, _types3, channelQueryBuilder, channelTypesFilter, types, allChannels, _publicChannels, _chatsGroups, contactsList, _contactsWithChannelsMap, _lowerCaseSearchBy, handleChannels, channelsMap, _iterator4, _step4, channel, channelQuery, channelsData, _iterator5, _step5, _channel2, channelsToAdd, _t8;
@@ -26434,7 +26498,7 @@ function searchChannelsForForward(action) {
26434
26498
  case 8:
26435
26499
  return _context8.a(2);
26436
26500
  }
26437
- }, _marked7$2, null, [[0, 7]]);
26501
+ }, _marked6$2, null, [[0, 7]]);
26438
26502
  }
26439
26503
  function channelsLoadMore(action) {
26440
26504
  var _mappedChannels5, _mappedChannels7, _mappedChannels8, payload, limit, channelQuery, channelsData, channelList, _yield$call3, mappedChannels, channelsForUpdateLastReactionMessage, _Object$keys4, _mappedChannels6, channelMessageMap, _t9;
@@ -26555,7 +26619,7 @@ function channelsLoadMore(action) {
26555
26619
  case 13:
26556
26620
  return _context9.a(2);
26557
26621
  }
26558
- }, _marked8$2, null, [[1, 12]]);
26622
+ }, _marked7$2, null, [[1, 12]]);
26559
26623
  }
26560
26624
  function getChannelMentions(action) {
26561
26625
  var payload, channelId, _SceytChatClient3, mentionsQueryBuilder, mentionsQuery, mentions, _t0;
@@ -26592,7 +26656,7 @@ function getChannelMentions(action) {
26592
26656
  case 5:
26593
26657
  return _context0.a(2);
26594
26658
  }
26595
- }, _marked9$1, null, [[0, 4]]);
26659
+ }, _marked8$2, null, [[0, 4]]);
26596
26660
  }
26597
26661
  function channelsForForwardLoadMore(action) {
26598
26662
  var payload, limit, _SceytChatClient4, channelQueryForward, channelsData, channelsToAdd, _yield$call4, mappedChannels, _t1;
@@ -26643,10 +26707,10 @@ function channelsForForwardLoadMore(action) {
26643
26707
  case 8:
26644
26708
  return _context1.a(2);
26645
26709
  }
26646
- }, _marked0$1, null, [[0, 7]]);
26710
+ }, _marked9$1, null, [[0, 7]]);
26647
26711
  }
26648
26712
  function markMessagesRead(action) {
26649
- var payload, channelId, messageIds, requestedMessageIds, channel, _confirmation$message, optimisticUpdate, pendingRead, confirmation, queuedPendingRead, readMessageIds, _iterator6, _step6, _confirmation$message2, _confirmation$message3, messageId, updateParams, _t10;
26713
+ var payload, channelId, messageIds, requestedMessageIds, _confirmation$message, channel, optimisticUpdate, pendingRead, confirmation, queuedPendingRead, _queuedPendingRead, readMessageIds, _iterator6, _step6, _confirmation$message2, _confirmation$message3, messageId, updateParams, _t10;
26650
26714
  return _regenerator().w(function (_context10) {
26651
26715
  while (1) switch (_context10.p = _context10.n) {
26652
26716
  case 0:
@@ -26657,57 +26721,85 @@ function markMessagesRead(action) {
26657
26721
  _context10.n = 1;
26658
26722
  break;
26659
26723
  }
26724
+ log.warn('[READ_MESSAGE] Skipping read marker because message id list is empty', compactReadMessageLogData({
26725
+ source: 'initial',
26726
+ channelId: channelId,
26727
+ readAll: false,
26728
+ messageIds: messageIds
26729
+ }));
26660
26730
  return _context10.a(2);
26661
26731
  case 1:
26662
26732
  _context10.p = 1;
26733
+ log.info('[READ_MESSAGE] Received markMessagesRead action', compactReadMessageLogData({
26734
+ source: 'initial',
26735
+ channelId: channelId,
26736
+ readAll: false,
26737
+ messageIds: requestedMessageIds
26738
+ }));
26663
26739
  _context10.n = 2;
26664
26740
  return effects.call(getStoredChannel$2, channelId);
26665
26741
  case 2:
26666
26742
  channel = _context10.v;
26667
- if (!channel) {
26668
- _context10.n = 11;
26743
+ if (channel) {
26744
+ _context10.n = 3;
26669
26745
  break;
26670
26746
  }
26747
+ log.warn('[READ_MESSAGE] Cannot mark messages as read because channel was not found', compactReadMessageLogData({
26748
+ channelId: channelId,
26749
+ messageIds: requestedMessageIds
26750
+ }));
26751
+ return _context10.a(2);
26752
+ case 3:
26671
26753
  optimisticUpdate = deriveChannelReadProgressUpdate({
26672
26754
  channel: channel,
26673
26755
  messageIds: requestedMessageIds
26674
26756
  });
26675
- _context10.n = 3;
26757
+ _context10.n = 4;
26676
26758
  return effects.call(applyChannelReadProgress, channel.id, optimisticUpdate);
26677
- case 3:
26759
+ case 4:
26678
26760
  pendingRead = setPendingChannelRead({
26679
26761
  channelId: channel.id,
26680
26762
  messageIds: requestedMessageIds
26681
26763
  });
26682
- _context10.n = 4;
26683
- return effects.call(confirmDisplayedRead, channel, pendingRead);
26684
- case 4:
26764
+ _context10.n = 5;
26765
+ return effects.call(confirmDisplayedRead, channel, pendingRead, 'initial');
26766
+ case 5:
26685
26767
  confirmation = _context10.v;
26686
26768
  if (!(confirmation.status === 'success')) {
26687
- _context10.n = 5;
26769
+ _context10.n = 6;
26688
26770
  break;
26689
26771
  }
26690
26772
  queuedPendingRead = getPendingChannelRead(channel.id);
26691
26773
  if ((queuedPendingRead === null || queuedPendingRead === void 0 ? void 0 : queuedPendingRead.queuedAt) === (pendingRead === null || pendingRead === void 0 ? void 0 : pendingRead.queuedAt)) {
26692
26774
  removePendingChannelRead(channel.id);
26693
26775
  }
26694
- _context10.n = 7;
26776
+ _context10.n = 8;
26695
26777
  break;
26696
- case 5:
26778
+ case 6:
26697
26779
  if (!(confirmation.status === 'drop')) {
26698
- _context10.n = 6;
26780
+ _context10.n = 7;
26699
26781
  break;
26700
26782
  }
26701
- removePendingChannelRead(channel.id);
26702
- return _context10.a(2);
26703
- case 6:
26783
+ _queuedPendingRead = getPendingChannelRead(channel.id);
26784
+ if ((_queuedPendingRead === null || _queuedPendingRead === void 0 ? void 0 : _queuedPendingRead.queuedAt) === (pendingRead === null || pendingRead === void 0 ? void 0 : pendingRead.queuedAt)) {
26785
+ removePendingChannelRead(channel.id);
26786
+ }
26704
26787
  return _context10.a(2);
26705
26788
  case 7:
26789
+ return _context10.a(2);
26790
+ case 8:
26706
26791
  readMessageIds = getUniqueMessageIds(((_confirmation$message = confirmation.messageListMarker) === null || _confirmation$message === void 0 ? void 0 : _confirmation$message.messageIds) || requestedMessageIds);
26792
+ log.info('[READ_MESSAGE] Confirmed read marker', compactReadMessageLogData({
26793
+ source: 'initial',
26794
+ channelId: channel.id,
26795
+ readAll: false,
26796
+ requestedMessageIds: requestedMessageIds,
26797
+ confirmedMessageIds: readMessageIds
26798
+ }));
26707
26799
  _iterator6 = _createForOfIteratorHelperLoose(readMessageIds);
26708
- case 8:
26800
+ case 9:
26709
26801
  if ((_step6 = _iterator6()).done) {
26710
- _context10.n = 11;
26802
+ _context10.n = 12;
26711
26803
  break;
26712
26804
  }
26713
26805
  messageId = _step6.value;
@@ -26720,27 +26812,27 @@ function markMessagesRead(action) {
26720
26812
  name: MESSAGE_DELIVERY_STATUS.READ
26721
26813
  }]
26722
26814
  };
26723
- _context10.n = 9;
26815
+ _context10.n = 10;
26724
26816
  return effects.put(updateMessageAC(messageId, updateParams));
26725
- case 9:
26817
+ case 10:
26726
26818
  updateMessageOnMap(channel.id, {
26727
26819
  messageId: messageId,
26728
26820
  params: updateParams
26729
26821
  });
26730
- case 10:
26731
- _context10.n = 8;
26732
- break;
26733
26822
  case 11:
26734
- _context10.n = 13;
26823
+ _context10.n = 9;
26735
26824
  break;
26736
26825
  case 12:
26737
- _context10.p = 12;
26826
+ _context10.n = 14;
26827
+ break;
26828
+ case 13:
26829
+ _context10.p = 13;
26738
26830
  _t10 = _context10.v;
26739
26831
  log.error(_t10, '[READ_MESSAGE] Error on mark messages read');
26740
- case 13:
26832
+ case 14:
26741
26833
  return _context10.a(2);
26742
26834
  }
26743
- }, _marked1$1, null, [[1, 12]]);
26835
+ }, _marked0$1, null, [[1, 13]]);
26744
26836
  }
26745
26837
  function markVoiceMessageAsPlayed(action) {
26746
26838
  var payload, channelId, messageIds, connectionStatus, channel, messageListMarker, _iterator7, _step7, messageId, updateParams, _t11;
@@ -26811,7 +26903,7 @@ function markVoiceMessageAsPlayed(action) {
26811
26903
  case 9:
26812
26904
  return _context11.a(2);
26813
26905
  }
26814
- }, _marked10$1, null, [[1, 8]]);
26906
+ }, _marked1$1, null, [[1, 8]]);
26815
26907
  }
26816
26908
  function updateMessageAsOpened(action) {
26817
26909
  var payload, channelId, messageListMarker, connectionStatus, channel, _iterator8, _step8, messageId, updateParams;
@@ -26870,7 +26962,7 @@ function updateMessageAsOpened(action) {
26870
26962
  case 6:
26871
26963
  return _context12.a(2);
26872
26964
  }
26873
- }, _marked11$1);
26965
+ }, _marked10$1);
26874
26966
  }
26875
26967
  function markMessageAsOpened(action) {
26876
26968
  var payload, channelId, messageIds, shouldUpdateMessage, connectionStatus, channel, messageListMarker, _t12;
@@ -26921,7 +27013,7 @@ function markMessageAsOpened(action) {
26921
27013
  case 6:
26922
27014
  return _context13.a(2);
26923
27015
  }
26924
- }, _marked12$1, null, [[1, 5]]);
27016
+ }, _marked11$1, null, [[1, 5]]);
26925
27017
  }
26926
27018
  function markMessagesDelivered(action) {
26927
27019
  var payload, channelId, messageIds, connectionStatus, channel, messageListMarker, _iterator9, _step9, messageId, updateParams, _t13;
@@ -26992,7 +27084,7 @@ function markMessagesDelivered(action) {
26992
27084
  case 9:
26993
27085
  return _context14.a(2);
26994
27086
  }
26995
- }, _marked13$1, null, [[1, 8]]);
27087
+ }, _marked12$1, null, [[1, 8]]);
26996
27088
  }
26997
27089
  function switchChannel(action) {
26998
27090
  var payload, channel, updateActiveChannel, channelToSwitch, existingChannel, addChannel, _SceytChatClient5, fetchedChannel, channelFromMap, currentActiveChannel, _t14;
@@ -27088,7 +27180,7 @@ function switchChannel(action) {
27088
27180
  case 17:
27089
27181
  return _context15.a(2);
27090
27182
  }
27091
- }, _marked14$1, null, [[0, 16]]);
27183
+ }, _marked13$1, null, [[0, 16]]);
27092
27184
  }
27093
27185
  function notificationsTurnOff(action) {
27094
27186
  var expireTime, activeChannelId, channel, updatedChannel, _t15;
@@ -27128,7 +27220,7 @@ function notificationsTurnOff(action) {
27128
27220
  case 7:
27129
27221
  return _context16.a(2);
27130
27222
  }
27131
- }, _marked15$1, null, [[3, 6]]);
27223
+ }, _marked14$1, null, [[3, 6]]);
27132
27224
  }
27133
27225
  function notificationsTurnOn() {
27134
27226
  var activeChannelId, channel, updatedChannel, _t16;
@@ -27167,15 +27259,21 @@ function notificationsTurnOn() {
27167
27259
  case 7:
27168
27260
  return _context17.a(2);
27169
27261
  }
27170
- }, _marked16$1, null, [[3, 6]]);
27262
+ }, _marked15$1, null, [[3, 6]]);
27171
27263
  }
27172
27264
  function markChannelAsRead(action) {
27173
- var channelId, channel, optimisticUpdate, pendingRead, confirmation, queuedPendingRead, _t17;
27265
+ var channelId, channel, optimisticUpdate, pendingRead, confirmation, queuedPendingRead, _queuedPendingRead2, _t17;
27174
27266
  return _regenerator().w(function (_context18) {
27175
27267
  while (1) switch (_context18.p = _context18.n) {
27176
27268
  case 0:
27177
27269
  _context18.p = 0;
27178
27270
  channelId = action.payload.channelId;
27271
+ log.info('[READ_MESSAGE] Received markChannelAsRead action', compactReadMessageLogData({
27272
+ source: 'initial',
27273
+ channelId: channelId,
27274
+ readAll: true,
27275
+ messageIds: []
27276
+ }));
27179
27277
  _context18.n = 1;
27180
27278
  return effects.call(getStoredChannel$2, channelId);
27181
27279
  case 1:
@@ -27184,6 +27282,9 @@ function markChannelAsRead(action) {
27184
27282
  _context18.n = 2;
27185
27283
  break;
27186
27284
  }
27285
+ log.warn('[READ_MESSAGE] Cannot mark channel as read because channel was not found', compactReadMessageLogData({
27286
+ channelId: channelId
27287
+ }));
27187
27288
  return _context18.a(2);
27188
27289
  case 2:
27189
27290
  optimisticUpdate = deriveChannelReadProgressUpdate({
@@ -27198,7 +27299,7 @@ function markChannelAsRead(action) {
27198
27299
  readAll: true
27199
27300
  });
27200
27301
  _context18.n = 4;
27201
- return effects.call(confirmDisplayedRead, channel, pendingRead);
27302
+ return effects.call(confirmDisplayedRead, channel, pendingRead, 'initial');
27202
27303
  case 4:
27203
27304
  confirmation = _context18.v;
27204
27305
  if (!(confirmation.status === 'success')) {
@@ -27209,22 +27310,31 @@ function markChannelAsRead(action) {
27209
27310
  if ((queuedPendingRead === null || queuedPendingRead === void 0 ? void 0 : queuedPendingRead.queuedAt) === (pendingRead === null || pendingRead === void 0 ? void 0 : pendingRead.queuedAt)) {
27210
27311
  removePendingChannelRead(channel.id);
27211
27312
  }
27313
+ log.info('[READ_MESSAGE] Confirmed read marker', compactReadMessageLogData({
27314
+ source: 'initial',
27315
+ channelId: channel.id,
27316
+ readAll: true,
27317
+ requestedMessageIds: [],
27318
+ confirmedMessageIds: []
27319
+ }));
27212
27320
  return _context18.a(2);
27213
27321
  case 5:
27214
27322
  if (confirmation.status === 'drop') {
27215
- removePendingChannelRead(channel.id);
27323
+ _queuedPendingRead2 = getPendingChannelRead(channel.id);
27324
+ if ((_queuedPendingRead2 === null || _queuedPendingRead2 === void 0 ? void 0 : _queuedPendingRead2.queuedAt) === (pendingRead === null || pendingRead === void 0 ? void 0 : pendingRead.queuedAt)) {
27325
+ removePendingChannelRead(channel.id);
27326
+ }
27216
27327
  }
27217
- log.error(confirmation.error, 'Error in set channel unread');
27218
27328
  _context18.n = 7;
27219
27329
  break;
27220
27330
  case 6:
27221
27331
  _context18.p = 6;
27222
27332
  _t17 = _context18.v;
27223
- log.error(_t17, 'Error in set channel unread');
27333
+ log.error(_t17, '[READ_MESSAGE] Error on mark channel as read');
27224
27334
  case 7:
27225
27335
  return _context18.a(2);
27226
27336
  }
27227
- }, _marked17$1, null, [[0, 6]]);
27337
+ }, _marked16$1, null, [[0, 6]]);
27228
27338
  }
27229
27339
  function resendPendingChannelReads(action) {
27230
27340
  var connectionState, pendingReads, _iterator0, _step0, pendingRead, currentPendingRead, channel, confirmation, latestPendingRead, _confirmation$message4, readMessageIds, _iterator1, _step1, _confirmation$message5, _confirmation$message6, messageId, updateParams, _t18;
@@ -27245,7 +27355,7 @@ function resendPendingChannelReads(action) {
27245
27355
  _iterator0 = _createForOfIteratorHelperLoose(pendingReads);
27246
27356
  case 2:
27247
27357
  if ((_step0 = _iterator0()).done) {
27248
- _context19.n = 14;
27358
+ _context19.n = 16;
27249
27359
  break;
27250
27360
  }
27251
27361
  pendingRead = _step0.value;
@@ -27260,14 +27370,20 @@ function resendPendingChannelReads(action) {
27260
27370
  _context19.n = 4;
27261
27371
  break;
27262
27372
  }
27263
- return _context19.a(3, 13);
27373
+ return _context19.a(3, 15);
27264
27374
  case 4:
27265
27375
  if (!(!pendingRead.readAll && !pendingRead.messageIds.length)) {
27266
27376
  _context19.n = 5;
27267
27377
  break;
27268
27378
  }
27379
+ log.warn('[READ_MESSAGE] Dropping queued replay because it has no message ids', compactReadMessageLogData({
27380
+ source: 'replay',
27381
+ channelId: pendingRead.channelId,
27382
+ readAll: pendingRead.readAll,
27383
+ messageIds: pendingRead.messageIds
27384
+ }));
27269
27385
  removePendingChannelRead(pendingRead.channelId);
27270
- return _context19.a(3, 13);
27386
+ return _context19.a(3, 15);
27271
27387
  case 5:
27272
27388
  _context19.n = 6;
27273
27389
  return effects.call(getStoredChannel$2, pendingRead.channelId);
@@ -27277,11 +27393,18 @@ function resendPendingChannelReads(action) {
27277
27393
  _context19.n = 7;
27278
27394
  break;
27279
27395
  }
27396
+ log.warn('[READ_MESSAGE] Dropping queued replay because channel was not found', compactReadMessageLogData({
27397
+ source: 'replay',
27398
+ channelId: pendingRead.channelId,
27399
+ readAll: pendingRead.readAll,
27400
+ messageIds: pendingRead.messageIds
27401
+ }));
27280
27402
  removePendingChannelRead(pendingRead.channelId);
27281
- return _context19.a(3, 13);
27403
+ return _context19.a(3, 15);
27282
27404
  case 7:
27405
+ log.info('[READ_MESSAGE] Replaying queued read marker', compactReadMessageLogData(getReadMarkerLogContext(pendingRead, 'replay', pendingRead.messageIds)));
27283
27406
  _context19.n = 8;
27284
- return effects.call(confirmDisplayedRead, channel, pendingRead);
27407
+ return effects.call(confirmDisplayedRead, channel, pendingRead, 'replay');
27285
27408
  case 8:
27286
27409
  confirmation = _context19.v;
27287
27410
  latestPendingRead = getPendingChannelRead(pendingRead.channelId);
@@ -27289,16 +27412,23 @@ function resendPendingChannelReads(action) {
27289
27412
  _context19.n = 9;
27290
27413
  break;
27291
27414
  }
27292
- return _context19.a(3, 13);
27415
+ return _context19.a(3, 15);
27293
27416
  case 9:
27294
27417
  if (confirmation.status === 'success' || confirmation.status === 'drop') {
27295
27418
  removePendingChannelRead(pendingRead.channelId);
27296
27419
  }
27297
27420
  if (!(confirmation.status === 'success' && !pendingRead.readAll)) {
27298
- _context19.n = 13;
27421
+ _context19.n = 14;
27299
27422
  break;
27300
27423
  }
27301
27424
  readMessageIds = getUniqueMessageIds(((_confirmation$message4 = confirmation.messageListMarker) === null || _confirmation$message4 === void 0 ? void 0 : _confirmation$message4.messageIds) || pendingRead.messageIds);
27425
+ log.info('[READ_MESSAGE] Confirmed read marker', compactReadMessageLogData({
27426
+ source: 'replay',
27427
+ channelId: channel.id,
27428
+ readAll: false,
27429
+ requestedMessageIds: pendingRead.messageIds,
27430
+ confirmedMessageIds: readMessageIds
27431
+ }));
27302
27432
  _iterator1 = _createForOfIteratorHelperLoose(readMessageIds);
27303
27433
  case 10:
27304
27434
  if ((_step1 = _iterator1()).done) {
@@ -27326,19 +27456,32 @@ function resendPendingChannelReads(action) {
27326
27456
  _context19.n = 10;
27327
27457
  break;
27328
27458
  case 13:
27329
- _context19.n = 2;
27459
+ _context19.n = 15;
27330
27460
  break;
27331
27461
  case 14:
27332
- _context19.n = 16;
27333
- break;
27462
+ if (confirmation.status === 'success' && pendingRead.readAll) {
27463
+ log.info('[READ_MESSAGE] Confirmed read marker', compactReadMessageLogData({
27464
+ source: 'replay',
27465
+ channelId: channel.id,
27466
+ readAll: true,
27467
+ requestedMessageIds: [],
27468
+ confirmedMessageIds: []
27469
+ }));
27470
+ }
27334
27471
  case 15:
27335
- _context19.p = 15;
27472
+ _context19.n = 2;
27473
+ break;
27474
+ case 16:
27475
+ _context19.n = 18;
27476
+ break;
27477
+ case 17:
27478
+ _context19.p = 17;
27336
27479
  _t18 = _context19.v;
27337
27480
  log.error(_t18, '[READ_MESSAGE] Error on resend pending channel reads');
27338
- case 16:
27481
+ case 18:
27339
27482
  return _context19.a(2);
27340
27483
  }
27341
- }, _marked18$1, null, [[0, 15]]);
27484
+ }, _marked17$1, null, [[0, 17]]);
27342
27485
  }
27343
27486
  function markChannelAsUnRead(action) {
27344
27487
  var channelId, channel, _t19;
@@ -27374,7 +27517,7 @@ function markChannelAsUnRead(action) {
27374
27517
  case 5:
27375
27518
  return _context20.a(2);
27376
27519
  }
27377
- }, _marked19$1, null, [[0, 4]]);
27520
+ }, _marked18$1, null, [[0, 4]]);
27378
27521
  }
27379
27522
  function pinChannel(action) {
27380
27523
  var channelId, channel, updatedChannel, _t20;
@@ -27411,7 +27554,7 @@ function pinChannel(action) {
27411
27554
  case 5:
27412
27555
  return _context21.a(2);
27413
27556
  }
27414
- }, _marked20$1, null, [[0, 4]]);
27557
+ }, _marked19$1, null, [[0, 4]]);
27415
27558
  }
27416
27559
  function unpinChannel(action) {
27417
27560
  var channelId, channel, updatedChannel, _t21;
@@ -27448,7 +27591,7 @@ function unpinChannel(action) {
27448
27591
  case 5:
27449
27592
  return _context22.a(2);
27450
27593
  }
27451
- }, _marked21$1, null, [[0, 4]]);
27594
+ }, _marked20$1, null, [[0, 4]]);
27452
27595
  }
27453
27596
  function removeChannelCaches(action) {
27454
27597
  var payload, channelId, activeChannelId, activeChannel;
@@ -27483,7 +27626,7 @@ function removeChannelCaches(action) {
27483
27626
  case 4:
27484
27627
  return _context23.a(2);
27485
27628
  }
27486
- }, _marked22$1);
27629
+ }, _marked21$1);
27487
27630
  }
27488
27631
  function leaveChannel(action) {
27489
27632
  var payload, channelId, channel, messageBuilder, messageToSend, _t22;
@@ -27535,7 +27678,7 @@ function leaveChannel(action) {
27535
27678
  case 7:
27536
27679
  return _context24.a(2);
27537
27680
  }
27538
- }, _marked23$1, null, [[0, 6]]);
27681
+ }, _marked22$1, null, [[0, 6]]);
27539
27682
  }
27540
27683
  function deletePendingDeleteChannels() {
27541
27684
  var pendingDeleteChannels, _iterator10, _step10, channel, resendableError, _t23;
@@ -27579,7 +27722,7 @@ function deletePendingDeleteChannels() {
27579
27722
  case 9:
27580
27723
  return _context25.a(2);
27581
27724
  }
27582
- }, _marked24$1, null, [[2, 7]]);
27725
+ }, _marked23$1, null, [[2, 7]]);
27583
27726
  }
27584
27727
  function deleteChannel(action) {
27585
27728
  var payload, channelId, channel, activeChannelId, lastChannel, _t24;
@@ -27673,7 +27816,7 @@ function deleteChannel(action) {
27673
27816
  case 19:
27674
27817
  return _context26.a(2);
27675
27818
  }
27676
- }, _marked25$1, null, [[0, 18]]);
27819
+ }, _marked24$1, null, [[0, 18]]);
27677
27820
  }
27678
27821
  function blockChannel(action) {
27679
27822
  var payload, channelId, channel, _t25;
@@ -27712,7 +27855,7 @@ function blockChannel(action) {
27712
27855
  case 6:
27713
27856
  return _context27.a(2);
27714
27857
  }
27715
- }, _marked26$1, null, [[0, 5]]);
27858
+ }, _marked25$1, null, [[0, 5]]);
27716
27859
  }
27717
27860
  function updateChannel(action) {
27718
27861
  var payload, channelId, config, _SceytChatClient6, channel, paramsToUpdate, fileToUpload, _yield$call5, subject, avatarUrl, metadata, onUpdateChannel, _channel3, _channel4, _channel5, fields, updatedChannel, _t26;
@@ -27809,7 +27952,7 @@ function updateChannel(action) {
27809
27952
  case 9:
27810
27953
  return _context28.a(2);
27811
27954
  }
27812
- }, _marked27$1, null, [[0, 8]]);
27955
+ }, _marked26$1, null, [[0, 8]]);
27813
27956
  }
27814
27957
  function checkUsersStatus() {
27815
27958
  var _SceytChatClient7, usersForUpdate, updatedUsers, usersToUpdateMap, update, updateData, _t27;
@@ -27860,7 +28003,7 @@ function checkUsersStatus() {
27860
28003
  case 7:
27861
28004
  return _context29.a(2);
27862
28005
  }
27863
- }, _marked28$1, null, [[0, 6]]);
28006
+ }, _marked27$1, null, [[0, 6]]);
27864
28007
  }
27865
28008
  function sendTyping(action) {
27866
28009
  var state, activeChannelId, channel, _t28;
@@ -27903,7 +28046,7 @@ function sendTyping(action) {
27903
28046
  case 8:
27904
28047
  return _context30.a(2);
27905
28048
  }
27906
- }, _marked29$1, null, [[3, 7]]);
28049
+ }, _marked28$1, null, [[3, 7]]);
27907
28050
  }
27908
28051
  function sendRecording(action) {
27909
28052
  var _action$payload, state, channelId, channel, _t29;
@@ -27946,7 +28089,7 @@ function sendRecording(action) {
27946
28089
  case 7:
27947
28090
  return _context31.a(2);
27948
28091
  }
27949
- }, _marked30$1, null, [[2, 6]]);
28092
+ }, _marked29$1, null, [[2, 6]]);
27950
28093
  }
27951
28094
  function clearHistory(action) {
27952
28095
  var payload, channelId, channel, activeChannelId, groupName, _t30;
@@ -28016,7 +28159,7 @@ function clearHistory(action) {
28016
28159
  case 10:
28017
28160
  return _context32.a(2);
28018
28161
  }
28019
- }, _marked31$1, null, [[0, 9]]);
28162
+ }, _marked30$1, null, [[0, 9]]);
28020
28163
  }
28021
28164
  function deleteAllMessages(action) {
28022
28165
  var payload, channelId, channel, activeChannelId, groupName, _t31;
@@ -28089,7 +28232,7 @@ function deleteAllMessages(action) {
28089
28232
  case 11:
28090
28233
  return _context33.a(2);
28091
28234
  }
28092
- }, _marked32$1, null, [[0, 10]]);
28235
+ }, _marked31$1, null, [[0, 10]]);
28093
28236
  }
28094
28237
  function joinChannel(action) {
28095
28238
  var payload, channelId, _SceytChatClient8, channel, joinedChannel, _t32;
@@ -28142,7 +28285,7 @@ function joinChannel(action) {
28142
28285
  case 10:
28143
28286
  return _context34.a(2);
28144
28287
  }
28145
- }, _marked33$1, null, [[0, 9]]);
28288
+ }, _marked32$1, null, [[0, 9]]);
28146
28289
  }
28147
28290
  function watchForChannelEvents() {
28148
28291
  return _regenerator().w(function (_context35) {
@@ -28153,7 +28296,7 @@ function watchForChannelEvents() {
28153
28296
  case 1:
28154
28297
  return _context35.a(2);
28155
28298
  }
28156
- }, _marked34$1);
28299
+ }, _marked33$1);
28157
28300
  }
28158
28301
  function createChannelInviteKey(action) {
28159
28302
  var payload, channelId, _SceytChatClient9, channel, inviteKey, _t33;
@@ -28195,7 +28338,7 @@ function createChannelInviteKey(action) {
28195
28338
  case 5:
28196
28339
  return _context36.a(2);
28197
28340
  }
28198
- }, _marked35$1, null, [[0, 4]]);
28341
+ }, _marked34$1, null, [[0, 4]]);
28199
28342
  }
28200
28343
  function getChannelInviteKeys(action) {
28201
28344
  var payload, channelId, channel, inviteKeys, _t34;
@@ -28232,7 +28375,7 @@ function getChannelInviteKeys(action) {
28232
28375
  case 5:
28233
28376
  return _context37.a(2);
28234
28377
  }
28235
- }, _marked36$1, null, [[0, 4]]);
28378
+ }, _marked35$1, null, [[0, 4]]);
28236
28379
  }
28237
28380
  function regenerateChannelInviteKey(action) {
28238
28381
  var payload, channelId, key, deletePermanently, channel, inviteKey, _t35;
@@ -28273,7 +28416,7 @@ function regenerateChannelInviteKey(action) {
28273
28416
  case 5:
28274
28417
  return _context38.a(2);
28275
28418
  }
28276
- }, _marked37$1, null, [[0, 4]]);
28419
+ }, _marked36$1, null, [[0, 4]]);
28277
28420
  }
28278
28421
  function updateChannelInviteKey(action) {
28279
28422
  var channelInviteKeys, channelId, payload, payloadChannelId, key, accessPriorHistory, expiresAt, maxUses, channel, copiedChannelInviteKeys, _t36;
@@ -28333,7 +28476,7 @@ function updateChannelInviteKey(action) {
28333
28476
  case 6:
28334
28477
  return _context39.a(2);
28335
28478
  }
28336
- }, _marked38$1, null, [[1, 5]]);
28479
+ }, _marked37$1, null, [[1, 5]]);
28337
28480
  }
28338
28481
  function getChannelByInviteKey(action) {
28339
28482
  var _channel$, _channel$2, payload, key, _SceytChatClient0, channel, _t37;
@@ -28384,7 +28527,7 @@ function getChannelByInviteKey(action) {
28384
28527
  case 8:
28385
28528
  return _context40.a(2);
28386
28529
  }
28387
- }, _marked39$1, null, [[0, 6]]);
28530
+ }, _marked38$1, null, [[0, 6]]);
28388
28531
  }
28389
28532
  function joinChannelWithInviteKey(action) {
28390
28533
  var payload, key, _SceytChatClient1, user, channel, messageToSend, _t38;
@@ -28428,7 +28571,7 @@ function joinChannelWithInviteKey(action) {
28428
28571
  case 7:
28429
28572
  return _context41.a(2);
28430
28573
  }
28431
- }, _marked40$1, null, [[0, 6]]);
28574
+ }, _marked39$1, null, [[0, 6]]);
28432
28575
  }
28433
28576
  function setMessageRetentionPeriod(action) {
28434
28577
  var payload, channelId, periodInMilliseconds, channel, messageToSend, _t39;
@@ -28481,7 +28624,7 @@ function setMessageRetentionPeriod(action) {
28481
28624
  case 6:
28482
28625
  return _context42.a(2);
28483
28626
  }
28484
- }, _marked41$1, null, [[0, 5]]);
28627
+ }, _marked40$1, null, [[0, 5]]);
28485
28628
  }
28486
28629
  function getChannelsWithUser(action) {
28487
28630
  var payload, userId, _SceytChatClient10, channelsQueryBuilder, channelsQuery, channelsData, channels, _t40;
@@ -28544,7 +28687,7 @@ function getChannelsWithUser(action) {
28544
28687
  case 12:
28545
28688
  return _context43.a(2);
28546
28689
  }
28547
- }, _marked42$1, null, [[2, 9, 10, 12]]);
28690
+ }, _marked41$1, null, [[2, 9, 10, 12]]);
28548
28691
  }
28549
28692
  function loadMoreMutualChannels(action) {
28550
28693
  var payload, limit, mutualChannelsQuery, channelsData, _t41;
@@ -28602,7 +28745,7 @@ function loadMoreMutualChannels(action) {
28602
28745
  case 11:
28603
28746
  return _context44.a(2);
28604
28747
  }
28605
- }, _marked43$1, null, [[1, 8, 9, 11]]);
28748
+ }, _marked42$1, null, [[1, 8, 9, 11]]);
28606
28749
  }
28607
28750
  function ChannelsSaga() {
28608
28751
  return _regenerator().w(function (_context45) {
@@ -28736,7 +28879,7 @@ function ChannelsSaga() {
28736
28879
  case 42:
28737
28880
  return _context45.a(2);
28738
28881
  }
28739
- }, _marked44$1);
28882
+ }, _marked43$1);
28740
28883
  }
28741
28884
 
28742
28885
  var _marked$4 = /*#__PURE__*/_regenerator().m(getMembers),
@@ -30723,19 +30866,10 @@ var SceytChat = function SceytChat(_ref) {
30723
30866
  var handleUserInteraction = function handleUserInteraction() {
30724
30867
  requestPermissionOnUserInteraction();
30725
30868
  };
30726
- var handleVisibilityChange = function handleVisibilityChange() {
30727
- if (document[hidden]) {
30728
- dispatch(browserTabIsActiveAC(false));
30729
- } else {
30730
- dispatch(browserTabIsActiveAC(true));
30731
- }
30732
- };
30733
- var handleFocusChange = function handleFocusChange(focus) {
30734
- if (focus) {
30735
- dispatch(browserTabIsActiveAC(true));
30736
- } else {
30737
- dispatch(browserTabIsActiveAC(false));
30738
- }
30869
+ var syncBrowserTabIsActive = function syncBrowserTabIsActive() {
30870
+ var isVisible = hidden ? !document[hidden] : document.visibilityState !== 'hidden';
30871
+ var isFocused = typeof document.hasFocus === 'function' ? document.hasFocus() : true;
30872
+ dispatch(browserTabIsActiveAC(isVisible && isFocused));
30739
30873
  };
30740
30874
  React.useEffect(function () {
30741
30875
  log.info('client is changed.... ', client);
@@ -30817,24 +30951,23 @@ var SceytChat = function SceytChat(_ref) {
30817
30951
  setBlobUrlEvictListener(function (keys) {
30818
30952
  return dispatch(removeAttachmentUpdatedEntriesAC(keys));
30819
30953
  });
30820
- var handleWindowFocus = function handleWindowFocus() {
30821
- return handleFocusChange(true);
30822
- };
30823
- var handleWindowBlur = function handleWindowBlur() {
30824
- return handleFocusChange(false);
30825
- };
30826
30954
  if (showNotifications) {
30827
30955
  initializeNotifications();
30828
30956
  window.sceytTabNotifications = null;
30829
30957
  window.sceytTabUrl = window.location.href;
30830
- window.addEventListener('focus', handleWindowFocus);
30831
- window.addEventListener('blur', handleWindowBlur);
30832
30958
  }
30833
- document.addEventListener(visibilityChange, handleVisibilityChange, false);
30959
+ window.addEventListener('focus', syncBrowserTabIsActive);
30960
+ window.addEventListener('blur', syncBrowserTabIsActive);
30961
+ if (visibilityChange) {
30962
+ document.addEventListener(visibilityChange, syncBrowserTabIsActive, false);
30963
+ }
30964
+ syncBrowserTabIsActive();
30834
30965
  return function () {
30835
- window.removeEventListener('focus', handleWindowFocus);
30836
- window.removeEventListener('blur', handleWindowBlur);
30837
- document.removeEventListener(visibilityChange, handleVisibilityChange);
30966
+ window.removeEventListener('focus', syncBrowserTabIsActive);
30967
+ window.removeEventListener('blur', syncBrowserTabIsActive);
30968
+ if (visibilityChange) {
30969
+ document.removeEventListener(visibilityChange, syncBrowserTabIsActive);
30970
+ }
30838
30971
  clearMessagesMap();
30839
30972
  setActiveChannelId('');
30840
30973
  destroyChannelsMap();
@@ -44903,10 +45036,49 @@ var Message$1 = function Message(_ref) {
44903
45036
  var alreadyRead = !!(message.userMarkers && message.userMarkers.length && message.userMarkers.find(function (marker) {
44904
45037
  return marker.name === MESSAGE_DELIVERY_STATUS.READ;
44905
45038
  }));
44906
- if (isVisible && message.incoming && !alreadyRead && !disableAutoReadTracking && isTabActive && channel.newMessageCount && channel.newMessageCount > 0 && connectionStatus === CONNECTION_STATUS.CONNECTED) {
45039
+ var shouldSendReadMarker = isVisible && message.incoming && !alreadyRead && !disableAutoReadTracking && isTabActive && !!channel.newMessageCount && channel.newMessageCount > 0 && connectionStatus === CONNECTION_STATUS.CONNECTED;
45040
+ if (message.incoming && isVisible) {
45041
+ if (shouldSendReadMarker) {
45042
+ log.info('[READ_MESSAGE] Message auto-read gate passed', compactReadMessageLogData({
45043
+ source: 'message',
45044
+ channelId: channel.id,
45045
+ messageId: message.id,
45046
+ isVisible: isVisible,
45047
+ alreadyRead: alreadyRead,
45048
+ disableAutoReadTracking: disableAutoReadTracking,
45049
+ isTabActive: isTabActive,
45050
+ newMessageCount: channel.newMessageCount || 0,
45051
+ connectionStatus: connectionStatus,
45052
+ queued: !!queueReadMarker
45053
+ }));
45054
+ } else {
45055
+ log.info('[READ_MESSAGE] Message auto-read gate blocked', compactReadMessageLogData({
45056
+ source: 'message',
45057
+ channelId: channel.id,
45058
+ messageId: message.id,
45059
+ isVisible: isVisible,
45060
+ alreadyRead: alreadyRead,
45061
+ disableAutoReadTracking: disableAutoReadTracking,
45062
+ isTabActive: isTabActive,
45063
+ newMessageCount: channel.newMessageCount || 0,
45064
+ connectionStatus: connectionStatus
45065
+ }));
45066
+ }
45067
+ }
45068
+ if (shouldSendReadMarker) {
44907
45069
  if (queueReadMarker) {
45070
+ log.info('[READ_MESSAGE] Queueing read marker from Message component', compactReadMessageLogData({
45071
+ source: 'message',
45072
+ channelId: channel.id,
45073
+ messageId: message.id
45074
+ }));
44908
45075
  queueReadMarker(channel.id, message.id);
44909
45076
  } else {
45077
+ log.info('[READ_MESSAGE] Dispatching read marker directly from Message component', compactReadMessageLogData({
45078
+ source: 'message',
45079
+ channelId: channel.id,
45080
+ messageId: message.id
45081
+ }));
44910
45082
  dispatch(markMessagesAsReadAC(channel.id, [message.id]));
44911
45083
  }
44912
45084
  }
@@ -44949,6 +45121,14 @@ var Message$1 = function Message(_ref) {
44949
45121
  }, [dispatch, selectionIsActive]);
44950
45122
  React.useEffect(function () {
44951
45123
  if (isVisible) {
45124
+ if (message.incoming) {
45125
+ log.info('[READ_MESSAGE] Message row became visible', compactReadMessageLogData({
45126
+ source: 'message',
45127
+ channelId: channel.id,
45128
+ messageId: message.id,
45129
+ localRef: message.tid || message.id || ''
45130
+ }));
45131
+ }
44952
45132
  if (setLastVisibleMessageId) {
44953
45133
  setLastVisibleMessageId(message);
44954
45134
  }
@@ -45958,6 +46138,14 @@ function useChatController(_ref5) {
45958
46138
  }, [clearJumpScrollingLock]);
45959
46139
  var queueVisibleUnreadCheck = React.useCallback(function () {
45960
46140
  if (pendingVisibleUnreadFrameRef.current !== null || unreadScrollTo || !tabIsActive) {
46141
+ if (!tabIsActive) {
46142
+ log.info('[READ_MESSAGE] Visible unread scan skipped because tab is inactive', compactReadMessageLogData({
46143
+ source: 'controller',
46144
+ channelId: channel.id,
46145
+ unreadScrollTo: unreadScrollTo,
46146
+ pendingFrameScheduled: pendingVisibleUnreadFrameRef.current !== null
46147
+ }));
46148
+ }
45961
46149
  return;
45962
46150
  }
45963
46151
  pendingVisibleUnreadFrameRef.current = requestAnimationFrame(function () {
@@ -45992,13 +46180,35 @@ function useChatController(_ref5) {
45992
46180
  var ids = visibleUnreadMessages.filter(isUnreadIncomingMessage).map(function (message) {
45993
46181
  return message.id;
45994
46182
  });
46183
+ if (visibleUnreadMessages.length && !ids.length) {
46184
+ log.info('[READ_MESSAGE] Visible unread scan found messages, but none were unread incoming', compactReadMessageLogData({
46185
+ source: 'controller',
46186
+ channelId: channel.id,
46187
+ visibleCandidateIds: visibleUnreadMessages.map(function (message) {
46188
+ return message.id;
46189
+ })
46190
+ }));
46191
+ }
45995
46192
  if (!ids.length || !channel.id || !channel.newMessageCount) {
46193
+ if (ids.length && (!channel.id || !channel.newMessageCount)) {
46194
+ log.info('[READ_MESSAGE] Visible unread scan blocked before dispatch', compactReadMessageLogData({
46195
+ source: 'controller',
46196
+ channelId: channel.id,
46197
+ messageIds: ids,
46198
+ newMessageCount: channel.newMessageCount || 0
46199
+ }));
46200
+ }
45996
46201
  return;
45997
46202
  }
45998
46203
  ids.forEach(function (id) {
45999
46204
  visibleUnreadReportedRef.current.add(id);
46000
46205
  });
46001
46206
  registerLocallyReadUnreadMessages(ids.length);
46207
+ log.info('[READ_MESSAGE] Dispatching read marker from visible unread scan', compactReadMessageLogData({
46208
+ source: 'controller',
46209
+ channelId: channel.id,
46210
+ messageIds: ids
46211
+ }));
46002
46212
  dispatch(markMessagesAsReadAC(channel.id, ids));
46003
46213
  });
46004
46214
  }, [channel.id, channel.lastDisplayedMessageId, channel.newMessageCount, dispatch, hasNext, messages, registerLocallyReadUnreadMessages, unreadScrollTo, tabIsActive]);