Skip to content

armgit / ente

Public Imported from GitHub
0

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

refractor(AllAlbums):strict-remote-pull

Aswin Asok4c170c26e60e
diff --git a/web/apps/photos/src/components/Collections/AllAlbums.tsx b/web/apps/photos/src/components/Collections/AllAlbums.tsx
index a4e3d82215..0e1c3597f8 100644
--- a/web/apps/photos/src/components/Collections/AllAlbums.tsx
+++ b/web/apps/photos/src/components/Collections/AllAlbums.tsx
@@ -20,6 +20,7 @@ import {
collectionDialogTitleSx as titleSx,
} from "@/components/CollectionDialog/styles";
import { CollectionsSortOptions } from "@/components/CollectionsSortOptions";
+import type { RemotePullOpts } from "@/components/gallery";
import { StarIcon } from "@/components/icons/StarIcon";
import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
import CloseIcon from "@mui/icons-material/Close";
@@ -138,7 +139,7 @@ interface AllAlbums {
onChangeCollectionsSortBy: (by: CollectionsSortBy) => void;
isInHiddenSection: boolean;
canCreateAlbum: boolean;
- onRemotePull: () => Promise<void>;
+ onRemotePull: (opts?: RemotePullOpts) => Promise<void>;
}
export const AllAlbums: React.FC<AllAlbums> = ({
@@ -240,7 +241,7 @@ export const AllAlbums: React.FC<AllAlbums> = ({
let confirmedCandidateIDs: number[];
try {
- await onRemotePull();
+ await onRemotePull({ strict: true });
const [collections, collectionFiles] = await Promise.all([
savedCollections(),
@@ -287,7 +288,7 @@ export const AllAlbums: React.FC<AllAlbums> = ({
let refreshFailed = false;
try {
- await onRemotePull();
+ await onRemotePull({ strict: true });
} catch {
refreshFailed = true;
}
diff --git a/web/apps/photos/src/components/gallery/index.tsx b/web/apps/photos/src/components/gallery/index.tsx
index 0f8d2043b8..d21434fd00 100644
--- a/web/apps/photos/src/components/gallery/index.tsx
+++ b/web/apps/photos/src/components/gallery/index.tsx
@@ -30,6 +30,7 @@ export { GalleryEmptyState } from "./GalleryEmptyState";
export interface RemotePullOpts {
silent?: boolean;
source?: string;
+ strict?: boolean;
}
export type SelectionContext =
| {
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index d62b4b30f0..e8b5b734a4 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -806,7 +806,7 @@ const Page: React.FC = () => {
const remotePull = useCallback(
async (opts?: RemotePullOpts) =>
remotePullQueue.current.add(async () => {
- const { silent, source } = opts ?? {};
+ const { silent, source, strict } = opts ?? {};
if (!navigator.onLine) return;
if (await isSessionInvalid()) {
@@ -827,6 +827,7 @@ const Page: React.FC = () => {
} catch (e) {
// A later pull retries transient failures after remote mutations.
log.error("Remote pull failed", e);
+ if (strict) throw e;
} finally {
dispatch({ type: "clearUnsyncedState" });
if (!silent) hideLoadingBar();