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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -9785,6 +9785,19 @@ function _finallyRethrows(body, finalizer) {
9785
9785
  var CustomUploader;
9786
9786
  var sendAttachmentsAsSeparateMessages = false;
9787
9787
  var pendingUploaders = {};
9788
+ var notStartedUploads = new Map();
9789
+ var markUploadNotStarted = function markUploadNotStarted(attachmentId) {
9790
+ notStartedUploads.set(attachmentId, {
9791
+ paused: false
9792
+ });
9793
+ };
9794
+ var isUploadNotStarted = function isUploadNotStarted(attachmentId) {
9795
+ return notStartedUploads.has(attachmentId);
9796
+ };
9797
+ var isUploadPausedBeforeStart = function isUploadPausedBeforeStart(attachmentId) {
9798
+ var _notStartedUploads$ge;
9799
+ return !!((_notStartedUploads$ge = notStartedUploads.get(attachmentId)) !== null && _notStartedUploads$ge !== void 0 && _notStartedUploads$ge.paused);
9800
+ };
9788
9801
  var setCustomUploader = function setCustomUploader(uploader) {
9789
9802
  CustomUploader = uploader;
9790
9803
  };
@@ -9824,7 +9837,12 @@ var customUpload = function customUpload(attachment, progress, messageType, getU
9824
9837
  resume: function resume() {}
9825
9838
  };
9826
9839
  pendingUploaders[attachment.tid] = uploadTask;
9840
+ var pausedBeforeStart = isUploadPausedBeforeStart(attachment.tid);
9841
+ notStartedUploads["delete"](attachment.tid);
9827
9842
  CustomUploader.upload(attachment, uploadTask, messageType);
9843
+ if (pausedBeforeStart) {
9844
+ uploadTask.stop();
9845
+ }
9828
9846
  } else {
9829
9847
  reject(new Error('No Custom uploader'));
9830
9848
  }
@@ -9833,6 +9851,11 @@ var customUpload = function customUpload(attachment, progress, messageType, getU
9833
9851
  var pauseUpload = function pauseUpload(attachmentId) {
9834
9852
  if (pendingUploaders[attachmentId]) {
9835
9853
  return pendingUploaders[attachmentId].stop();
9854
+ } else if (notStartedUploads.has(attachmentId)) {
9855
+ notStartedUploads.set(attachmentId, {
9856
+ paused: true
9857
+ });
9858
+ return true;
9836
9859
  } else {
9837
9860
  log.info('Unknown uploading task');
9838
9861
  return false;
@@ -9841,12 +9864,18 @@ var pauseUpload = function pauseUpload(attachmentId) {
9841
9864
  var resumeUpload = function resumeUpload(attachmentId) {
9842
9865
  if (pendingUploaders[attachmentId]) {
9843
9866
  return pendingUploaders[attachmentId].resume();
9867
+ } else if (notStartedUploads.has(attachmentId)) {
9868
+ notStartedUploads.set(attachmentId, {
9869
+ paused: false
9870
+ });
9871
+ return true;
9844
9872
  } else {
9845
9873
  log.info('Unknown uploading task');
9846
9874
  return false;
9847
9875
  }
9848
9876
  };
9849
9877
  var cancelUpload = function cancelUpload(attachmentId) {
9878
+ notStartedUploads["delete"](attachmentId);
9850
9879
  var task = pendingUploaders[attachmentId];
9851
9880
  if (task) {
9852
9881
  delete pendingUploaders[attachmentId];
@@ -18548,10 +18577,13 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
18548
18577
  var fileType = (_attachment$url = attachment.url) === null || _attachment$url === void 0 ? void 0 : (_attachment$url$type = _attachment$url.type) === null || _attachment$url$type === void 0 ? void 0 : _attachment$url$type.split('/')[0];
18549
18578
  var _temp12 = function () {
18550
18579
  if (attachment.type === attachmentTypes.video) {
18580
+ if (!attachment.cachedUrl) {
18581
+ markUploadNotStarted(attachment.tid);
18582
+ }
18551
18583
  return Promise.resolve(prepareAndUploadVideoPreview(attachment, message.type)).then(function (_prepareAndUploadVide) {
18552
18584
  attachment = _prepareAndUploadVide;
18553
18585
  if (!attachment.cachedUrl) {
18554
- store.dispatch(updateAttachmentUploadingStateAC(UPLOAD_STATE.UPLOADING, attachment.tid));
18586
+ store.dispatch(updateAttachmentUploadingStateAC(isUploadPausedBeforeStart(attachment.tid) ? UPLOAD_STATE.PAUSED : UPLOAD_STATE.UPLOADING, attachment.tid));
18555
18587
  }
18556
18588
  });
18557
18589
  }
@@ -23985,7 +24017,7 @@ function pauseAttachmentUploading(action) {
23985
24017
  }, _marked48, null, [[0, 2]]);
23986
24018
  }
23987
24019
  function resumeAttachmentUploading(action) {
23988
- var attachmentId, isResumed, _t46;
24020
+ var attachmentId, preparing, isResumed, _t46;
23989
24021
  return _regenerator().w(function (_context58) {
23990
24022
  while (1) switch (_context58.p = _context58.n) {
23991
24023
  case 0:
@@ -23996,13 +24028,14 @@ function resumeAttachmentUploading(action) {
23996
24028
  _context58.n = 1;
23997
24029
  break;
23998
24030
  }
24031
+ preparing = isUploadNotStarted(attachmentId);
23999
24032
  isResumed = resumeUpload(attachmentId);
24000
24033
  if (!isResumed) {
24001
24034
  _context58.n = 1;
24002
24035
  break;
24003
24036
  }
24004
24037
  _context58.n = 1;
24005
- return effects.put(updateAttachmentUploadingStateAC(UPLOAD_STATE.UPLOADING, attachmentId));
24038
+ return effects.put(updateAttachmentUploadingStateAC(preparing ? UPLOAD_STATE.PREPARING : UPLOAD_STATE.UPLOADING, attachmentId));
24006
24039
  case 1:
24007
24040
  _context58.n = 3;
24008
24041
  break;
@@ -42476,13 +42509,14 @@ var Attachment = function Attachment(_ref) {
42476
42509
  setDownloadIsCancelled(true);
42477
42510
  }
42478
42511
  };
42512
+ var pauseResumeUploadLabel = downloadingFile ? 'Cancel file download' : attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || attachmentCompilationState[attachment.tid] === UPLOAD_STATE.PREPARING ? 'Stop upload' : 'Resume upload';
42479
42513
  var handlePauseResumeUpload = function handlePauseResumeUpload(e) {
42480
42514
  e.stopPropagation();
42481
42515
  if (downloadingFile) {
42482
42516
  handleStopStartDownloadFile(attachment);
42483
42517
  } else {
42484
42518
  if (attachmentCompilationState[attachment.tid]) {
42485
- if (attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING) {
42519
+ if (attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || attachmentCompilationState[attachment.tid] === UPLOAD_STATE.PREPARING) {
42486
42520
  dispatch(pauseAttachmentUploadingAC(attachment.tid));
42487
42521
  } else {
42488
42522
  dispatch(resumeAttachmentUploadingAC(attachment.tid));
@@ -43218,7 +43252,8 @@ var Attachment = function Attachment(_ref) {
43218
43252
  isDetailsView: isDetailsView,
43219
43253
  backgroundColor: overlayBackground2
43220
43254
  }, isInUploadingState ? (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43221
- onClick: handlePauseResumeUpload
43255
+ onClick: handlePauseResumeUpload,
43256
+ "aria-label": pauseResumeUploadLabel
43222
43257
  }, attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING ? (/*#__PURE__*/React__default.createElement(SvgCancel, null)) : (/*#__PURE__*/React__default.createElement(SvgUpload, null)))) : !isCached && (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43223
43258
  "aria-label": 'Cancel image download',
43224
43259
  onClick: function onClick(e) {
@@ -43300,7 +43335,8 @@ var Attachment = function Attachment(_ref) {
43300
43335
  isDetailsView: isDetailsView,
43301
43336
  backgroundColor: overlayBackground2
43302
43337
  }, isInUploadingState ? (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43303
- onClick: handlePauseResumeUpload
43338
+ onClick: handlePauseResumeUpload,
43339
+ "aria-label": pauseResumeUploadLabel
43304
43340
  }, attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || isPreparingVideo ? (/*#__PURE__*/React__default.createElement(SvgCancel, null)) : (/*#__PURE__*/React__default.createElement(SvgUpload, null)))) : (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43305
43341
  onClick: handleCancelOriginalVideoDownload,
43306
43342
  "aria-label": 'Cancel video download'
@@ -43452,7 +43488,8 @@ var Attachment = function Attachment(_ref) {
43452
43488
  isDetailsView: isDetailsView,
43453
43489
  backgroundColor: overlayBackground2
43454
43490
  }, (isInUploadingState || downloadingFile) && (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43455
- onClick: handlePauseResumeUpload
43491
+ onClick: handlePauseResumeUpload,
43492
+ "aria-label": pauseResumeUploadLabel
43456
43493
  }, attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || downloadingFile ? (/*#__PURE__*/React__default.createElement(SvgCancel, null)) : isInUploadingState && /*#__PURE__*/React__default.createElement(SvgUpload, null))), (attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || downloadingFile) && (/*#__PURE__*/React__default.createElement(ProgressWrapper, null, /*#__PURE__*/React__default.createElement(reactCircularProgressbar.CircularProgressbar, {
43457
43494
  minValue: 0,
43458
43495
  maxValue: 100,
package/index.modern.js CHANGED
@@ -9766,6 +9766,19 @@ function _finallyRethrows(body, finalizer) {
9766
9766
  var CustomUploader;
9767
9767
  var sendAttachmentsAsSeparateMessages = false;
9768
9768
  var pendingUploaders = {};
9769
+ var notStartedUploads = new Map();
9770
+ var markUploadNotStarted = function markUploadNotStarted(attachmentId) {
9771
+ notStartedUploads.set(attachmentId, {
9772
+ paused: false
9773
+ });
9774
+ };
9775
+ var isUploadNotStarted = function isUploadNotStarted(attachmentId) {
9776
+ return notStartedUploads.has(attachmentId);
9777
+ };
9778
+ var isUploadPausedBeforeStart = function isUploadPausedBeforeStart(attachmentId) {
9779
+ var _notStartedUploads$ge;
9780
+ return !!((_notStartedUploads$ge = notStartedUploads.get(attachmentId)) !== null && _notStartedUploads$ge !== void 0 && _notStartedUploads$ge.paused);
9781
+ };
9769
9782
  var setCustomUploader = function setCustomUploader(uploader) {
9770
9783
  CustomUploader = uploader;
9771
9784
  };
@@ -9805,7 +9818,12 @@ var customUpload = function customUpload(attachment, progress, messageType, getU
9805
9818
  resume: function resume() {}
9806
9819
  };
9807
9820
  pendingUploaders[attachment.tid] = uploadTask;
9821
+ var pausedBeforeStart = isUploadPausedBeforeStart(attachment.tid);
9822
+ notStartedUploads["delete"](attachment.tid);
9808
9823
  CustomUploader.upload(attachment, uploadTask, messageType);
9824
+ if (pausedBeforeStart) {
9825
+ uploadTask.stop();
9826
+ }
9809
9827
  } else {
9810
9828
  reject(new Error('No Custom uploader'));
9811
9829
  }
@@ -9814,6 +9832,11 @@ var customUpload = function customUpload(attachment, progress, messageType, getU
9814
9832
  var pauseUpload = function pauseUpload(attachmentId) {
9815
9833
  if (pendingUploaders[attachmentId]) {
9816
9834
  return pendingUploaders[attachmentId].stop();
9835
+ } else if (notStartedUploads.has(attachmentId)) {
9836
+ notStartedUploads.set(attachmentId, {
9837
+ paused: true
9838
+ });
9839
+ return true;
9817
9840
  } else {
9818
9841
  log.info('Unknown uploading task');
9819
9842
  return false;
@@ -9822,12 +9845,18 @@ var pauseUpload = function pauseUpload(attachmentId) {
9822
9845
  var resumeUpload = function resumeUpload(attachmentId) {
9823
9846
  if (pendingUploaders[attachmentId]) {
9824
9847
  return pendingUploaders[attachmentId].resume();
9848
+ } else if (notStartedUploads.has(attachmentId)) {
9849
+ notStartedUploads.set(attachmentId, {
9850
+ paused: false
9851
+ });
9852
+ return true;
9825
9853
  } else {
9826
9854
  log.info('Unknown uploading task');
9827
9855
  return false;
9828
9856
  }
9829
9857
  };
9830
9858
  var cancelUpload = function cancelUpload(attachmentId) {
9859
+ notStartedUploads["delete"](attachmentId);
9831
9860
  var task = pendingUploaders[attachmentId];
9832
9861
  if (task) {
9833
9862
  delete pendingUploaders[attachmentId];
@@ -18529,10 +18558,13 @@ var handleUploadAttachments = function handleUploadAttachments(attachments, mess
18529
18558
  var fileType = (_attachment$url = attachment.url) === null || _attachment$url === void 0 ? void 0 : (_attachment$url$type = _attachment$url.type) === null || _attachment$url$type === void 0 ? void 0 : _attachment$url$type.split('/')[0];
18530
18559
  var _temp12 = function () {
18531
18560
  if (attachment.type === attachmentTypes.video) {
18561
+ if (!attachment.cachedUrl) {
18562
+ markUploadNotStarted(attachment.tid);
18563
+ }
18532
18564
  return Promise.resolve(prepareAndUploadVideoPreview(attachment, message.type)).then(function (_prepareAndUploadVide) {
18533
18565
  attachment = _prepareAndUploadVide;
18534
18566
  if (!attachment.cachedUrl) {
18535
- store.dispatch(updateAttachmentUploadingStateAC(UPLOAD_STATE.UPLOADING, attachment.tid));
18567
+ store.dispatch(updateAttachmentUploadingStateAC(isUploadPausedBeforeStart(attachment.tid) ? UPLOAD_STATE.PAUSED : UPLOAD_STATE.UPLOADING, attachment.tid));
18536
18568
  }
18537
18569
  });
18538
18570
  }
@@ -23966,7 +23998,7 @@ function pauseAttachmentUploading(action) {
23966
23998
  }, _marked48, null, [[0, 2]]);
23967
23999
  }
23968
24000
  function resumeAttachmentUploading(action) {
23969
- var attachmentId, isResumed, _t46;
24001
+ var attachmentId, preparing, isResumed, _t46;
23970
24002
  return _regenerator().w(function (_context58) {
23971
24003
  while (1) switch (_context58.p = _context58.n) {
23972
24004
  case 0:
@@ -23977,13 +24009,14 @@ function resumeAttachmentUploading(action) {
23977
24009
  _context58.n = 1;
23978
24010
  break;
23979
24011
  }
24012
+ preparing = isUploadNotStarted(attachmentId);
23980
24013
  isResumed = resumeUpload(attachmentId);
23981
24014
  if (!isResumed) {
23982
24015
  _context58.n = 1;
23983
24016
  break;
23984
24017
  }
23985
24018
  _context58.n = 1;
23986
- return put(updateAttachmentUploadingStateAC(UPLOAD_STATE.UPLOADING, attachmentId));
24019
+ return put(updateAttachmentUploadingStateAC(preparing ? UPLOAD_STATE.PREPARING : UPLOAD_STATE.UPLOADING, attachmentId));
23987
24020
  case 1:
23988
24021
  _context58.n = 3;
23989
24022
  break;
@@ -42457,13 +42490,14 @@ var Attachment = function Attachment(_ref) {
42457
42490
  setDownloadIsCancelled(true);
42458
42491
  }
42459
42492
  };
42493
+ var pauseResumeUploadLabel = downloadingFile ? 'Cancel file download' : attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || attachmentCompilationState[attachment.tid] === UPLOAD_STATE.PREPARING ? 'Stop upload' : 'Resume upload';
42460
42494
  var handlePauseResumeUpload = function handlePauseResumeUpload(e) {
42461
42495
  e.stopPropagation();
42462
42496
  if (downloadingFile) {
42463
42497
  handleStopStartDownloadFile(attachment);
42464
42498
  } else {
42465
42499
  if (attachmentCompilationState[attachment.tid]) {
42466
- if (attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING) {
42500
+ if (attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || attachmentCompilationState[attachment.tid] === UPLOAD_STATE.PREPARING) {
42467
42501
  dispatch(pauseAttachmentUploadingAC(attachment.tid));
42468
42502
  } else {
42469
42503
  dispatch(resumeAttachmentUploadingAC(attachment.tid));
@@ -43199,7 +43233,8 @@ var Attachment = function Attachment(_ref) {
43199
43233
  isDetailsView: isDetailsView,
43200
43234
  backgroundColor: overlayBackground2
43201
43235
  }, isInUploadingState ? (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43202
- onClick: handlePauseResumeUpload
43236
+ onClick: handlePauseResumeUpload,
43237
+ "aria-label": pauseResumeUploadLabel
43203
43238
  }, attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING ? (/*#__PURE__*/React__default.createElement(SvgCancel, null)) : (/*#__PURE__*/React__default.createElement(SvgUpload, null)))) : !isCached && (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43204
43239
  "aria-label": 'Cancel image download',
43205
43240
  onClick: function onClick(e) {
@@ -43281,7 +43316,8 @@ var Attachment = function Attachment(_ref) {
43281
43316
  isDetailsView: isDetailsView,
43282
43317
  backgroundColor: overlayBackground2
43283
43318
  }, isInUploadingState ? (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43284
- onClick: handlePauseResumeUpload
43319
+ onClick: handlePauseResumeUpload,
43320
+ "aria-label": pauseResumeUploadLabel
43285
43321
  }, attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || isPreparingVideo ? (/*#__PURE__*/React__default.createElement(SvgCancel, null)) : (/*#__PURE__*/React__default.createElement(SvgUpload, null)))) : (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43286
43322
  onClick: handleCancelOriginalVideoDownload,
43287
43323
  "aria-label": 'Cancel video download'
@@ -43433,7 +43469,8 @@ var Attachment = function Attachment(_ref) {
43433
43469
  isDetailsView: isDetailsView,
43434
43470
  backgroundColor: overlayBackground2
43435
43471
  }, (isInUploadingState || downloadingFile) && (/*#__PURE__*/React__default.createElement(CancelResumeWrapper, {
43436
- onClick: handlePauseResumeUpload
43472
+ onClick: handlePauseResumeUpload,
43473
+ "aria-label": pauseResumeUploadLabel
43437
43474
  }, attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || downloadingFile ? (/*#__PURE__*/React__default.createElement(SvgCancel, null)) : isInUploadingState && /*#__PURE__*/React__default.createElement(SvgUpload, null))), (attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || downloadingFile) && (/*#__PURE__*/React__default.createElement(ProgressWrapper, null, /*#__PURE__*/React__default.createElement(CircularProgressbar, {
43438
43475
  minValue: 0,
43439
43476
  maxValue: 100,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.9.2-beta.5",
3
+ "version": "1.9.2-beta.6",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",