π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Clear on error
Manav Rathidf2678f35855
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex f50af47519..75d458d3db 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -808,16 +808,27 @@ const Page: React.FC = () => {dispatch({type: "markPendingVisibilityUpdate",fileID,- visibility: "pending",+ mark: true,});- await changeFilesVisibility(files, visibility);- // See: [Note: File viewer update and dispatch]- dispatch({- type: "markUnsyncedVisibilityUpdate",- fileID,- visibility,- });+ try {+ await changeFilesVisibility(files, visibility);+ // See: [Note: File viewer update and dispatch]+ dispatch({+ type: "markUnsyncedVisibilityUpdate",+ fileID,+ visibility,+ });+ } catch (e) {+ // Clean pending requests on error (on success,+ // "markUnsyncedVisibilityUpdate" will do it for us).+ dispatch({+ type: "markPendingVisibilityUpdate",+ fileID,+ mark: false,+ });+ throw e;+ }},[],);diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.tsindex ac408d0dd3..31d0c2fde9 100644--- a/web/packages/new/photos/components/gallery/reducer.ts+++ b/web/packages/new/photos/components/gallery/reducer.ts@@ -414,9 +414,8 @@ export type GalleryAction =| {type: "markPendingVisibilityUpdate";fileID: number;- // Passing undefined clears any existing entry; passing "pending" adds- // one.- visibility: "pending" | undefined;+ // Passing `true` adds an entry, and `false` clears any existing one.+ mark: boolean;}| {type: "markUnsyncedVisibilityUpdate";@@ -877,10 +876,10 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (const pendingVisibilityUpdates = new Set(state.pendingVisibilityUpdates,);- if (action.visibility === undefined) {- pendingVisibilityUpdates.delete(action.fileID);- } else {+ if (action.mark) {pendingVisibilityUpdates.add(action.fileID);+ } else {+ pendingVisibilityUpdates.delete(action.fileID);}// Skipping a call to stateByUpdatingFilteredFiles since it// currently doesn't depend on pendingVisibilityUpdates.