Skip to content

armgit / ente

Public Imported from GitHub
0

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

Download in bar

Manav Rathifd13c737aad0
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 3d85319753..36fc4067d7 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -403,7 +403,7 @@ const FileViewer: React.FC<FileViewerProps> = ({
})();
const showMore =
- showDelete || showEditImage || showDownload == "bar";
+ showDelete || showEditImage || showDownload == "menu";
return {
fileID,
diff --git a/web/packages/gallery/components/viewer/icons.tsx b/web/packages/gallery/components/viewer/icons.tsx
index 241d83638c..5c7c8dc5b1 100644
--- a/web/packages/gallery/components/viewer/icons.tsx
+++ b/web/packages/gallery/components/viewer/icons.tsx
@@ -29,6 +29,9 @@ const paths = {
'<path d="M13.35 20.13c-.76.69-1.93.69-2.69-.01l-.11-.1C5.3 15.27 1.87 12.16 2 8.28c.06-1.7.93-3.33 2.34-4.29 2.64-1.8 5.9-.96 7.66 1.1 1.76-2.06 5.02-2.91 7.66-1.1 1.41.96 2.28 2.59 2.34 4.29.14 3.88-3.3 6.99-8.55 11.76z" transform="translate(3, 3)"',
// "@mui/icons-material/MoreHoriz"
more: '<path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2" transform="translate(3, 4)"',
+ // "@mui/icons-material/FileDownloadOutlined"
+ download:
+ '<path d="M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5z"',
};
/**
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index 890d6fc164..2aded83324 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -67,6 +67,8 @@ export interface FileViewerFileAnnotation {
* - When "bar", the action button is shown among the bar icons.
*
* - When "menu", the action is shown as a more menu entry.
+ *
+ * Note: "bar" should only be set if {@link haveUser} is also true.
*/
showDownload: "bar" | "menu" | undefined;
/**
@@ -262,6 +264,7 @@ export class FileViewerPhotoSwipe {
onClose,
onAnnotate,
onViewInfo,
+ onDownload,
onMore,
}: FileViewerPhotoSwipeOptions) {
this.opts = { disableDownload };
@@ -566,7 +569,7 @@ export class FileViewerPhotoSwipe {
// up being shown, so they can safely share the same order.
pswp.ui.registerElement({
name: "favorite",
- title: t("favorite_key"),
+ title: t("favorite"),
order: 8,
isButton: true,
html: createPSRegisterElementIconHTML("favorite"),
@@ -578,7 +581,7 @@ export class FileViewerPhotoSwipe {
});
pswp.ui.registerElement({
name: "unfavorite",
- title: t("unfavorite_key"),
+ title: t("unfavorite"),
order: 8,
isButton: true,
html: createPSRegisterElementIconHTML("unfavorite"),
@@ -588,6 +591,27 @@ export class FileViewerPhotoSwipe {
showFavoriteIf(buttonElement, true),
),
});
+ } else {
+ // When we don't have a user (i.e. in the context of public
+ // albums), the download button is shown (if enabled for that
+ // album) instead of the favorite button as the first action.
+ //
+ // It can thus also use the same order as fav/unfav.
+ pswp.ui.registerElement({
+ name: "download",
+ title: t("download"),
+ order: 8,
+ isButton: true,
+ html: createPSRegisterElementIconHTML("download"),
+ onClick: () => onDownload(currentAnnotatedFile()),
+ onInit: (buttonElement) =>
+ pswp.on("change", () =>
+ showIf(
+ buttonElement,
+ currentFileAnnotation().showDownload == "bar",
+ ),
+ ),
+ });
}
pswp.ui.registerElement({