add proper file and not checks

This commit is contained in:
Abhinav 2023-01-25 16:06:32 +05:30
parent cbee1c442b
commit 7a7f59ae1c

View file

@ -308,6 +308,7 @@ function PhotoViewer(props: Iprops) {
}); });
photoSwipe.listen('beforeChange', () => { photoSwipe.listen('beforeChange', () => {
const currItem = photoSwipe?.currItem as EnteFile; const currItem = photoSwipe?.currItem as EnteFile;
if (!currItem) return;
updateFavButton(currItem); updateFavButton(currItem);
if (currItem.metadata.fileType !== FILE_TYPE.IMAGE) { if (currItem.metadata.fileType !== FILE_TYPE.IMAGE) {
setExif({ key: currItem.src, value: null }); setExif({ key: currItem.src, value: null });
@ -325,6 +326,7 @@ function PhotoViewer(props: Iprops) {
}); });
photoSwipe.listen('resize', () => { photoSwipe.listen('resize', () => {
const currItem = photoSwipe?.currItem as EnteFile; const currItem = photoSwipe?.currItem as EnteFile;
if (!currItem) return;
if (currItem.metadata.fileType !== FILE_TYPE.IMAGE) { if (currItem.metadata.fileType !== FILE_TYPE.IMAGE) {
setExif({ key: currItem.src, value: null }); setExif({ key: currItem.src, value: null });
return; return;
@ -368,6 +370,7 @@ function PhotoViewer(props: Iprops) {
}; };
const onFavClick = async (file: EnteFile) => { const onFavClick = async (file: EnteFile) => {
if (!file) return;
const { favItemIds } = props; const { favItemIds } = props;
if (!isInFav(file)) { if (!isInFav(file)) {
favItemIds.add(file.id); favItemIds.add(file.id);
@ -390,7 +393,7 @@ function PhotoViewer(props: Iprops) {
}; };
const confirmTrashFile = (file: EnteFile) => { const confirmTrashFile = (file: EnteFile) => {
if (props.isSharedCollection || props.isTrashCollection) { if (!file || props.isSharedCollection || props.isTrashCollection) {
return; return;
} }
appContext.setDialogMessage(getTrashFileMessage(() => trashFile(file))); appContext.setDialogMessage(getTrashFileMessage(() => trashFile(file)));
@ -463,7 +466,7 @@ function PhotoViewer(props: Iprops) {
}; };
const downloadFileHelper = async (file) => { const downloadFileHelper = async (file) => {
if (props.enableDownload) { if (!file && props.enableDownload) {
appContext.startLoading(); appContext.startLoading();
await downloadFile( await downloadFile(
file, file,
@ -476,7 +479,7 @@ function PhotoViewer(props: Iprops) {
}; };
const copyToClipboardHelper = async (file: EnteFile) => { const copyToClipboardHelper = async (file: EnteFile) => {
if (props.enableDownload && shouldShowCopyOption) { if (!file && props.enableDownload && shouldShowCopyOption) {
appContext.startLoading(); appContext.startLoading();
await copyFileToClipboard(file.src); await copyFileToClipboard(file.src);
appContext.finishLoading(); appContext.finishLoading();