diff --git a/web/packages/gallery/components/viewer/icons.tsx b/web/packages/gallery/components/viewer/icons.tsx index d3739be83d..a0a295a498 100644 --- a/web/packages/gallery/components/viewer/icons.tsx +++ b/web/packages/gallery/components/viewer/icons.tsx @@ -23,6 +23,10 @@ const paths = { error: ' void; /** @@ -438,25 +436,51 @@ export class FileViewerPhotoSwipe { }); if (onToggleFavorite) { + // Only one of these two will end up being shown, so they can + // safely share the same order. pswp.ui.registerElement({ name: "favorite", - title: t("favorite"), - order: 15, + title: t("favorite_key"), + order: 8, isButton: true, html: createPSRegisterElementIconHTML("favorite"), onClick: withCurrentAnnotatedFile(onToggleFavorite), onInit: (buttonElement, pswp) => { - // TODO: - // pswp.on("change", () => - // buttonElement.classList.toggle( - // "pswp--ui-visible", - // currentFileAnnotation().isFavorite, - // ), - // ); + pswp.on("change", () => + buttonElement.classList.toggle( + "pswp--ui-visible", + currentFileAnnotation().isFavorite === false, + ), + ); + }, + }); + pswp.ui.registerElement({ + name: "unfavorite", + title: t("unfavorite_key"), + order: 8, + isButton: true, + html: createPSRegisterElementIconHTML("unfavorite"), + onClick: withCurrentAnnotatedFile(onToggleFavorite), + onInit: (buttonElement, pswp) => { + pswp.on("change", () => + buttonElement.classList.toggle( + "pswp--ui-visible", + currentFileAnnotation().isFavorite === true, + ), + ); }, }); } + pswp.ui.registerElement({ + name: "info", + title: t("info"), + order: 9, + isButton: true, + html: createPSRegisterElementIconHTML("info"), + onClick: withCurrentAnnotatedFile(onViewInfo), + }); + if (onEditImage) { pswp.ui.registerElement({ name: "edit", @@ -471,21 +495,12 @@ export class FileViewerPhotoSwipe { pswp.on("change", () => buttonElement.classList.toggle( "pswp--ui-visible", - currentFileAnnotation().isEditableImage, + !!currentFileAnnotation().isEditableImage, ), ); }, }); } - - pswp.ui.registerElement({ - name: "info", - title: t("info"), - order: 17, - isButton: true, - html: createPSRegisterElementIconHTML("info"), - onClick: withCurrentAnnotatedFile(onViewInfo), - }); }); // Modify the default UI elements.