π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Don't use exceptions for control flow
Manav Rathi86f859aaca0f
diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsxindex 9c3234fb26..e737fa5e0a 100644--- a/web/apps/photos/src/components/PhotoFrame.tsx+++ b/web/apps/photos/src/components/PhotoFrame.tsx@@ -192,6 +192,8 @@ const PhotoFrame = ({return <div />;}+ // Return a function which will return true if the URL was updated (for the+ // given params), and false otherwise.const updateURL =(index: number) => (id: number, url: string, forceUpdate?: boolean) => {const file = displayFiles[index];@@ -203,9 +205,10 @@ const PhotoFrame = ({throw Error("update url file id mismatch");}if (file.msrc && !forceUpdate) {- throw Error(CustomError.URL_ALREADY_SET);+ return false;}updateFileMsrcProps(file, url);+ return true;};const updateSrcURL = async (@@ -344,21 +347,20 @@ const PhotoFrame = ({thumbFetching[item.id] = true;const url = await DownloadManager.getThumbnailForPreview(item);try {- updateURL(index)(item.id, url);- log.info(- `[${item.id}] calling invalidateCurrItems for thumbnail msrc: ${!!item.msrc}`,- );- instance.invalidateCurrItems();- if ((instance as any).isOpen()) {- instance.updateSize(true);- }- } catch (e) {- if (e.message !== CustomError.URL_ALREADY_SET) {- log.error(- "updating photoswipe after msrc url update failed",- e,+ if (updateURL(index)(item.id, url)) {+ log.info(+ `[${item.id}] calling invalidateCurrItems for thumbnail msrc: ${!!item.msrc}`,);+ instance.invalidateCurrItems();+ if ((instance as any).isOpen()) {+ instance.updateSize(true);+ }}+ } catch (e) {+ log.error(+ "updating photoswipe after msrc url update failed",+ e,+ );// ignore}} catch (e) {@@ -491,13 +493,14 @@ const PhotoFrame = ({return;}try {- updateURL(index)(item.id, item.msrc, true);- log.info(- `[${item.id}] calling invalidateCurrItems for thumbnail msrc: ${!!item.msrc}`,- );- instance.invalidateCurrItems();- if ((instance as any).isOpen()) {- instance.updateSize(true);+ if (updateURL(index)(item.id, item.msrc, true)) {+ log.info(+ `[${item.id}] calling invalidateCurrItems for thumbnail msrc: ${!!item.msrc}`,+ );+ instance.invalidateCurrItems();+ if ((instance as any).isOpen()) {+ instance.updateSize(true);+ }}} catch (e) {if (e.message !== CustomError.URL_ALREADY_SET) {diff --git a/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx b/web/apps/photos/src/components/pages/gallery/PreviewCard.tsxindex 64a44ff335..6817ce7b17 100644--- a/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx+++ b/web/apps/photos/src/components/pages/gallery/PreviewCard.tsx@@ -12,7 +12,6 @@ import {} from "@/new/photos/components/PlaceholderThumbnails";import { TRASH_SECTION } from "@/new/photos/services/collection";import DownloadManager from "@/new/photos/services/download";-import { CustomError } from "@ente/shared/error";import useLongPress from "@ente/shared/hooks/useLongPress";import AlbumOutlined from "@mui/icons-material/AlbumOutlined";import Favorite from "@mui/icons-material/FavoriteRounded";@@ -286,9 +285,7 @@ export default function PreviewCard(props: IProps) {setImgSrc(url);updateURL(file.id, url);} catch (e) {- if (e.message !== CustomError.URL_ALREADY_SET) {- log.error("preview card useEffect failed", e);- }+ log.error("preview card useEffect failed", e);// no-op}};