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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,19 @@ export interface IUploadTask {
19
19
  }
20
20
  export interface ICustomUploader {
21
21
  upload: (attachment: IAttachment, uploadTask: IUploadTask, messageType: string | null | undefined) => void;
22
+ /**
23
+ * `messageId` is the ID of a message the attachment appears in, supplied by
24
+ * the client. Treat it as a hint, not proof of access:
25
+ * - Media previews (images, videos, voice, video thumbnails) are shared and
26
+ * cached by `uri`. When several messages use the same file (e.g. forwards),
27
+ * only the first request's ID is sent, and its failure is shared too.
28
+ * - A file already in the browser's attachment cache is served without
29
+ * calling `download`; that cache is per origin, not per user.
30
+ * - It may be empty (`''`) or missing for messages that are not confirmed yet.
31
+ * The backend must verify that the caller can read the message and that
32
+ * `uri` legitimately belongs to it (e.g. traced to its original upload),
33
+ * before serving the file.
34
+ */
22
35
  download: (uri: string, download: boolean, progressCallback: (progress: any) => void, messageType: string | null | undefined, messageId?: string | null) => Promise<any>;
23
36
  cancelRequest: (requestPromise: any) => void;
24
37
  }
package/index.js CHANGED
@@ -42018,9 +42018,15 @@ var VideoPreview = /*#__PURE__*/React.memo(function VideoPreview(_ref) {
42018
42018
  var previousVideoSourceRef = React.useRef(undefined);
42019
42019
  React.useEffect(function () {
42020
42020
  if (!videoThumb || downloadedPreviewImage) return;
42021
+ var customDownloader = getCustomDownloader();
42022
+ var previewRequest = customDownloader && !file.messageId ? getAttachmentUrlFromCache(videoThumb)["catch"](function () {
42023
+ return false;
42024
+ }).then(function (cachedUrl) {
42025
+ return typeof cachedUrl === 'string' ? cachedUrl : undefined;
42026
+ }) : downloadVideoThumb(videoThumb, customDownloader, messageType, file.messageId);
42021
42027
  var cancelled = false;
42022
- downloadVideoThumb(videoThumb, getCustomDownloader(), messageType, file.messageId).then(function (localPreviewUrl) {
42023
- if (!cancelled) {
42028
+ previewRequest.then(function (localPreviewUrl) {
42029
+ if (!cancelled && localPreviewUrl) {
42024
42030
  dispatch(setUpdateMessageAttachmentAC(videoThumb, localPreviewUrl));
42025
42031
  }
42026
42032
  })["catch"](function (error) {
@@ -42029,7 +42035,7 @@ var VideoPreview = /*#__PURE__*/React.memo(function VideoPreview(_ref) {
42029
42035
  return function () {
42030
42036
  cancelled = true;
42031
42037
  };
42032
- }, [videoThumb, downloadedPreviewImage, dispatch, messageType]);
42038
+ }, [videoThumb, downloadedPreviewImage, dispatch, messageType, file.messageId]);
42033
42039
  React.useEffect(function () {
42034
42040
  var videoSource = src;
42035
42041
  var canExtractFirstFrame = shouldExtractVideoFirstFrame(file.metadata);
@@ -42174,7 +42180,7 @@ var VideoPreview = /*#__PURE__*/React.memo(function VideoPreview(_ref) {
42174
42180
  messageTimeBackgroundColor: overlayBackground2
42175
42181
  }, !isRepliedMessage && !isPreview && /*#__PURE__*/React__default.createElement(SvgVideoCall, null), videoCurrentTime))));
42176
42182
  }, function (prev, next) {
42177
- return prev.src === next.src && prev.file.id === next.file.id && prev.file.url === next.file.url && prev.file.metadata === next.file.metadata && prev.uploading === next.uploading && prev.downloading === next.downloading && prev.width === next.width && prev.height === next.height && prev.borderRadius === next.borderRadius && prev.isRepliedMessage === next.isRepliedMessage && prev.isDetailsView === next.isDetailsView;
42183
+ return prev.src === next.src && prev.file.id === next.file.id && prev.file.messageId === next.file.messageId && prev.messageType === next.messageType && prev.file.url === next.file.url && prev.file.metadata === next.file.metadata && prev.uploading === next.uploading && prev.downloading === next.downloading && prev.width === next.width && prev.height === next.height && prev.borderRadius === next.borderRadius && prev.isRepliedMessage === next.isRepliedMessage && prev.isDetailsView === next.isDetailsView;
42178
42184
  });
42179
42185
  var VideoControls = styled__default.div(_templateObject$t || (_templateObject$t = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 6;\n"])));
42180
42186
  var VideoTime = styled__default.div(_templateObject2$q || (_templateObject2$q = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: ", ";\n bottom: ", ";\n left: ", ";\n font-size: ", ";\n display: flex;\n align-items: center;\n border-radius: 16px;\n padding: ", ";\n background-color: ", ";\n line-height: 14px;\n color: ", ";\n z-index: 10;\n\n & > svg {\n color: ", ";\n margin-right: 4px;\n }\n"])), function (props) {
@@ -42455,7 +42461,7 @@ var Attachment = function Attachment(_ref) {
42455
42461
  e.stopPropagation();
42456
42462
  if (downloadIsCancelled) {
42457
42463
  setDownloadIsCancelled(false);
42458
- if (getCustomUploader()) {
42464
+ if (customDownloader) {
42459
42465
  handleResumeOriginalImageDownload(e);
42460
42466
  } else {
42461
42467
  downloadImage(attachment.url);
package/index.modern.js CHANGED
@@ -41999,9 +41999,15 @@ var VideoPreview = /*#__PURE__*/memo(function VideoPreview(_ref) {
41999
41999
  var previousVideoSourceRef = useRef(undefined);
42000
42000
  useEffect(function () {
42001
42001
  if (!videoThumb || downloadedPreviewImage) return;
42002
+ var customDownloader = getCustomDownloader();
42003
+ var previewRequest = customDownloader && !file.messageId ? getAttachmentUrlFromCache(videoThumb)["catch"](function () {
42004
+ return false;
42005
+ }).then(function (cachedUrl) {
42006
+ return typeof cachedUrl === 'string' ? cachedUrl : undefined;
42007
+ }) : downloadVideoThumb(videoThumb, customDownloader, messageType, file.messageId);
42002
42008
  var cancelled = false;
42003
- downloadVideoThumb(videoThumb, getCustomDownloader(), messageType, file.messageId).then(function (localPreviewUrl) {
42004
- if (!cancelled) {
42009
+ previewRequest.then(function (localPreviewUrl) {
42010
+ if (!cancelled && localPreviewUrl) {
42005
42011
  dispatch(setUpdateMessageAttachmentAC(videoThumb, localPreviewUrl));
42006
42012
  }
42007
42013
  })["catch"](function (error) {
@@ -42010,7 +42016,7 @@ var VideoPreview = /*#__PURE__*/memo(function VideoPreview(_ref) {
42010
42016
  return function () {
42011
42017
  cancelled = true;
42012
42018
  };
42013
- }, [videoThumb, downloadedPreviewImage, dispatch, messageType]);
42019
+ }, [videoThumb, downloadedPreviewImage, dispatch, messageType, file.messageId]);
42014
42020
  useEffect(function () {
42015
42021
  var videoSource = src;
42016
42022
  var canExtractFirstFrame = shouldExtractVideoFirstFrame(file.metadata);
@@ -42155,7 +42161,7 @@ var VideoPreview = /*#__PURE__*/memo(function VideoPreview(_ref) {
42155
42161
  messageTimeBackgroundColor: overlayBackground2
42156
42162
  }, !isRepliedMessage && !isPreview && /*#__PURE__*/React__default.createElement(SvgVideoCall, null), videoCurrentTime))));
42157
42163
  }, function (prev, next) {
42158
- return prev.src === next.src && prev.file.id === next.file.id && prev.file.url === next.file.url && prev.file.metadata === next.file.metadata && prev.uploading === next.uploading && prev.downloading === next.downloading && prev.width === next.width && prev.height === next.height && prev.borderRadius === next.borderRadius && prev.isRepliedMessage === next.isRepliedMessage && prev.isDetailsView === next.isDetailsView;
42164
+ return prev.src === next.src && prev.file.id === next.file.id && prev.file.messageId === next.file.messageId && prev.messageType === next.messageType && prev.file.url === next.file.url && prev.file.metadata === next.file.metadata && prev.uploading === next.uploading && prev.downloading === next.downloading && prev.width === next.width && prev.height === next.height && prev.borderRadius === next.borderRadius && prev.isRepliedMessage === next.isRepliedMessage && prev.isDetailsView === next.isDetailsView;
42159
42165
  });
42160
42166
  var VideoControls = styled.div(_templateObject$t || (_templateObject$t = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 6;\n"])));
42161
42167
  var VideoTime = styled.div(_templateObject2$q || (_templateObject2$q = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: ", ";\n bottom: ", ";\n left: ", ";\n font-size: ", ";\n display: flex;\n align-items: center;\n border-radius: 16px;\n padding: ", ";\n background-color: ", ";\n line-height: 14px;\n color: ", ";\n z-index: 10;\n\n & > svg {\n color: ", ";\n margin-right: 4px;\n }\n"])), function (props) {
@@ -42436,7 +42442,7 @@ var Attachment = function Attachment(_ref) {
42436
42442
  e.stopPropagation();
42437
42443
  if (downloadIsCancelled) {
42438
42444
  setDownloadIsCancelled(false);
42439
- if (getCustomUploader()) {
42445
+ if (customDownloader) {
42440
42446
  handleResumeOriginalImageDownload(e);
42441
42447
  } else {
42442
42448
  downloadImage(attachment.url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.9.2-beta.2",
3
+ "version": "1.9.2-beta.3",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",