π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Single element 1
Manav Rathi781de2b60ba3
diff --git a/web/packages/gallery/components/viewer/icons.tsx b/web/packages/gallery/components/viewer/icons.tsxindex 127927c37e..aea783a5c9 100644--- a/web/packages/gallery/components/viewer/icons.tsx+++ b/web/packages/gallery/components/viewer/icons.tsx@@ -28,7 +28,7 @@ const paths = {favorite:'<path d="M19.66 3.99c-2.64-1.8-5.9-.96-7.66 1.1-1.76-2.06-5.02-2.91-7.66-1.1-1.4.96-2.28 2.58-2.34 4.29-.14 3.88 3.3 6.99 8.55 11.76l.1.09c.76.69 1.93.69 2.69-.01l.11-.1c5.25-4.76 8.68-7.87 8.55-11.75-.06-1.7-.94-3.32-2.34-4.28M12.1 18.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05" transform="translate(0, 5.5) scale(0.95)"',// "@mui/icons-material/FavoriteRounded"- unfavorite:+ "favorite-fill":'<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(0, 5.5) scale(0.95)"',// "@mui/icons-material/FileDownloadOutlined"download:@@ -39,6 +39,8 @@ const paths = {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(0, 4.5)"',};+type IconKeys = Exclude<keyof typeof paths, "favorite-fill">;+/*** Return an object that can be passed verbatim to the "html" option expected by* PhotoSwipe's registerElement function.@@ -55,8 +57,15 @@ const paths = {* }**/-export const createPSRegisterElementIconHTML = (name: "info") => ({+export const createPSRegisterElementIconHTML = (name: IconKeys) => ({isCustomSVG: true,- inner: `${paths[name]} id="pswp__icn-${name}" />`,+ inner:+ name == "favorite"+ ? favoriteInner()+ : `${paths[name]} id="pswp__icn-${name}" />`,outlineID: `pswp__icn-${name}`,});++// Favorite is a special case since it consists of two layers.+const favoriteInner = () =>+ `${paths.favorite} id="pswp__icn-favorite" />${paths["favorite-fill"]} id="pswp__icn-favorite-fill" />`;diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex a771221781..3361f5faa0 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -572,9 +572,10 @@ export class FileViewerPhotoSwipe {const af = currentAnnotatedFile();pendingFavoriteUpdates.add(af.file.id);favoriteButtonElement.disabled = true;- unfavoriteButtonElement.disabled = true;+ // unfavoriteButtonElement.disabled = true;await delegate.toggleFavorite(af);pendingFavoriteUpdates.delete(af.file.id);+ favoriteButtonElement.disabled = false;// TODO: We reload the entire slide instead of just updating// the button state. This is because there are two buttons,// instead of a single button toggling between two states@@ -582,7 +583,17 @@ export class FileViewerPhotoSwipe {//// To fix this, a single button can be achieved by moving// the fill of the heart as a layer.- this.refreshCurrentSlideContent();+ // this.refreshCurrentSlideContent();+ updateFavoriteButton();+ };++ const updateFavoriteButton = () => {+ const af = currentAnnotatedFile();+ const isFavorite = delegate.isFavorite(af);+ const fill = document.getElementById("pswp__icn-favorite-fill")!;+ console.log(fill, isFavorite);+ fill.style.display = isFavorite ? "initial" : "none";+ // if (fill) showIf(fill, isFavorite);};const handleToggleFavorite = () => void toggleFavorite();@@ -694,6 +705,8 @@ export class FileViewerPhotoSwipe {buttonElement: HTMLButtonElement,value: boolean,) => {+ updateFavoriteButton();+ return;const af = currentAnnotatedFile();const isFavorite = delegate.isFavorite(af);showIf(@@ -721,20 +734,20 @@ export class FileViewerPhotoSwipe {);},});- pswp.ui.registerElement({- name: "unfavorite",- title: pt("Favorite"),- order: 11,- isButton: true,- html: createPSRegisterElementIconHTML("unfavorite"),- onClick: handleToggleFavorite,- onInit: (buttonElement) => {- unfavoriteButtonElement = buttonElement;- pswp.on("change", () =>- showFavoriteIf(buttonElement, true),- );- },- });+ // pswp.ui.registerElement({+ // name: "unfavorite",+ // title: pt("Favorite"),+ // order: 11,+ // isButton: true,+ // html: createPSRegisterElementIconHTML("unfavorite"),+ // onClick: handleToggleFavorite,+ // onInit: (buttonElement) => {+ // unfavoriteButtonElement = buttonElement;+ // pswp.on("change", () =>+ // 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