Web: Common: fixed the ability to spam deleting a media file with hotkey

This commit is contained in:
DmitrySychugov 2023-02-14 17:32:55 +05:00
parent 596f4213b5
commit c8da0fe2c6

View File

@ -267,17 +267,24 @@ function MediaViewer({
return 0 <= posExt ? fileTitle.substring(posExt).trim().toLowerCase() : "";
}, []);
let isRemoved: null | number = null;
const onDelete = () => {
const { playlist, onDelete } = props;
let currentFileId = playlist.find((file) => file.id === playlistPos)
?.fileId;
if (currentFileId === isRemoved) return;
const canDelete = targetFile?.security?.Delete;
if (!canDelete) return;
if (!isNullOrUndefined(currentFileId)) onDelete(currentFileId);
if (!isNullOrUndefined(currentFileId)) {
onDelete(currentFileId);
isRemoved = currentFileId;
}
};
const onDownload = () => {