Attempt to enable shortcuts on photoView
This commit is contained in:
parent
bce60813fd
commit
c47ebfdc2e
|
@ -72,6 +72,34 @@ function PhotoViewer(props: Iprops) {
|
|||
|
||||
useEffect(() => {
|
||||
if (!pswpElement) return;
|
||||
function handleKeyUp(event) {
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
console.log(
|
||||
'Event: ' + event.key + ' isShiftPressedx: ' + event.shiftKey
|
||||
);
|
||||
switch (event.key) {
|
||||
case 'i':
|
||||
if (isOpen && !showInfo) {
|
||||
setShowInfo(true);
|
||||
}
|
||||
break;
|
||||
case 'Backspace':
|
||||
confirmTrashFile(photoSwipe?.currItem as EnteFile);
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
if (event.shiftKey) {
|
||||
downloadFileHelper(photoSwipe?.currItem as EnteFile);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('keyup', handleKeyUp);
|
||||
if (isOpen) {
|
||||
openPhotoSwipe();
|
||||
}
|
||||
|
@ -80,6 +108,8 @@ function PhotoViewer(props: Iprops) {
|
|||
}
|
||||
return () => {
|
||||
closePhotoSwipe();
|
||||
console.log('Removing listner');
|
||||
window.removeEventListener('keyup', handleKeyUp);
|
||||
};
|
||||
}, [isOpen]);
|
||||
|
||||
|
@ -277,8 +307,12 @@ function PhotoViewer(props: Iprops) {
|
|||
needUpdate.current = true;
|
||||
};
|
||||
|
||||
const confirmTrashFile = (file: EnteFile) =>
|
||||
const confirmTrashFile = (file: EnteFile) => {
|
||||
if (props.isSharedCollection || props.isTrashCollection) {
|
||||
return;
|
||||
}
|
||||
appContext.setDialogMessage(getTrashFileMessage(() => trashFile(file)));
|
||||
};
|
||||
|
||||
const updateItems = (items = []) => {
|
||||
if (photoSwipe) {
|
||||
|
@ -336,6 +370,7 @@ function PhotoViewer(props: Iprops) {
|
|||
};
|
||||
|
||||
const downloadFileHelper = async (file) => {
|
||||
if (props.enableDownload) {
|
||||
appContext.startLoading();
|
||||
await downloadFile(
|
||||
file,
|
||||
|
@ -343,8 +378,8 @@ function PhotoViewer(props: Iprops) {
|
|||
publicCollectionGalleryContext.token,
|
||||
publicCollectionGalleryContext.passwordToken
|
||||
);
|
||||
|
||||
appContext.finishLoading();
|
||||
}
|
||||
};
|
||||
const scheduleUpdate = () => (needUpdate.current = true);
|
||||
const { id } = props;
|
||||
|
|
Loading…
Reference in a new issue