sceyt-chat-react-uikit 1.8.0-beta.14 → 1.8.0-beta.15

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 +52 -27
  2. package/index.modern.js +52 -27
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -22182,7 +22182,7 @@ function loadMoreReactions(action) {
22182
22182
  }, _marked11$1, null, [[0, 5]]);
22183
22183
  }
22184
22184
  function getMessageAttachments(action) {
22185
- var _action$payload2, channelId, attachmentType, limit, direction, attachmentId, forPopup, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, attachmentIndex, hasNext, hasPrev, _t25;
22185
+ var _action$payload2, channelId, attachmentType, limit, direction, attachmentId, forPopup, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, attachments, attachmentIndex, hasPrev, hasNext, _t25;
22186
22186
  return _regenerator().w(function (_context17) {
22187
22187
  while (1) switch (_context17.p = _context17.n) {
22188
22188
  case 0:
@@ -22238,29 +22238,32 @@ function getMessageAttachments(action) {
22238
22238
  case 8:
22239
22239
  result = _context17.v;
22240
22240
  case 9:
22241
+ attachments = result.attachments.sort(function (a, b) {
22242
+ return forPopup ? Number(a.id || 0) - Number(b.id || 0) : Number(b.id || 0) - Number(a.id || 0);
22243
+ });
22241
22244
  if (!forPopup) {
22242
22245
  _context17.n = 12;
22243
22246
  break;
22244
22247
  }
22245
22248
  query.AttachmentByTypeQueryForPopup = AttachmentByTypeQuery;
22246
22249
  _context17.n = 10;
22247
- return effects.put(setAttachmentsForPopupAC(JSON.parse(JSON.stringify(result.attachments))));
22250
+ return effects.put(setAttachmentsForPopupAC(JSON.parse(JSON.stringify(attachments))));
22248
22251
  case 10:
22249
- attachmentIndex = result.attachments.findIndex(function (attachment) {
22252
+ attachmentIndex = attachments.findIndex(function (attachment) {
22250
22253
  return attachment.id === attachmentId;
22251
22254
  });
22252
- hasNext = false;
22253
- if (attachmentIndex >= limit / 2 && result.hasNext && limit === result.attachments.length) {
22254
- hasNext = true;
22255
- } else {
22256
- hasNext = false;
22257
- }
22258
22255
  hasPrev = false;
22259
- if (attachmentIndex <= limit / 2 - 1 && result.hasNext && limit === result.attachments.length) {
22256
+ if (attachmentIndex >= limit / 2 && result.hasNext && limit === attachments.length) {
22260
22257
  hasPrev = true;
22261
22258
  } else {
22262
22259
  hasPrev = false;
22263
22260
  }
22261
+ hasNext = false;
22262
+ if (attachmentIndex <= limit / 2 - 1 && result.hasNext && limit === attachments.length) {
22263
+ hasNext = true;
22264
+ } else {
22265
+ hasNext = false;
22266
+ }
22264
22267
  _context17.n = 11;
22265
22268
  return effects.put(setAttachmentsCompleteForPopupAC(hasPrev, hasNext));
22266
22269
  case 11:
@@ -22272,8 +22275,9 @@ function getMessageAttachments(action) {
22272
22275
  return effects.put(setAttachmentsCompleteAC(result.hasNext));
22273
22276
  case 13:
22274
22277
  _context17.n = 14;
22275
- return effects.put(setAttachmentsAC(JSON.parse(JSON.stringify(result.attachments))));
22278
+ return effects.put(setAttachmentsAC(JSON.parse(JSON.stringify(attachments))));
22276
22279
  case 14:
22280
+ console.log('attachments', attachments);
22277
22281
  _context17.n = 16;
22278
22282
  break;
22279
22283
  case 15:
@@ -29495,9 +29499,11 @@ var Carousel = function Carousel(_ref) {
29495
29499
  var isInternalNavigationRef = React.useRef(false);
29496
29500
  var lastInitialIndexRef = React.useRef(initialActiveIndex);
29497
29501
  var transitionTimeoutRef = React.useRef(null);
29502
+ var currentIndexRef = React.useRef(initialActiveIndex);
29498
29503
  React.useEffect(function () {
29499
29504
  isInternalNavigationRef.current = false;
29500
29505
  setCurrentIndex(initialActiveIndex);
29506
+ currentIndexRef.current = initialActiveIndex;
29501
29507
  lastInitialIndexRef.current = initialActiveIndex;
29502
29508
  }, [initialActiveIndex]);
29503
29509
  var items = React__default.Children.toArray(children);
@@ -29508,9 +29514,13 @@ var Carousel = function Carousel(_ref) {
29508
29514
  setIsTransitioning(false);
29509
29515
  }
29510
29516
  setCurrentIndex(initialActiveIndex);
29517
+ currentIndexRef.current = initialActiveIndex;
29511
29518
  lastInitialIndexRef.current = initialActiveIndex;
29512
29519
  }
29513
29520
  }, [initialActiveIndex, totalItems, currentIndex, skipTransition]);
29521
+ React.useEffect(function () {
29522
+ currentIndexRef.current = currentIndex;
29523
+ }, [currentIndex]);
29514
29524
  React.useEffect(function () {
29515
29525
  if (onChange && currentIndex >= 0 && currentIndex < totalItems) {
29516
29526
  if (isInternalNavigationRef.current) {
@@ -29532,6 +29542,7 @@ var Carousel = function Carousel(_ref) {
29532
29542
  setIsTransitioning(true);
29533
29543
  }
29534
29544
  setCurrentIndex(newIndex);
29545
+ currentIndexRef.current = newIndex;
29535
29546
  if (transitionTimeoutRef.current) {
29536
29547
  clearTimeout(transitionTimeoutRef.current);
29537
29548
  }
@@ -29543,16 +29554,18 @@ var Carousel = function Carousel(_ref) {
29543
29554
  }
29544
29555
  }, [totalItems]);
29545
29556
  var goToNext = React.useCallback(function () {
29546
- setCurrentIndex(function (prevIndex) {
29547
- var nextIndex = prevIndex + 1;
29548
- if (nextIndex >= totalItems) return prevIndex;
29549
- return nextIndex;
29550
- });
29557
+ var currentIdx = currentIndexRef.current;
29558
+ var nextIndex = currentIdx + 1;
29559
+ if (nextIndex >= totalItems) {
29560
+ return;
29561
+ }
29551
29562
  isInternalNavigationRef.current = true;
29552
29563
  setIsTransitioning(true);
29553
29564
  if (transitionTimeoutRef.current) {
29554
29565
  clearTimeout(transitionTimeoutRef.current);
29555
29566
  }
29567
+ setCurrentIndex(nextIndex);
29568
+ currentIndexRef.current = nextIndex;
29556
29569
  transitionTimeoutRef.current = setTimeout(function () {
29557
29570
  setIsTransitioning(false);
29558
29571
  isInternalNavigationRef.current = false;
@@ -29563,16 +29576,18 @@ var Carousel = function Carousel(_ref) {
29563
29576
  }
29564
29577
  }, [totalItems, onNextStart]);
29565
29578
  var goToPrev = React.useCallback(function () {
29566
- setCurrentIndex(function (prevIndex) {
29567
- var prevIndexValue = prevIndex - 1;
29568
- if (prevIndexValue < 0) return prevIndex;
29569
- return prevIndexValue;
29570
- });
29579
+ var currentIdx = currentIndexRef.current;
29580
+ var prevIndexValue = currentIdx - 1;
29581
+ if (prevIndexValue < 0) {
29582
+ return;
29583
+ }
29571
29584
  isInternalNavigationRef.current = true;
29572
29585
  setIsTransitioning(true);
29573
29586
  if (transitionTimeoutRef.current) {
29574
29587
  clearTimeout(transitionTimeoutRef.current);
29575
29588
  }
29589
+ setCurrentIndex(prevIndexValue);
29590
+ currentIndexRef.current = prevIndexValue;
29576
29591
  transitionTimeoutRef.current = setTimeout(function () {
29577
29592
  setIsTransitioning(false);
29578
29593
  isInternalNavigationRef.current = false;
@@ -31246,6 +31261,20 @@ var SliderPopup = function SliderPopup(_ref) {
31246
31261
  e.stopPropagation();
31247
31262
  }
31248
31263
  }, []);
31264
+ var loadNextMoreAttachments = React.useCallback(function () {
31265
+ debugger;
31266
+ if (activeFileIndex > attachmentsList.length - 5 && attachmentLoadingStateForPopup === LOADING_STATE.LOADED && attachmentsForPopupHasNext) {
31267
+ dispatch(loadMoreAttachmentsAC(34, queryDirection.NEXT, attachmentsList[attachmentsList.length - 1].id, true));
31268
+ }
31269
+ }, [activeFileIndex, attachmentLoadingStateForPopup, attachmentsForPopupHasNext, attachmentsList, dispatch]);
31270
+ var loadPrevMoreAttachments = React.useCallback(function () {
31271
+ if (activeFileIndex < 5 && attachmentLoadingStateForPopup === LOADING_STATE.LOADED && attachmentsForPopupHasPrev) {
31272
+ dispatch(loadMoreAttachmentsAC(34, queryDirection.PREV, attachmentsList[0].id, true));
31273
+ }
31274
+ }, [activeFileIndex, attachmentLoadingStateForPopup, attachmentsForPopupHasPrev, attachmentsList, dispatch]);
31275
+ console.log('attachmentsForPopupHasNext', attachmentsForPopupHasNext);
31276
+ console.log('attachmentsForPopupHasPrev', attachmentsForPopupHasPrev);
31277
+ console.log('attachmentsList', attachmentsList);
31249
31278
  return /*#__PURE__*/React__default.createElement(Container$b, {
31250
31279
  draggable: false
31251
31280
  }, /*#__PURE__*/React__default.createElement(SliderHeader, null, /*#__PURE__*/React__default.createElement(FileInfo, null, /*#__PURE__*/React__default.createElement(Avatar, {
@@ -31328,9 +31357,7 @@ var SliderPopup = function SliderPopup(_ref) {
31328
31357
  setImageLoading(true);
31329
31358
  }
31330
31359
  }
31331
- if (activeFileIndex > attachmentsList.length - 5 && attachmentLoadingStateForPopup === LOADING_STATE.LOADED) {
31332
- dispatch(loadMoreAttachmentsAC(34, queryDirection.NEXT, attachmentsList[attachmentsList.length - 1].id, true));
31333
- }
31360
+ loadNextMoreAttachments();
31334
31361
  },
31335
31362
  onPrevStart: function onPrevStart() {
31336
31363
  if (activeFileIndex - 1 >= 0) {
@@ -31339,9 +31366,7 @@ var SliderPopup = function SliderPopup(_ref) {
31339
31366
  setImageLoading(true);
31340
31367
  }
31341
31368
  }
31342
- if (activeFileIndex < 5 && attachmentLoadingStateForPopup === LOADING_STATE.LOADED) {
31343
- dispatch(loadMoreAttachmentsAC(34, queryDirection.PREV, attachmentsList[0].id, true));
31344
- }
31369
+ loadPrevMoreAttachments();
31345
31370
  },
31346
31371
  onChange: function onChange(pageIndex) {
31347
31372
  if (pageIndex >= 0 && pageIndex < attachmentsList.length) {
package/index.modern.js CHANGED
@@ -22181,7 +22181,7 @@ function loadMoreReactions(action) {
22181
22181
  }, _marked11$1, null, [[0, 5]]);
22182
22182
  }
22183
22183
  function getMessageAttachments(action) {
22184
- var _action$payload2, channelId, attachmentType, limit, direction, attachmentId, forPopup, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, attachmentIndex, hasNext, hasPrev, _t25;
22184
+ var _action$payload2, channelId, attachmentType, limit, direction, attachmentId, forPopup, SceytChatClient, typeList, AttachmentByTypeQueryBuilder, AttachmentByTypeQuery, result, attachments, attachmentIndex, hasPrev, hasNext, _t25;
22185
22185
  return _regenerator().w(function (_context17) {
22186
22186
  while (1) switch (_context17.p = _context17.n) {
22187
22187
  case 0:
@@ -22237,29 +22237,32 @@ function getMessageAttachments(action) {
22237
22237
  case 8:
22238
22238
  result = _context17.v;
22239
22239
  case 9:
22240
+ attachments = result.attachments.sort(function (a, b) {
22241
+ return forPopup ? Number(a.id || 0) - Number(b.id || 0) : Number(b.id || 0) - Number(a.id || 0);
22242
+ });
22240
22243
  if (!forPopup) {
22241
22244
  _context17.n = 12;
22242
22245
  break;
22243
22246
  }
22244
22247
  query.AttachmentByTypeQueryForPopup = AttachmentByTypeQuery;
22245
22248
  _context17.n = 10;
22246
- return put(setAttachmentsForPopupAC(JSON.parse(JSON.stringify(result.attachments))));
22249
+ return put(setAttachmentsForPopupAC(JSON.parse(JSON.stringify(attachments))));
22247
22250
  case 10:
22248
- attachmentIndex = result.attachments.findIndex(function (attachment) {
22251
+ attachmentIndex = attachments.findIndex(function (attachment) {
22249
22252
  return attachment.id === attachmentId;
22250
22253
  });
22251
- hasNext = false;
22252
- if (attachmentIndex >= limit / 2 && result.hasNext && limit === result.attachments.length) {
22253
- hasNext = true;
22254
- } else {
22255
- hasNext = false;
22256
- }
22257
22254
  hasPrev = false;
22258
- if (attachmentIndex <= limit / 2 - 1 && result.hasNext && limit === result.attachments.length) {
22255
+ if (attachmentIndex >= limit / 2 && result.hasNext && limit === attachments.length) {
22259
22256
  hasPrev = true;
22260
22257
  } else {
22261
22258
  hasPrev = false;
22262
22259
  }
22260
+ hasNext = false;
22261
+ if (attachmentIndex <= limit / 2 - 1 && result.hasNext && limit === attachments.length) {
22262
+ hasNext = true;
22263
+ } else {
22264
+ hasNext = false;
22265
+ }
22263
22266
  _context17.n = 11;
22264
22267
  return put(setAttachmentsCompleteForPopupAC(hasPrev, hasNext));
22265
22268
  case 11:
@@ -22271,8 +22274,9 @@ function getMessageAttachments(action) {
22271
22274
  return put(setAttachmentsCompleteAC(result.hasNext));
22272
22275
  case 13:
22273
22276
  _context17.n = 14;
22274
- return put(setAttachmentsAC(JSON.parse(JSON.stringify(result.attachments))));
22277
+ return put(setAttachmentsAC(JSON.parse(JSON.stringify(attachments))));
22275
22278
  case 14:
22279
+ console.log('attachments', attachments);
22276
22280
  _context17.n = 16;
22277
22281
  break;
22278
22282
  case 15:
@@ -29494,9 +29498,11 @@ var Carousel = function Carousel(_ref) {
29494
29498
  var isInternalNavigationRef = useRef(false);
29495
29499
  var lastInitialIndexRef = useRef(initialActiveIndex);
29496
29500
  var transitionTimeoutRef = useRef(null);
29501
+ var currentIndexRef = useRef(initialActiveIndex);
29497
29502
  useEffect(function () {
29498
29503
  isInternalNavigationRef.current = false;
29499
29504
  setCurrentIndex(initialActiveIndex);
29505
+ currentIndexRef.current = initialActiveIndex;
29500
29506
  lastInitialIndexRef.current = initialActiveIndex;
29501
29507
  }, [initialActiveIndex]);
29502
29508
  var items = React__default.Children.toArray(children);
@@ -29507,9 +29513,13 @@ var Carousel = function Carousel(_ref) {
29507
29513
  setIsTransitioning(false);
29508
29514
  }
29509
29515
  setCurrentIndex(initialActiveIndex);
29516
+ currentIndexRef.current = initialActiveIndex;
29510
29517
  lastInitialIndexRef.current = initialActiveIndex;
29511
29518
  }
29512
29519
  }, [initialActiveIndex, totalItems, currentIndex, skipTransition]);
29520
+ useEffect(function () {
29521
+ currentIndexRef.current = currentIndex;
29522
+ }, [currentIndex]);
29513
29523
  useEffect(function () {
29514
29524
  if (onChange && currentIndex >= 0 && currentIndex < totalItems) {
29515
29525
  if (isInternalNavigationRef.current) {
@@ -29531,6 +29541,7 @@ var Carousel = function Carousel(_ref) {
29531
29541
  setIsTransitioning(true);
29532
29542
  }
29533
29543
  setCurrentIndex(newIndex);
29544
+ currentIndexRef.current = newIndex;
29534
29545
  if (transitionTimeoutRef.current) {
29535
29546
  clearTimeout(transitionTimeoutRef.current);
29536
29547
  }
@@ -29542,16 +29553,18 @@ var Carousel = function Carousel(_ref) {
29542
29553
  }
29543
29554
  }, [totalItems]);
29544
29555
  var goToNext = useCallback(function () {
29545
- setCurrentIndex(function (prevIndex) {
29546
- var nextIndex = prevIndex + 1;
29547
- if (nextIndex >= totalItems) return prevIndex;
29548
- return nextIndex;
29549
- });
29556
+ var currentIdx = currentIndexRef.current;
29557
+ var nextIndex = currentIdx + 1;
29558
+ if (nextIndex >= totalItems) {
29559
+ return;
29560
+ }
29550
29561
  isInternalNavigationRef.current = true;
29551
29562
  setIsTransitioning(true);
29552
29563
  if (transitionTimeoutRef.current) {
29553
29564
  clearTimeout(transitionTimeoutRef.current);
29554
29565
  }
29566
+ setCurrentIndex(nextIndex);
29567
+ currentIndexRef.current = nextIndex;
29555
29568
  transitionTimeoutRef.current = setTimeout(function () {
29556
29569
  setIsTransitioning(false);
29557
29570
  isInternalNavigationRef.current = false;
@@ -29562,16 +29575,18 @@ var Carousel = function Carousel(_ref) {
29562
29575
  }
29563
29576
  }, [totalItems, onNextStart]);
29564
29577
  var goToPrev = useCallback(function () {
29565
- setCurrentIndex(function (prevIndex) {
29566
- var prevIndexValue = prevIndex - 1;
29567
- if (prevIndexValue < 0) return prevIndex;
29568
- return prevIndexValue;
29569
- });
29578
+ var currentIdx = currentIndexRef.current;
29579
+ var prevIndexValue = currentIdx - 1;
29580
+ if (prevIndexValue < 0) {
29581
+ return;
29582
+ }
29570
29583
  isInternalNavigationRef.current = true;
29571
29584
  setIsTransitioning(true);
29572
29585
  if (transitionTimeoutRef.current) {
29573
29586
  clearTimeout(transitionTimeoutRef.current);
29574
29587
  }
29588
+ setCurrentIndex(prevIndexValue);
29589
+ currentIndexRef.current = prevIndexValue;
29575
29590
  transitionTimeoutRef.current = setTimeout(function () {
29576
29591
  setIsTransitioning(false);
29577
29592
  isInternalNavigationRef.current = false;
@@ -31245,6 +31260,20 @@ var SliderPopup = function SliderPopup(_ref) {
31245
31260
  e.stopPropagation();
31246
31261
  }
31247
31262
  }, []);
31263
+ var loadNextMoreAttachments = useCallback(function () {
31264
+ debugger;
31265
+ if (activeFileIndex > attachmentsList.length - 5 && attachmentLoadingStateForPopup === LOADING_STATE.LOADED && attachmentsForPopupHasNext) {
31266
+ dispatch(loadMoreAttachmentsAC(34, queryDirection.NEXT, attachmentsList[attachmentsList.length - 1].id, true));
31267
+ }
31268
+ }, [activeFileIndex, attachmentLoadingStateForPopup, attachmentsForPopupHasNext, attachmentsList, dispatch]);
31269
+ var loadPrevMoreAttachments = useCallback(function () {
31270
+ if (activeFileIndex < 5 && attachmentLoadingStateForPopup === LOADING_STATE.LOADED && attachmentsForPopupHasPrev) {
31271
+ dispatch(loadMoreAttachmentsAC(34, queryDirection.PREV, attachmentsList[0].id, true));
31272
+ }
31273
+ }, [activeFileIndex, attachmentLoadingStateForPopup, attachmentsForPopupHasPrev, attachmentsList, dispatch]);
31274
+ console.log('attachmentsForPopupHasNext', attachmentsForPopupHasNext);
31275
+ console.log('attachmentsForPopupHasPrev', attachmentsForPopupHasPrev);
31276
+ console.log('attachmentsList', attachmentsList);
31248
31277
  return /*#__PURE__*/React__default.createElement(Container$b, {
31249
31278
  draggable: false
31250
31279
  }, /*#__PURE__*/React__default.createElement(SliderHeader, null, /*#__PURE__*/React__default.createElement(FileInfo, null, /*#__PURE__*/React__default.createElement(Avatar, {
@@ -31327,9 +31356,7 @@ var SliderPopup = function SliderPopup(_ref) {
31327
31356
  setImageLoading(true);
31328
31357
  }
31329
31358
  }
31330
- if (activeFileIndex > attachmentsList.length - 5 && attachmentLoadingStateForPopup === LOADING_STATE.LOADED) {
31331
- dispatch(loadMoreAttachmentsAC(34, queryDirection.NEXT, attachmentsList[attachmentsList.length - 1].id, true));
31332
- }
31359
+ loadNextMoreAttachments();
31333
31360
  },
31334
31361
  onPrevStart: function onPrevStart() {
31335
31362
  if (activeFileIndex - 1 >= 0) {
@@ -31338,9 +31365,7 @@ var SliderPopup = function SliderPopup(_ref) {
31338
31365
  setImageLoading(true);
31339
31366
  }
31340
31367
  }
31341
- if (activeFileIndex < 5 && attachmentLoadingStateForPopup === LOADING_STATE.LOADED) {
31342
- dispatch(loadMoreAttachmentsAC(34, queryDirection.PREV, attachmentsList[0].id, true));
31343
- }
31368
+ loadPrevMoreAttachments();
31344
31369
  },
31345
31370
  onChange: function onChange(pageIndex) {
31346
31371
  if (pageIndex >= 0 && pageIndex < attachmentsList.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.8.0-beta.14",
3
+ "version": "1.8.0-beta.15",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",