sceyt-chat-react-uikit 1.9.2-beta.3 → 1.9.2-beta.5

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 +44 -13
  2. package/index.modern.js +44 -13
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -42353,18 +42353,22 @@ var Attachment = function Attachment(_ref) {
42353
42353
  var _useState8 = React.useState(false),
42354
42354
  downloadIsCancelled = _useState8[0],
42355
42355
  setDownloadIsCancelled = _useState8[1];
42356
- var _useState9 = React.useState(0),
42357
- videoDownloadRetry = _useState9[0],
42358
- setVideoDownloadRetry = _useState9[1];
42356
+ var _useState9 = React.useState(false),
42357
+ fileDownloadFailed = _useState9[0],
42358
+ setFileDownloadFailed = _useState9[1];
42359
+ var fileDownloadCancelledRef = React.useRef(false);
42359
42360
  var _useState0 = React.useState(0),
42360
- imageDownloadRetry = _useState0[0],
42361
- setImageDownloadRetry = _useState0[1];
42362
- var _useState1 = React.useState(false),
42363
- isOriginalImageRestarting = _useState1[0],
42364
- setIsOriginalImageRestarting = _useState1[1];
42361
+ videoDownloadRetry = _useState0[0],
42362
+ setVideoDownloadRetry = _useState0[1];
42363
+ var _useState1 = React.useState(0),
42364
+ imageDownloadRetry = _useState1[0],
42365
+ setImageDownloadRetry = _useState1[1];
42365
42366
  var _useState10 = React.useState(false),
42366
- isOriginalVideoRestarting = _useState10[0],
42367
- setIsOriginalVideoRestarting = _useState10[1];
42367
+ isOriginalImageRestarting = _useState10[0],
42368
+ setIsOriginalImageRestarting = _useState10[1];
42369
+ var _useState11 = React.useState(false),
42370
+ isOriginalVideoRestarting = _useState11[0],
42371
+ setIsOriginalVideoRestarting = _useState11[1];
42368
42372
  var originalVideoDownloadStartedRef = React.useRef(false);
42369
42373
  var videoDownloadRequestRef = React.useRef(0);
42370
42374
  var imageDownloadRequestRef = React.useRef(0);
@@ -42400,7 +42404,8 @@ var Attachment = function Attachment(_ref) {
42400
42404
  var isPreparingVideo = attachmentCompilationState[attachment.tid] === UPLOAD_STATE.PREPARING;
42401
42405
  var isSharedOriginalVideoDownloading = sharedOriginalVideoDownload.state === 'loading';
42402
42406
  var isSharedOriginalVideoCancelled = sharedOriginalVideoDownload.state === 'cancelled';
42403
- var shouldShowVideoDownloadRetry = !isSharedOriginalVideoDownloading && !isOriginalVideoRestarting && (isSharedOriginalVideoCancelled || !originalVideoDownloadKey && downloadIsCancelled);
42407
+ var isSharedOriginalVideoFailed = sharedOriginalVideoDownload.state === 'failed';
42408
+ var shouldShowVideoDownloadRetry = !isSharedOriginalVideoDownloading && !isOriginalVideoRestarting && (isSharedOriginalVideoCancelled || isSharedOriginalVideoFailed || !originalVideoDownloadKey && downloadIsCancelled);
42404
42409
  var isVideoDownloading = downloadingFile || isSharedOriginalVideoDownloading;
42405
42410
  var isVideoDownloadActive = isVideoDownloading || isOriginalVideoRestarting;
42406
42411
  var shouldRenderVideoDownloadProgress = Boolean(!isRepliedMessage && !isPreview && (isInUploadingState || isVideoDownloadActive));
@@ -42490,9 +42495,10 @@ var Attachment = function Attachment(_ref) {
42490
42495
  closeMessageActions(enter);
42491
42496
  }
42492
42497
  };
42493
- var handleCompleteDownload = function handleCompleteDownload(attachmentId) {
42498
+ var handleCompleteDownload = function handleCompleteDownload(attachmentId, failed) {
42494
42499
  if (attachmentId === attachment.id) {
42495
42500
  setDownloadingFile(false);
42501
+ setFileDownloadFailed(!!failed && !fileDownloadCancelledRef.current);
42496
42502
  }
42497
42503
  };
42498
42504
  var handleStopStartDownloadFile = function handleStopStartDownloadFile(att) {
@@ -42506,6 +42512,7 @@ var Attachment = function Attachment(_ref) {
42506
42512
  }
42507
42513
  } else {
42508
42514
  setDownloadIsCancelled(true);
42515
+ fileDownloadCancelledRef.current = true;
42509
42516
  var attachmentId = att ? att.id : attachment.id;
42510
42517
  cancelDownloadFile(attachmentId || '');
42511
42518
  }
@@ -42522,6 +42529,8 @@ var Attachment = function Attachment(_ref) {
42522
42529
  var handleDownloadFileToDevice = function handleDownloadFileToDevice(attachment) {
42523
42530
  setDownloadingFile(true);
42524
42531
  setDownloadIsCancelled(false);
42532
+ setFileDownloadFailed(false);
42533
+ fileDownloadCancelledRef.current = false;
42525
42534
  downloadFile(attachment, true, handleCompleteDownload, function (progress) {
42526
42535
  var loadedRes = progress.loaded && progress.loaded / progress.total;
42527
42536
  var uploadPercent = loadedRes && loadedRes * 100;
@@ -42844,6 +42853,9 @@ var Attachment = function Attachment(_ref) {
42844
42853
  }, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, isDetailsView, originalVideoUrlFromMap, connectionStatus, dispatch, messageType, attachment.size, videoDownloadRetry, isSharedOriginalVideoCancelled, sharedOriginalVideoDownload.state]);
42845
42854
  var handleResumeOriginalVideoDownload = function handleResumeOriginalVideoDownload(event) {
42846
42855
  event.stopPropagation();
42856
+ restartOriginalVideoDownload();
42857
+ };
42858
+ var restartOriginalVideoDownload = function restartOriginalVideoDownload() {
42847
42859
  if (!attachment.url) return;
42848
42860
  var _getVideoAttachmentCa2 = getVideoAttachmentCacheKeys(attachment.url, attachment.metadata),
42849
42861
  originalVideoCacheKey = _getVideoAttachmentCa2.originalVideo;
@@ -42880,6 +42892,9 @@ var Attachment = function Attachment(_ref) {
42880
42892
  };
42881
42893
  var handleResumeOriginalImageDownload = function handleResumeOriginalImageDownload(event) {
42882
42894
  event.stopPropagation();
42895
+ restartOriginalImageDownload();
42896
+ };
42897
+ var restartOriginalImageDownload = function restartOriginalImageDownload() {
42883
42898
  if (!attachment.url) return;
42884
42899
  var imageDownloadRequest = imageDownloadRequestRef.current + 1;
42885
42900
  imageDownloadRequestRef.current = imageDownloadRequest;
@@ -42923,6 +42938,17 @@ var Attachment = function Attachment(_ref) {
42923
42938
  log.error('Error restarting image attachment download:', error);
42924
42939
  });
42925
42940
  };
42941
+ var previousConnectionStatusRef = React.useRef(connectionStatus);
42942
+ React.useEffect(function () {
42943
+ var reconnected = connectionStatus === CONNECTION_STATUS.CONNECTED && previousConnectionStatusRef.current !== CONNECTION_STATUS.CONNECTED;
42944
+ previousConnectionStatusRef.current = connectionStatus;
42945
+ if (!reconnected) return;
42946
+ if (attachment.type === attachmentTypes.video && isSharedOriginalVideoFailed) {
42947
+ restartOriginalVideoDownload();
42948
+ } else if (attachment.type === attachmentTypes.image && sharedOriginalImageDownload.state === 'failed') {
42949
+ restartOriginalImageDownload();
42950
+ }
42951
+ }, [connectionStatus]);
42926
42952
  var handleCancelOriginalVideoDownload = function handleCancelOriginalVideoDownload(event) {
42927
42953
  event.stopPropagation();
42928
42954
  if (isSharedOriginalVideoDownloading && originalVideoDownloadKey) {
@@ -43402,6 +43428,9 @@ var Attachment = function Attachment(_ref) {
43402
43428
  })) : isPreview && attachment.attachmentUrl ? (/*#__PURE__*/React__default.createElement(FileThumbnail, {
43403
43429
  src: attachment.attachmentUrl || attachmentUrl
43404
43430
  })) : attachmentCompilationState[attachment.tid] !== UPLOAD_STATE.UPLOADING && attachmentCompilationState[attachment.tid] !== UPLOAD_STATE.PAUSED && (selectedFileAttachmentsIcon || /*#__PURE__*/React__default.createElement(SvgFileIcon, null)))), !isRepliedMessage && !isPreview && (/*#__PURE__*/React__default.createElement(DownloadFile$1, {
43431
+ role: 'button',
43432
+ "aria-label": fileDownloadFailed ? 'Download failed, retry' : 'Download file',
43433
+ visible: fileDownloadFailed && !downloadingFile,
43405
43434
  widthThumb: !!attachmentThumb,
43406
43435
  backgroundColor: attachmentThumb ? overlayBackground2 : accentColor,
43407
43436
  onClick: function onClick() {
@@ -43497,7 +43526,9 @@ var FileThumbnailSkeleton = styled__default.div(_templateObject5$h || (_template
43497
43526
  }, function (props) {
43498
43527
  return props.color;
43499
43528
  }, fileThumbnailShimmer);
43500
- var DownloadFile$1 = styled__default.span(_templateObject6$c || (_templateObject6$c = _taggedTemplateLiteralLoose(["\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n background-color: ", ";\n min-width: 40px;\n max-width: 40px;\n height: 40px;\n position: ", ";\n border-radius: ", ";\n\n & > svg {\n width: 20px;\n height: 20px;\n }\n"])), function (props) {
43529
+ var DownloadFile$1 = styled__default.span(_templateObject6$c || (_templateObject6$c = _taggedTemplateLiteralLoose(["\n display: ", ";\n align-items: center;\n justify-content: center;\n cursor: pointer;\n background-color: ", ";\n min-width: 40px;\n max-width: 40px;\n height: 40px;\n position: ", ";\n border-radius: ", ";\n\n & > svg {\n width: 20px;\n height: 20px;\n }\n"])), function (props) {
43530
+ return props.visible ? 'flex' : 'none';
43531
+ }, function (props) {
43501
43532
  return props.backgroundColor;
43502
43533
  }, function (props) {
43503
43534
  return props.widthThumb && 'absolute';
package/index.modern.js CHANGED
@@ -42334,18 +42334,22 @@ var Attachment = function Attachment(_ref) {
42334
42334
  var _useState8 = useState(false),
42335
42335
  downloadIsCancelled = _useState8[0],
42336
42336
  setDownloadIsCancelled = _useState8[1];
42337
- var _useState9 = useState(0),
42338
- videoDownloadRetry = _useState9[0],
42339
- setVideoDownloadRetry = _useState9[1];
42337
+ var _useState9 = useState(false),
42338
+ fileDownloadFailed = _useState9[0],
42339
+ setFileDownloadFailed = _useState9[1];
42340
+ var fileDownloadCancelledRef = useRef(false);
42340
42341
  var _useState0 = useState(0),
42341
- imageDownloadRetry = _useState0[0],
42342
- setImageDownloadRetry = _useState0[1];
42343
- var _useState1 = useState(false),
42344
- isOriginalImageRestarting = _useState1[0],
42345
- setIsOriginalImageRestarting = _useState1[1];
42342
+ videoDownloadRetry = _useState0[0],
42343
+ setVideoDownloadRetry = _useState0[1];
42344
+ var _useState1 = useState(0),
42345
+ imageDownloadRetry = _useState1[0],
42346
+ setImageDownloadRetry = _useState1[1];
42346
42347
  var _useState10 = useState(false),
42347
- isOriginalVideoRestarting = _useState10[0],
42348
- setIsOriginalVideoRestarting = _useState10[1];
42348
+ isOriginalImageRestarting = _useState10[0],
42349
+ setIsOriginalImageRestarting = _useState10[1];
42350
+ var _useState11 = useState(false),
42351
+ isOriginalVideoRestarting = _useState11[0],
42352
+ setIsOriginalVideoRestarting = _useState11[1];
42349
42353
  var originalVideoDownloadStartedRef = useRef(false);
42350
42354
  var videoDownloadRequestRef = useRef(0);
42351
42355
  var imageDownloadRequestRef = useRef(0);
@@ -42381,7 +42385,8 @@ var Attachment = function Attachment(_ref) {
42381
42385
  var isPreparingVideo = attachmentCompilationState[attachment.tid] === UPLOAD_STATE.PREPARING;
42382
42386
  var isSharedOriginalVideoDownloading = sharedOriginalVideoDownload.state === 'loading';
42383
42387
  var isSharedOriginalVideoCancelled = sharedOriginalVideoDownload.state === 'cancelled';
42384
- var shouldShowVideoDownloadRetry = !isSharedOriginalVideoDownloading && !isOriginalVideoRestarting && (isSharedOriginalVideoCancelled || !originalVideoDownloadKey && downloadIsCancelled);
42388
+ var isSharedOriginalVideoFailed = sharedOriginalVideoDownload.state === 'failed';
42389
+ var shouldShowVideoDownloadRetry = !isSharedOriginalVideoDownloading && !isOriginalVideoRestarting && (isSharedOriginalVideoCancelled || isSharedOriginalVideoFailed || !originalVideoDownloadKey && downloadIsCancelled);
42385
42390
  var isVideoDownloading = downloadingFile || isSharedOriginalVideoDownloading;
42386
42391
  var isVideoDownloadActive = isVideoDownloading || isOriginalVideoRestarting;
42387
42392
  var shouldRenderVideoDownloadProgress = Boolean(!isRepliedMessage && !isPreview && (isInUploadingState || isVideoDownloadActive));
@@ -42471,9 +42476,10 @@ var Attachment = function Attachment(_ref) {
42471
42476
  closeMessageActions(enter);
42472
42477
  }
42473
42478
  };
42474
- var handleCompleteDownload = function handleCompleteDownload(attachmentId) {
42479
+ var handleCompleteDownload = function handleCompleteDownload(attachmentId, failed) {
42475
42480
  if (attachmentId === attachment.id) {
42476
42481
  setDownloadingFile(false);
42482
+ setFileDownloadFailed(!!failed && !fileDownloadCancelledRef.current);
42477
42483
  }
42478
42484
  };
42479
42485
  var handleStopStartDownloadFile = function handleStopStartDownloadFile(att) {
@@ -42487,6 +42493,7 @@ var Attachment = function Attachment(_ref) {
42487
42493
  }
42488
42494
  } else {
42489
42495
  setDownloadIsCancelled(true);
42496
+ fileDownloadCancelledRef.current = true;
42490
42497
  var attachmentId = att ? att.id : attachment.id;
42491
42498
  cancelDownloadFile(attachmentId || '');
42492
42499
  }
@@ -42503,6 +42510,8 @@ var Attachment = function Attachment(_ref) {
42503
42510
  var handleDownloadFileToDevice = function handleDownloadFileToDevice(attachment) {
42504
42511
  setDownloadingFile(true);
42505
42512
  setDownloadIsCancelled(false);
42513
+ setFileDownloadFailed(false);
42514
+ fileDownloadCancelledRef.current = false;
42506
42515
  downloadFile(attachment, true, handleCompleteDownload, function (progress) {
42507
42516
  var loadedRes = progress.loaded && progress.loaded / progress.total;
42508
42517
  var uploadPercent = loadedRes && loadedRes * 100;
@@ -42825,6 +42834,9 @@ var Attachment = function Attachment(_ref) {
42825
42834
  }, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, isDetailsView, originalVideoUrlFromMap, connectionStatus, dispatch, messageType, attachment.size, videoDownloadRetry, isSharedOriginalVideoCancelled, sharedOriginalVideoDownload.state]);
42826
42835
  var handleResumeOriginalVideoDownload = function handleResumeOriginalVideoDownload(event) {
42827
42836
  event.stopPropagation();
42837
+ restartOriginalVideoDownload();
42838
+ };
42839
+ var restartOriginalVideoDownload = function restartOriginalVideoDownload() {
42828
42840
  if (!attachment.url) return;
42829
42841
  var _getVideoAttachmentCa2 = getVideoAttachmentCacheKeys(attachment.url, attachment.metadata),
42830
42842
  originalVideoCacheKey = _getVideoAttachmentCa2.originalVideo;
@@ -42861,6 +42873,9 @@ var Attachment = function Attachment(_ref) {
42861
42873
  };
42862
42874
  var handleResumeOriginalImageDownload = function handleResumeOriginalImageDownload(event) {
42863
42875
  event.stopPropagation();
42876
+ restartOriginalImageDownload();
42877
+ };
42878
+ var restartOriginalImageDownload = function restartOriginalImageDownload() {
42864
42879
  if (!attachment.url) return;
42865
42880
  var imageDownloadRequest = imageDownloadRequestRef.current + 1;
42866
42881
  imageDownloadRequestRef.current = imageDownloadRequest;
@@ -42904,6 +42919,17 @@ var Attachment = function Attachment(_ref) {
42904
42919
  log.error('Error restarting image attachment download:', error);
42905
42920
  });
42906
42921
  };
42922
+ var previousConnectionStatusRef = useRef(connectionStatus);
42923
+ useEffect(function () {
42924
+ var reconnected = connectionStatus === CONNECTION_STATUS.CONNECTED && previousConnectionStatusRef.current !== CONNECTION_STATUS.CONNECTED;
42925
+ previousConnectionStatusRef.current = connectionStatus;
42926
+ if (!reconnected) return;
42927
+ if (attachment.type === attachmentTypes.video && isSharedOriginalVideoFailed) {
42928
+ restartOriginalVideoDownload();
42929
+ } else if (attachment.type === attachmentTypes.image && sharedOriginalImageDownload.state === 'failed') {
42930
+ restartOriginalImageDownload();
42931
+ }
42932
+ }, [connectionStatus]);
42907
42933
  var handleCancelOriginalVideoDownload = function handleCancelOriginalVideoDownload(event) {
42908
42934
  event.stopPropagation();
42909
42935
  if (isSharedOriginalVideoDownloading && originalVideoDownloadKey) {
@@ -43383,6 +43409,9 @@ var Attachment = function Attachment(_ref) {
43383
43409
  })) : isPreview && attachment.attachmentUrl ? (/*#__PURE__*/React__default.createElement(FileThumbnail, {
43384
43410
  src: attachment.attachmentUrl || attachmentUrl
43385
43411
  })) : attachmentCompilationState[attachment.tid] !== UPLOAD_STATE.UPLOADING && attachmentCompilationState[attachment.tid] !== UPLOAD_STATE.PAUSED && (selectedFileAttachmentsIcon || /*#__PURE__*/React__default.createElement(SvgFileIcon, null)))), !isRepliedMessage && !isPreview && (/*#__PURE__*/React__default.createElement(DownloadFile$1, {
43412
+ role: 'button',
43413
+ "aria-label": fileDownloadFailed ? 'Download failed, retry' : 'Download file',
43414
+ visible: fileDownloadFailed && !downloadingFile,
43386
43415
  widthThumb: !!attachmentThumb,
43387
43416
  backgroundColor: attachmentThumb ? overlayBackground2 : accentColor,
43388
43417
  onClick: function onClick() {
@@ -43478,7 +43507,9 @@ var FileThumbnailSkeleton = styled.div(_templateObject5$h || (_templateObject5$h
43478
43507
  }, function (props) {
43479
43508
  return props.color;
43480
43509
  }, fileThumbnailShimmer);
43481
- var DownloadFile$1 = styled.span(_templateObject6$c || (_templateObject6$c = _taggedTemplateLiteralLoose(["\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n background-color: ", ";\n min-width: 40px;\n max-width: 40px;\n height: 40px;\n position: ", ";\n border-radius: ", ";\n\n & > svg {\n width: 20px;\n height: 20px;\n }\n"])), function (props) {
43510
+ var DownloadFile$1 = styled.span(_templateObject6$c || (_templateObject6$c = _taggedTemplateLiteralLoose(["\n display: ", ";\n align-items: center;\n justify-content: center;\n cursor: pointer;\n background-color: ", ";\n min-width: 40px;\n max-width: 40px;\n height: 40px;\n position: ", ";\n border-radius: ", ";\n\n & > svg {\n width: 20px;\n height: 20px;\n }\n"])), function (props) {
43511
+ return props.visible ? 'flex' : 'none';
43512
+ }, function (props) {
43482
43513
  return props.backgroundColor;
43483
43514
  }, function (props) {
43484
43515
  return props.widthThumb && 'absolute';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.9.2-beta.3",
3
+ "version": "1.9.2-beta.5",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",