Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix: hide edit on videos, live photos and raw

httpjamesm159994260554
diff --git a/apps/photos/src/components/PhotoViewer/index.tsx b/apps/photos/src/components/PhotoViewer/index.tsx
index d1890d503c..128698c724 100644
--- a/apps/photos/src/components/PhotoViewer/index.tsx
+++ b/apps/photos/src/components/PhotoViewer/index.tsx
@@ -12,6 +12,7 @@ import {
copyFileToClipboard,
getFileExtension,
getFileFromURL,
+ isRawFileFromFileName,
} from 'utils/file';
import { logError } from 'utils/sentry';
@@ -133,6 +134,30 @@ function PhotoViewer(props: Iprops) {
Map<number, number>
>(new Map());
+ const [showEditButton, setShowEditButton] = useState(false);
+
+ useEffect(() => {
+ const currentItem = photoSwipe?.currItem;
+
+ if (!currentItem) {
+ return;
+ }
+
+ const enteFile = currentItem as EnteFile;
+
+ const fileType = enteFile.metadata.fileType;
+
+ if (
+ fileType !== FILE_TYPE.IMAGE ||
+ isRawFileFromFileName(enteFile.metadata.title)
+ ) {
+ setShowEditButton(false);
+ return;
+ }
+
+ setShowEditButton(true);
+ }, [photoSwipe?.currItem]);
+
useEffect(() => {
if (publicCollectionGalleryContext.accessedThroughSharedURL) {
publicCollectionDownloadManager.setProgressUpdater(
@@ -777,14 +802,18 @@ function PhotoViewer(props: Iprops) {
!props.isTrashCollection &&
!props.isInHiddenSection && (
<>
- <button
- className="pswp__button pswp__button--custom"
- onClick={() => {
- props.onClose(false);
- setShowImageEditorOverlay(true);
- }}>
- <EditIcon />
- </button>
+ {showEditButton && (
+ <button
+ className="pswp__button pswp__button--custom"
+ onClick={() => {
+ props.onClose(false);
+ setShowImageEditorOverlay(
+ true
+ );
+ }}>
+ <EditIcon />
+ </button>
+ )}
<button
title={
isFav
diff --git a/apps/photos/src/utils/file/index.ts b/apps/photos/src/utils/file/index.ts
index f5f324d01b..06470eed4c 100644
--- a/apps/photos/src/utils/file/index.ts
+++ b/apps/photos/src/utils/file/index.ts
@@ -498,6 +498,15 @@ export function isRawFile(exactType: string) {
return RAW_FORMATS.includes(exactType.toLowerCase());
}
+export function isRawFileFromFileName(fileName: string) {
+ for (const rawFormat of RAW_FORMATS) {
+ if (fileName.toLowerCase().endsWith(rawFormat)) {
+ return true;
+ }
+ }
+ return false;
+}
+
export function isSupportedRawFormat(exactType: string) {
return SUPPORTED_RAW_FORMATS.includes(exactType.toLowerCase());
}