sceyt-chat-react-uikit 1.9.0-beta.3 → 1.9.0-beta.4
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 +31 -121
- package/index.modern.js +31 -121
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -36249,7 +36249,7 @@ var Carousel = function Carousel(_ref) {
|
|
|
36249
36249
|
var lastInitialIndexRef = React.useRef(initialActiveIndex);
|
|
36250
36250
|
var transitionTimeoutRef = React.useRef(null);
|
|
36251
36251
|
var currentIndexRef = React.useRef(initialActiveIndex);
|
|
36252
|
-
React.
|
|
36252
|
+
React.useLayoutEffect(function () {
|
|
36253
36253
|
isInternalNavigationRef.current = false;
|
|
36254
36254
|
setCurrentIndex(initialActiveIndex);
|
|
36255
36255
|
currentIndexRef.current = initialActiveIndex;
|
|
@@ -38878,6 +38878,10 @@ var Attachment = function Attachment(_ref) {
|
|
|
38878
38878
|
if (typeof cachedThumb === 'string') {
|
|
38879
38879
|
dispatch(setUpdateMessageAttachmentAC(videoThumb, cachedThumb));
|
|
38880
38880
|
}
|
|
38881
|
+
if (isDetailsView) {
|
|
38882
|
+
setIsCached(true);
|
|
38883
|
+
return;
|
|
38884
|
+
}
|
|
38881
38885
|
return Promise.resolve(getAttachmentUrlFromCache(originalVideoCacheKey)["catch"](function () {
|
|
38882
38886
|
return false;
|
|
38883
38887
|
})).then(function (cachedOriginalVideo) {
|
|
@@ -38901,7 +38905,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38901
38905
|
return function () {
|
|
38902
38906
|
cancelled = true;
|
|
38903
38907
|
};
|
|
38904
|
-
}, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, originalVideoUrlFromMap, connectionStatus, dispatch]);
|
|
38908
|
+
}, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, isDetailsView, originalVideoUrlFromMap, connectionStatus, dispatch]);
|
|
38905
38909
|
React.useEffect(function () {
|
|
38906
38910
|
if (!attachment.attachmentUrl && connectionStatus === CONNECTION_STATUS.CONNECTED && attachment.id && !attachmentUrlFromMap && !(attachment.type === attachmentTypes.video && getVideoThumb(attachment.metadata)) && !(attachment.type === attachmentTypes.file || attachment.type === attachmentTypes.link)) {
|
|
38907
38911
|
var requestAttachmentKey = attachmentKey;
|
|
@@ -40581,6 +40585,16 @@ var DeleteOptionItem = styled__default.div(_templateObject2$t || (_templateObjec
|
|
|
40581
40585
|
});
|
|
40582
40586
|
|
|
40583
40587
|
var _templateObject$x, _templateObject2$u, _templateObject3$o, _templateObject4$l, _templateObject5$h, _templateObject6$e, _templateObject7$d, _templateObject8$b, _templateObject9$a, _templateObject0$9, _templateObject1$8, _templateObject10$6, _templateObject11$5, _templateObject12$5, _templateObject13$5, _templateObject14$5;
|
|
40588
|
+
var getMediaThumbnailSource = function getMediaThumbnailSource(file) {
|
|
40589
|
+
var metadata = isJSON(file.metadata) ? JSON.parse(file.metadata) : file.metadata;
|
|
40590
|
+
var thumbnail = metadata === null || metadata === void 0 ? void 0 : metadata.tmb;
|
|
40591
|
+
if (!thumbnail || typeof thumbnail !== 'string') return undefined;
|
|
40592
|
+
try {
|
|
40593
|
+
return thumbnail.length < 70 ? base64ToDataURL(thumbnail) : "data:image/jpeg;base64," + thumbnail;
|
|
40594
|
+
} catch (_unused) {
|
|
40595
|
+
return undefined;
|
|
40596
|
+
}
|
|
40597
|
+
};
|
|
40584
40598
|
var SliderPopup = function SliderPopup(_ref) {
|
|
40585
40599
|
var channel = _ref.channel,
|
|
40586
40600
|
setIsSliderOpen = _ref.setIsSliderOpen,
|
|
@@ -40642,11 +40656,6 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
40642
40656
|
var customDownloader = getCustomDownloader();
|
|
40643
40657
|
var contactsMap = useSelector(contactsMapSelector);
|
|
40644
40658
|
var attachmentsList = useSelector(attachmentsForPopupSelector, reactRedux.shallowEqual) || [];
|
|
40645
|
-
var previousListLengthRef = React.useRef(attachmentsList.length);
|
|
40646
|
-
var currentFileIdRef = React.useRef(currentFile === null || currentFile === void 0 ? void 0 : currentFile.id);
|
|
40647
|
-
var _useState0 = React.useState(false),
|
|
40648
|
-
skipTransition = _useState0[0],
|
|
40649
|
-
setSkipTransition = _useState0[1];
|
|
40650
40659
|
var attachmentUserName = currentFile ? currentFile.user && makeUsername(contactsMap[currentFile.user.id], currentFile.user, getFromContacts && user.id !== currentFile.user.id) : '';
|
|
40651
40660
|
var handleClosePopup = function handleClosePopup() {
|
|
40652
40661
|
setIsSliderOpen(false);
|
|
@@ -40887,71 +40896,9 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
40887
40896
|
}
|
|
40888
40897
|
}, [attachmentsList]);
|
|
40889
40898
|
React.useEffect(function () {
|
|
40890
|
-
|
|
40891
|
-
var attachmentUrl = currentMediaFile.url + prefixUrl;
|
|
40892
|
-
getAttachmentUrlFromCache(attachmentUrl).then(function (cachedUrl) {
|
|
40893
|
-
if (cachedUrl) {
|
|
40894
|
-
if (currentMediaFile.type === 'image') {
|
|
40895
|
-
downloadImage(cachedUrl, false, 'image');
|
|
40896
|
-
} else {
|
|
40897
|
-
dispatch(setUpdateMessageAttachmentAC(attachmentUrl, cachedUrl));
|
|
40898
|
-
setPlayedVideo(currentMediaFile.id);
|
|
40899
|
-
}
|
|
40900
|
-
} else {
|
|
40901
|
-
if (customDownloader) {
|
|
40902
|
-
customDownloader(currentMediaFile.url, false, function () {}, messageType).then(function (url) {
|
|
40903
|
-
try {
|
|
40904
|
-
var _temp0 = _catch(function () {
|
|
40905
|
-
return Promise.resolve(fetch(url)).then(function (response) {
|
|
40906
|
-
setAttachmentToCache(attachmentUrl, response);
|
|
40907
|
-
if (currentMediaFile.type === 'image') {
|
|
40908
|
-
downloadImage(url, false, 'image');
|
|
40909
|
-
} else {
|
|
40910
|
-
dispatch(setUpdateMessageAttachmentAC(attachmentUrl, url));
|
|
40911
|
-
setPlayedVideo(currentMediaFile.id);
|
|
40912
|
-
}
|
|
40913
|
-
});
|
|
40914
|
-
}, function (error) {
|
|
40915
|
-
log.error('Error fetching initial attachment:', error);
|
|
40916
|
-
});
|
|
40917
|
-
return Promise.resolve(_temp0 && _temp0.then ? _temp0.then(function () {}) : void 0);
|
|
40918
|
-
} catch (e) {
|
|
40919
|
-
return Promise.reject(e);
|
|
40920
|
-
}
|
|
40921
|
-
})["catch"](function (error) {
|
|
40922
|
-
log.error('Error downloading initial attachment:', error);
|
|
40923
|
-
});
|
|
40924
|
-
} else {
|
|
40925
|
-
if (currentMediaFile.type === 'image') {
|
|
40926
|
-
downloadImage(attachmentUrl, false, 'image');
|
|
40927
|
-
} else {
|
|
40928
|
-
dispatch(setUpdateMessageAttachmentAC(attachmentUrl, currentMediaFile.url));
|
|
40929
|
-
setPlayedVideo(currentMediaFile.id);
|
|
40930
|
-
}
|
|
40931
|
-
}
|
|
40932
|
-
}
|
|
40933
|
-
})["catch"](function (error) {
|
|
40934
|
-
log.error('Error getting initial attachment from cache:', error);
|
|
40935
|
-
});
|
|
40936
|
-
}
|
|
40937
|
-
var foundInStaleList = !!attachmentsList.find(function (item) {
|
|
40938
|
-
return item.id === currentMediaFile.id;
|
|
40939
|
-
});
|
|
40940
|
-
console.log('[MEDIA_OPEN] 4.slider-mount ' + JSON.stringify({
|
|
40941
|
-
attId: currentMediaFile.id,
|
|
40942
|
-
name: currentMediaFile.name,
|
|
40943
|
-
msgId: currentMediaFile.messageId,
|
|
40944
|
-
staleListLen: attachmentsList.length,
|
|
40945
|
-
foundInStaleList: foundInStaleList,
|
|
40946
|
-
staleListIds: attachmentsList.slice(0, 5).map(function (item) {
|
|
40947
|
-
return item.id;
|
|
40948
|
-
})
|
|
40949
|
-
}));
|
|
40950
|
-
if (!foundInStaleList) {
|
|
40951
|
-
dispatch(setAttachmentsForPopupAC([currentMediaFile]));
|
|
40952
|
-
}
|
|
40899
|
+
dispatch(setAttachmentsForPopupAC([currentMediaFile]));
|
|
40953
40900
|
dispatch(getAttachmentsAC(channel.id, channelDetailsTabs.media, 34, queryDirection.NEAR, currentMediaFile.id, true));
|
|
40954
|
-
}, []);
|
|
40901
|
+
}, [channel.id, currentMediaFile, dispatch]);
|
|
40955
40902
|
var activeFileIndex = React.useMemo(function () {
|
|
40956
40903
|
if (!(currentFile !== null && currentFile !== void 0 && currentFile.id)) return -1;
|
|
40957
40904
|
var index = attachmentsList.findIndex(function (item) {
|
|
@@ -40966,50 +40913,13 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
40966
40913
|
return index;
|
|
40967
40914
|
}, [attachmentsList, currentFile]);
|
|
40968
40915
|
React.useEffect(function () {
|
|
40969
|
-
var
|
|
40970
|
-
|
|
40971
|
-
|
|
40972
|
-
|
|
40973
|
-
|
|
40974
|
-
setSkipTransition(true);
|
|
40975
|
-
var newIndex = attachmentsList.findIndex(function (item) {
|
|
40976
|
-
return item.id === currentFileId;
|
|
40977
|
-
});
|
|
40978
|
-
console.log('[MEDIA_OPEN] 6.list-grew ' + JSON.stringify({
|
|
40979
|
-
prevLen: previousLength,
|
|
40980
|
-
newLen: newLength,
|
|
40981
|
-
attId: currentFileId,
|
|
40982
|
-
newIndex: newIndex,
|
|
40983
|
-
activeFileIndex: activeFileIndex
|
|
40984
|
-
}));
|
|
40985
|
-
if (newIndex >= 0) {
|
|
40986
|
-
if (newIndex !== activeFileIndex) {
|
|
40987
|
-
var newFile = attachmentsList[newIndex];
|
|
40988
|
-
if (newFile) {
|
|
40989
|
-
setCurrentFile(newFile);
|
|
40990
|
-
}
|
|
40991
|
-
}
|
|
40992
|
-
timeoutId = setTimeout(function () {
|
|
40993
|
-
requestAnimationFrame(function () {
|
|
40994
|
-
requestAnimationFrame(function () {
|
|
40995
|
-
setSkipTransition(false);
|
|
40996
|
-
});
|
|
40997
|
-
});
|
|
40998
|
-
}, 150);
|
|
40999
|
-
} else {
|
|
41000
|
-
timeoutId = setTimeout(function () {
|
|
41001
|
-
setSkipTransition(false);
|
|
41002
|
-
}, 150);
|
|
41003
|
-
}
|
|
40916
|
+
var latestCurrentFile = attachmentsList.find(function (file) {
|
|
40917
|
+
return file.id === currentFile.id;
|
|
40918
|
+
});
|
|
40919
|
+
if (latestCurrentFile && latestCurrentFile !== currentFile) {
|
|
40920
|
+
setCurrentFile(latestCurrentFile);
|
|
41004
40921
|
}
|
|
41005
|
-
|
|
41006
|
-
currentFileIdRef.current = currentFileId;
|
|
41007
|
-
return function () {
|
|
41008
|
-
if (timeoutId) {
|
|
41009
|
-
clearTimeout(timeoutId);
|
|
41010
|
-
}
|
|
41011
|
-
};
|
|
41012
|
-
}, [attachmentsList.length, currentFile === null || currentFile === void 0 ? void 0 : currentFile.id, activeFileIndex, attachmentsList]);
|
|
40922
|
+
}, [attachmentsList, currentFile]);
|
|
41013
40923
|
var handleCarouselItemMouseDown = React.useCallback(function (e) {
|
|
41014
40924
|
if (e.button === 2) {
|
|
41015
40925
|
e.stopPropagation();
|
|
@@ -41108,7 +41018,6 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
41108
41018
|
pagination: false,
|
|
41109
41019
|
className: 'custom_carousel',
|
|
41110
41020
|
initialActiveIndex: activeFileIndex >= 0 ? activeFileIndex : 0,
|
|
41111
|
-
skipTransition: skipTransition,
|
|
41112
41021
|
onNextStart: function onNextStart() {
|
|
41113
41022
|
setReadyToPlay(false);
|
|
41114
41023
|
loadNextMoreAttachments();
|
|
@@ -41166,11 +41075,11 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
41166
41075
|
}
|
|
41167
41076
|
}, isItemLoading(file.id) && file.type === 'image' && (/*#__PURE__*/React__default.createElement(ItemLoadingCont, null, /*#__PURE__*/React__default.createElement(UploadingIcon, {
|
|
41168
41077
|
color: textOnPrimary
|
|
41169
|
-
}))), file.type === 'image' ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, attachmentUpdatedMap[getAttachmentURLWithVersion(file.url + '_original_image_url')] && (/*#__PURE__*/React__default.createElement("img", {
|
|
41170
|
-
loading: '
|
|
41078
|
+
}))), file.type === 'image' ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, (attachmentUpdatedMap[getAttachmentURLWithVersion(file.url + '_original_image_url')] || getMediaThumbnailSource(file)) && (/*#__PURE__*/React__default.createElement("img", {
|
|
41079
|
+
loading: 'eager',
|
|
41171
41080
|
decoding: 'async',
|
|
41172
41081
|
draggable: false,
|
|
41173
|
-
src: attachmentUpdatedMap[getAttachmentURLWithVersion(file.url + '_original_image_url')],
|
|
41082
|
+
src: attachmentUpdatedMap[getAttachmentURLWithVersion(file.url + '_original_image_url')] || getMediaThumbnailSource(file),
|
|
41174
41083
|
alt: file.name || 'Attachment',
|
|
41175
41084
|
onMouseDown: function onMouseDown(e) {
|
|
41176
41085
|
if (e.button === 2) {
|
|
@@ -41180,7 +41089,7 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
41180
41089
|
style: {
|
|
41181
41090
|
position: 'relative',
|
|
41182
41091
|
zIndex: 2,
|
|
41183
|
-
opacity:
|
|
41092
|
+
opacity: 1
|
|
41184
41093
|
},
|
|
41185
41094
|
onLoad: function onLoad() {
|
|
41186
41095
|
var fileId = file.id;
|
|
@@ -41255,7 +41164,7 @@ var IconWrapper = styled__default.span(_templateObject10$6 || (_templateObject10
|
|
|
41255
41164
|
}, function (props) {
|
|
41256
41165
|
return props.hideInMobile && "\n @media (max-width: 550px) {\n display: none;\n }\n ";
|
|
41257
41166
|
});
|
|
41258
|
-
var CarouselItem$1 = styled__default.div(_templateObject11$5 || (_templateObject11$5 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n max-width: calc(100% - 200px);\n z-index: 2;\n\n img,\n video {\n
|
|
41167
|
+
var CarouselItem$1 = styled__default.div(_templateObject11$5 || (_templateObject11$5 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n width: calc(100% - 200px);\n height: calc(100% - 80px);\n max-width: calc(100% - 200px);\n max-height: calc(100vh - 140px);\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n img,\n video {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n object-fit: contain;\n @media (max-width: 480px) {\n width: 100%;\n }\n }\n @media (max-width: 480px) {\n width: calc(100% - 100px);\n height: calc(100% - 48px);\n max-width: calc(100% - 100px);\n }\n\n img {\n display: block;\n }\n"])));
|
|
41259
41168
|
var UploadCont$1 = styled__default.div(_templateObject12$5 || (_templateObject12$5 = _taggedTemplateLiteralLoose(["\n left: calc((100vw - 100%) / -2);\n top: calc((100vh - 100%) / -2);\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n z-index: 1;\n"])));
|
|
41260
41169
|
var ItemLoadingCont = styled__default.div(_templateObject13$5 || (_templateObject13$5 = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: calc((100vw - 100%) / -2);\n top: calc((100vh - 100% + 60px) / -2);\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n"])));
|
|
41261
41170
|
var ArrowButton = styled__default.button(_templateObject14$5 || (_templateObject14$5 = _taggedTemplateLiteralLoose(["\n min-width: 60px;\n max-width: 60px;\n height: 60px;\n margin-right: ", ";\n margin-left: ", ";\n border: none;\n color: ", ";\n background: transparent;\n box-sizing: border-box;\n border-radius: 50%;\n line-height: 1px;\n align-self: center;\n outline: none;\n cursor: pointer;\n visibility: ", ";\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n left: ", ";\n right: ", ";\n & > svg {\n width: 40px;\n height: 40px;\n }\n @media (max-width: 768px) {\n min-width: 36px;\n max-width: 36px;\n height: 36px;\n margin-right: ", ";\n margin-left: ", ";\n\n & > svg {\n width: 22px;\n height: 22px;\n }\n }\n @media (max-width: 450px) {\n min-width: 32px;\n max-width: 32px;\n height: 32px;\n\n & > svg {\n width: 20px;\n height: 20px;\n }\n }\n"])), function (props) {
|
|
@@ -57428,6 +57337,7 @@ var Media = function Media(_ref) {
|
|
|
57428
57337
|
var dispatch = useDispatch();
|
|
57429
57338
|
var handleMediaItemClick = function handleMediaItemClick(file) {
|
|
57430
57339
|
if (file !== null && file !== void 0 && file.id) {
|
|
57340
|
+
dispatch(setAttachmentsForPopupAC([file]));
|
|
57431
57341
|
setMediaFile(file);
|
|
57432
57342
|
}
|
|
57433
57343
|
};
|
|
@@ -57475,7 +57385,7 @@ var Media = function Media(_ref) {
|
|
|
57475
57385
|
year: 'numeric'
|
|
57476
57386
|
})), /*#__PURE__*/React__default.createElement(ItemsGrid, null, group.items.map(function (file, index) {
|
|
57477
57387
|
return /*#__PURE__*/React__default.createElement(MediaItem, {
|
|
57478
|
-
key: file.id + "_" + index
|
|
57388
|
+
key: file.id || file.messageId + "_" + index
|
|
57479
57389
|
}, /*#__PURE__*/React__default.createElement(Attachment$1, {
|
|
57480
57390
|
attachment: _extends({}, file, {
|
|
57481
57391
|
metadata: isJSON(file.metadata) ? JSON.parse(file.metadata) : file.metadata
|
package/index.modern.js
CHANGED
|
@@ -36229,7 +36229,7 @@ var Carousel = function Carousel(_ref) {
|
|
|
36229
36229
|
var lastInitialIndexRef = useRef(initialActiveIndex);
|
|
36230
36230
|
var transitionTimeoutRef = useRef(null);
|
|
36231
36231
|
var currentIndexRef = useRef(initialActiveIndex);
|
|
36232
|
-
|
|
36232
|
+
useLayoutEffect(function () {
|
|
36233
36233
|
isInternalNavigationRef.current = false;
|
|
36234
36234
|
setCurrentIndex(initialActiveIndex);
|
|
36235
36235
|
currentIndexRef.current = initialActiveIndex;
|
|
@@ -38858,6 +38858,10 @@ var Attachment = function Attachment(_ref) {
|
|
|
38858
38858
|
if (typeof cachedThumb === 'string') {
|
|
38859
38859
|
dispatch(setUpdateMessageAttachmentAC(videoThumb, cachedThumb));
|
|
38860
38860
|
}
|
|
38861
|
+
if (isDetailsView) {
|
|
38862
|
+
setIsCached(true);
|
|
38863
|
+
return;
|
|
38864
|
+
}
|
|
38861
38865
|
return Promise.resolve(getAttachmentUrlFromCache(originalVideoCacheKey)["catch"](function () {
|
|
38862
38866
|
return false;
|
|
38863
38867
|
})).then(function (cachedOriginalVideo) {
|
|
@@ -38881,7 +38885,7 @@ var Attachment = function Attachment(_ref) {
|
|
|
38881
38885
|
return function () {
|
|
38882
38886
|
cancelled = true;
|
|
38883
38887
|
};
|
|
38884
|
-
}, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, originalVideoUrlFromMap, connectionStatus, dispatch]);
|
|
38888
|
+
}, [attachment.id, attachment.type, attachment.url, attachment.metadata, attachment.attachmentUrl, isDetailsView, originalVideoUrlFromMap, connectionStatus, dispatch]);
|
|
38885
38889
|
useEffect(function () {
|
|
38886
38890
|
if (!attachment.attachmentUrl && connectionStatus === CONNECTION_STATUS.CONNECTED && attachment.id && !attachmentUrlFromMap && !(attachment.type === attachmentTypes.video && getVideoThumb(attachment.metadata)) && !(attachment.type === attachmentTypes.file || attachment.type === attachmentTypes.link)) {
|
|
38887
38891
|
var requestAttachmentKey = attachmentKey;
|
|
@@ -40561,6 +40565,16 @@ var DeleteOptionItem = styled.div(_templateObject2$t || (_templateObject2$t = _t
|
|
|
40561
40565
|
});
|
|
40562
40566
|
|
|
40563
40567
|
var _templateObject$x, _templateObject2$u, _templateObject3$o, _templateObject4$l, _templateObject5$h, _templateObject6$e, _templateObject7$d, _templateObject8$b, _templateObject9$a, _templateObject0$9, _templateObject1$8, _templateObject10$6, _templateObject11$5, _templateObject12$5, _templateObject13$5, _templateObject14$5;
|
|
40568
|
+
var getMediaThumbnailSource = function getMediaThumbnailSource(file) {
|
|
40569
|
+
var metadata = isJSON(file.metadata) ? JSON.parse(file.metadata) : file.metadata;
|
|
40570
|
+
var thumbnail = metadata === null || metadata === void 0 ? void 0 : metadata.tmb;
|
|
40571
|
+
if (!thumbnail || typeof thumbnail !== 'string') return undefined;
|
|
40572
|
+
try {
|
|
40573
|
+
return thumbnail.length < 70 ? base64ToDataURL(thumbnail) : "data:image/jpeg;base64," + thumbnail;
|
|
40574
|
+
} catch (_unused) {
|
|
40575
|
+
return undefined;
|
|
40576
|
+
}
|
|
40577
|
+
};
|
|
40564
40578
|
var SliderPopup = function SliderPopup(_ref) {
|
|
40565
40579
|
var channel = _ref.channel,
|
|
40566
40580
|
setIsSliderOpen = _ref.setIsSliderOpen,
|
|
@@ -40622,11 +40636,6 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
40622
40636
|
var customDownloader = getCustomDownloader();
|
|
40623
40637
|
var contactsMap = useSelector(contactsMapSelector);
|
|
40624
40638
|
var attachmentsList = useSelector(attachmentsForPopupSelector, shallowEqual) || [];
|
|
40625
|
-
var previousListLengthRef = useRef(attachmentsList.length);
|
|
40626
|
-
var currentFileIdRef = useRef(currentFile === null || currentFile === void 0 ? void 0 : currentFile.id);
|
|
40627
|
-
var _useState0 = useState(false),
|
|
40628
|
-
skipTransition = _useState0[0],
|
|
40629
|
-
setSkipTransition = _useState0[1];
|
|
40630
40639
|
var attachmentUserName = currentFile ? currentFile.user && makeUsername(contactsMap[currentFile.user.id], currentFile.user, getFromContacts && user.id !== currentFile.user.id) : '';
|
|
40631
40640
|
var handleClosePopup = function handleClosePopup() {
|
|
40632
40641
|
setIsSliderOpen(false);
|
|
@@ -40867,71 +40876,9 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
40867
40876
|
}
|
|
40868
40877
|
}, [attachmentsList]);
|
|
40869
40878
|
useEffect(function () {
|
|
40870
|
-
|
|
40871
|
-
var attachmentUrl = currentMediaFile.url + prefixUrl;
|
|
40872
|
-
getAttachmentUrlFromCache(attachmentUrl).then(function (cachedUrl) {
|
|
40873
|
-
if (cachedUrl) {
|
|
40874
|
-
if (currentMediaFile.type === 'image') {
|
|
40875
|
-
downloadImage(cachedUrl, false, 'image');
|
|
40876
|
-
} else {
|
|
40877
|
-
dispatch(setUpdateMessageAttachmentAC(attachmentUrl, cachedUrl));
|
|
40878
|
-
setPlayedVideo(currentMediaFile.id);
|
|
40879
|
-
}
|
|
40880
|
-
} else {
|
|
40881
|
-
if (customDownloader) {
|
|
40882
|
-
customDownloader(currentMediaFile.url, false, function () {}, messageType).then(function (url) {
|
|
40883
|
-
try {
|
|
40884
|
-
var _temp0 = _catch(function () {
|
|
40885
|
-
return Promise.resolve(fetch(url)).then(function (response) {
|
|
40886
|
-
setAttachmentToCache(attachmentUrl, response);
|
|
40887
|
-
if (currentMediaFile.type === 'image') {
|
|
40888
|
-
downloadImage(url, false, 'image');
|
|
40889
|
-
} else {
|
|
40890
|
-
dispatch(setUpdateMessageAttachmentAC(attachmentUrl, url));
|
|
40891
|
-
setPlayedVideo(currentMediaFile.id);
|
|
40892
|
-
}
|
|
40893
|
-
});
|
|
40894
|
-
}, function (error) {
|
|
40895
|
-
log.error('Error fetching initial attachment:', error);
|
|
40896
|
-
});
|
|
40897
|
-
return Promise.resolve(_temp0 && _temp0.then ? _temp0.then(function () {}) : void 0);
|
|
40898
|
-
} catch (e) {
|
|
40899
|
-
return Promise.reject(e);
|
|
40900
|
-
}
|
|
40901
|
-
})["catch"](function (error) {
|
|
40902
|
-
log.error('Error downloading initial attachment:', error);
|
|
40903
|
-
});
|
|
40904
|
-
} else {
|
|
40905
|
-
if (currentMediaFile.type === 'image') {
|
|
40906
|
-
downloadImage(attachmentUrl, false, 'image');
|
|
40907
|
-
} else {
|
|
40908
|
-
dispatch(setUpdateMessageAttachmentAC(attachmentUrl, currentMediaFile.url));
|
|
40909
|
-
setPlayedVideo(currentMediaFile.id);
|
|
40910
|
-
}
|
|
40911
|
-
}
|
|
40912
|
-
}
|
|
40913
|
-
})["catch"](function (error) {
|
|
40914
|
-
log.error('Error getting initial attachment from cache:', error);
|
|
40915
|
-
});
|
|
40916
|
-
}
|
|
40917
|
-
var foundInStaleList = !!attachmentsList.find(function (item) {
|
|
40918
|
-
return item.id === currentMediaFile.id;
|
|
40919
|
-
});
|
|
40920
|
-
console.log('[MEDIA_OPEN] 4.slider-mount ' + JSON.stringify({
|
|
40921
|
-
attId: currentMediaFile.id,
|
|
40922
|
-
name: currentMediaFile.name,
|
|
40923
|
-
msgId: currentMediaFile.messageId,
|
|
40924
|
-
staleListLen: attachmentsList.length,
|
|
40925
|
-
foundInStaleList: foundInStaleList,
|
|
40926
|
-
staleListIds: attachmentsList.slice(0, 5).map(function (item) {
|
|
40927
|
-
return item.id;
|
|
40928
|
-
})
|
|
40929
|
-
}));
|
|
40930
|
-
if (!foundInStaleList) {
|
|
40931
|
-
dispatch(setAttachmentsForPopupAC([currentMediaFile]));
|
|
40932
|
-
}
|
|
40879
|
+
dispatch(setAttachmentsForPopupAC([currentMediaFile]));
|
|
40933
40880
|
dispatch(getAttachmentsAC(channel.id, channelDetailsTabs.media, 34, queryDirection.NEAR, currentMediaFile.id, true));
|
|
40934
|
-
}, []);
|
|
40881
|
+
}, [channel.id, currentMediaFile, dispatch]);
|
|
40935
40882
|
var activeFileIndex = useMemo(function () {
|
|
40936
40883
|
if (!(currentFile !== null && currentFile !== void 0 && currentFile.id)) return -1;
|
|
40937
40884
|
var index = attachmentsList.findIndex(function (item) {
|
|
@@ -40946,50 +40893,13 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
40946
40893
|
return index;
|
|
40947
40894
|
}, [attachmentsList, currentFile]);
|
|
40948
40895
|
useEffect(function () {
|
|
40949
|
-
var
|
|
40950
|
-
|
|
40951
|
-
|
|
40952
|
-
|
|
40953
|
-
|
|
40954
|
-
setSkipTransition(true);
|
|
40955
|
-
var newIndex = attachmentsList.findIndex(function (item) {
|
|
40956
|
-
return item.id === currentFileId;
|
|
40957
|
-
});
|
|
40958
|
-
console.log('[MEDIA_OPEN] 6.list-grew ' + JSON.stringify({
|
|
40959
|
-
prevLen: previousLength,
|
|
40960
|
-
newLen: newLength,
|
|
40961
|
-
attId: currentFileId,
|
|
40962
|
-
newIndex: newIndex,
|
|
40963
|
-
activeFileIndex: activeFileIndex
|
|
40964
|
-
}));
|
|
40965
|
-
if (newIndex >= 0) {
|
|
40966
|
-
if (newIndex !== activeFileIndex) {
|
|
40967
|
-
var newFile = attachmentsList[newIndex];
|
|
40968
|
-
if (newFile) {
|
|
40969
|
-
setCurrentFile(newFile);
|
|
40970
|
-
}
|
|
40971
|
-
}
|
|
40972
|
-
timeoutId = setTimeout(function () {
|
|
40973
|
-
requestAnimationFrame(function () {
|
|
40974
|
-
requestAnimationFrame(function () {
|
|
40975
|
-
setSkipTransition(false);
|
|
40976
|
-
});
|
|
40977
|
-
});
|
|
40978
|
-
}, 150);
|
|
40979
|
-
} else {
|
|
40980
|
-
timeoutId = setTimeout(function () {
|
|
40981
|
-
setSkipTransition(false);
|
|
40982
|
-
}, 150);
|
|
40983
|
-
}
|
|
40896
|
+
var latestCurrentFile = attachmentsList.find(function (file) {
|
|
40897
|
+
return file.id === currentFile.id;
|
|
40898
|
+
});
|
|
40899
|
+
if (latestCurrentFile && latestCurrentFile !== currentFile) {
|
|
40900
|
+
setCurrentFile(latestCurrentFile);
|
|
40984
40901
|
}
|
|
40985
|
-
|
|
40986
|
-
currentFileIdRef.current = currentFileId;
|
|
40987
|
-
return function () {
|
|
40988
|
-
if (timeoutId) {
|
|
40989
|
-
clearTimeout(timeoutId);
|
|
40990
|
-
}
|
|
40991
|
-
};
|
|
40992
|
-
}, [attachmentsList.length, currentFile === null || currentFile === void 0 ? void 0 : currentFile.id, activeFileIndex, attachmentsList]);
|
|
40902
|
+
}, [attachmentsList, currentFile]);
|
|
40993
40903
|
var handleCarouselItemMouseDown = useCallback(function (e) {
|
|
40994
40904
|
if (e.button === 2) {
|
|
40995
40905
|
e.stopPropagation();
|
|
@@ -41088,7 +40998,6 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
41088
40998
|
pagination: false,
|
|
41089
40999
|
className: 'custom_carousel',
|
|
41090
41000
|
initialActiveIndex: activeFileIndex >= 0 ? activeFileIndex : 0,
|
|
41091
|
-
skipTransition: skipTransition,
|
|
41092
41001
|
onNextStart: function onNextStart() {
|
|
41093
41002
|
setReadyToPlay(false);
|
|
41094
41003
|
loadNextMoreAttachments();
|
|
@@ -41146,11 +41055,11 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
41146
41055
|
}
|
|
41147
41056
|
}, isItemLoading(file.id) && file.type === 'image' && (/*#__PURE__*/React__default.createElement(ItemLoadingCont, null, /*#__PURE__*/React__default.createElement(UploadingIcon, {
|
|
41148
41057
|
color: textOnPrimary
|
|
41149
|
-
}))), file.type === 'image' ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, attachmentUpdatedMap[getAttachmentURLWithVersion(file.url + '_original_image_url')] && (/*#__PURE__*/React__default.createElement("img", {
|
|
41150
|
-
loading: '
|
|
41058
|
+
}))), file.type === 'image' ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, (attachmentUpdatedMap[getAttachmentURLWithVersion(file.url + '_original_image_url')] || getMediaThumbnailSource(file)) && (/*#__PURE__*/React__default.createElement("img", {
|
|
41059
|
+
loading: 'eager',
|
|
41151
41060
|
decoding: 'async',
|
|
41152
41061
|
draggable: false,
|
|
41153
|
-
src: attachmentUpdatedMap[getAttachmentURLWithVersion(file.url + '_original_image_url')],
|
|
41062
|
+
src: attachmentUpdatedMap[getAttachmentURLWithVersion(file.url + '_original_image_url')] || getMediaThumbnailSource(file),
|
|
41154
41063
|
alt: file.name || 'Attachment',
|
|
41155
41064
|
onMouseDown: function onMouseDown(e) {
|
|
41156
41065
|
if (e.button === 2) {
|
|
@@ -41160,7 +41069,7 @@ var SliderPopup = function SliderPopup(_ref) {
|
|
|
41160
41069
|
style: {
|
|
41161
41070
|
position: 'relative',
|
|
41162
41071
|
zIndex: 2,
|
|
41163
|
-
opacity:
|
|
41072
|
+
opacity: 1
|
|
41164
41073
|
},
|
|
41165
41074
|
onLoad: function onLoad() {
|
|
41166
41075
|
var fileId = file.id;
|
|
@@ -41235,7 +41144,7 @@ var IconWrapper = styled.span(_templateObject10$6 || (_templateObject10$6 = _tag
|
|
|
41235
41144
|
}, function (props) {
|
|
41236
41145
|
return props.hideInMobile && "\n @media (max-width: 550px) {\n display: none;\n }\n ";
|
|
41237
41146
|
});
|
|
41238
|
-
var CarouselItem$1 = styled.div(_templateObject11$5 || (_templateObject11$5 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n max-width: calc(100% - 200px);\n z-index: 2;\n\n img,\n video {\n
|
|
41147
|
+
var CarouselItem$1 = styled.div(_templateObject11$5 || (_templateObject11$5 = _taggedTemplateLiteralLoose(["\n position: relative;\n display: flex;\n width: calc(100% - 200px);\n height: calc(100% - 80px);\n max-width: calc(100% - 200px);\n max-height: calc(100vh - 140px);\n align-items: center;\n justify-content: center;\n z-index: 2;\n\n img,\n video {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n object-fit: contain;\n @media (max-width: 480px) {\n width: 100%;\n }\n }\n @media (max-width: 480px) {\n width: calc(100% - 100px);\n height: calc(100% - 48px);\n max-width: calc(100% - 100px);\n }\n\n img {\n display: block;\n }\n"])));
|
|
41239
41148
|
var UploadCont$1 = styled.div(_templateObject12$5 || (_templateObject12$5 = _taggedTemplateLiteralLoose(["\n left: calc((100vw - 100%) / -2);\n top: calc((100vh - 100%) / -2);\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n z-index: 1;\n"])));
|
|
41240
41149
|
var ItemLoadingCont = styled.div(_templateObject13$5 || (_templateObject13$5 = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: calc((100vw - 100%) / -2);\n top: calc((100vh - 100% + 60px) / -2);\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n"])));
|
|
41241
41150
|
var ArrowButton = styled.button(_templateObject14$5 || (_templateObject14$5 = _taggedTemplateLiteralLoose(["\n min-width: 60px;\n max-width: 60px;\n height: 60px;\n margin-right: ", ";\n margin-left: ", ";\n border: none;\n color: ", ";\n background: transparent;\n box-sizing: border-box;\n border-radius: 50%;\n line-height: 1px;\n align-self: center;\n outline: none;\n cursor: pointer;\n visibility: ", ";\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n left: ", ";\n right: ", ";\n & > svg {\n width: 40px;\n height: 40px;\n }\n @media (max-width: 768px) {\n min-width: 36px;\n max-width: 36px;\n height: 36px;\n margin-right: ", ";\n margin-left: ", ";\n\n & > svg {\n width: 22px;\n height: 22px;\n }\n }\n @media (max-width: 450px) {\n min-width: 32px;\n max-width: 32px;\n height: 32px;\n\n & > svg {\n width: 20px;\n height: 20px;\n }\n }\n"])), function (props) {
|
|
@@ -57408,6 +57317,7 @@ var Media = function Media(_ref) {
|
|
|
57408
57317
|
var dispatch = useDispatch();
|
|
57409
57318
|
var handleMediaItemClick = function handleMediaItemClick(file) {
|
|
57410
57319
|
if (file !== null && file !== void 0 && file.id) {
|
|
57320
|
+
dispatch(setAttachmentsForPopupAC([file]));
|
|
57411
57321
|
setMediaFile(file);
|
|
57412
57322
|
}
|
|
57413
57323
|
};
|
|
@@ -57455,7 +57365,7 @@ var Media = function Media(_ref) {
|
|
|
57455
57365
|
year: 'numeric'
|
|
57456
57366
|
})), /*#__PURE__*/React__default.createElement(ItemsGrid, null, group.items.map(function (file, index) {
|
|
57457
57367
|
return /*#__PURE__*/React__default.createElement(MediaItem, {
|
|
57458
|
-
key: file.id + "_" + index
|
|
57368
|
+
key: file.id || file.messageId + "_" + index
|
|
57459
57369
|
}, /*#__PURE__*/React__default.createElement(Attachment$1, {
|
|
57460
57370
|
attachment: _extends({}, file, {
|
|
57461
57371
|
metadata: isJSON(file.metadata) ? JSON.parse(file.metadata) : file.metadata
|