Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove potentially illdefined forcing support

Manav Rathie38a39200a51
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index 5c722ad985..0b9aa1f2e5 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -154,7 +154,7 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({
} catch (e) {
onGenericError(e);
} finally {
- void syncWithRemote(false, true);
+ void syncWithRemote(true);
hideLoadingBar();
}
};
@@ -167,7 +167,7 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({
async (newName: string) => {
if (activeCollection.name !== newName) {
await renameCollection(activeCollection, newName);
- void syncWithRemote(false, true);
+ void syncWithRemote(true);
}
},
[activeCollection],
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index 623de19983..0a33c0d18d 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -112,7 +112,7 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
} catch (e) {
onGenericError(e);
} finally {
- void syncWithRemote(false, true);
+ void syncWithRemote(true);
hideLoadingBar();
}
};
@@ -477,7 +477,7 @@ const AddParticipant: React.FC<AddParticipantProps> = ({
}
if (emails.length) {
- await syncWithRemote(false, true);
+ await syncWithRemote(true);
}
onClose();
@@ -842,7 +842,7 @@ const ManageParticipant: React.FC<ManageParticipantProps> = ({
try {
await shareCollection(collection, selectedEmail, newRole);
selectedParticipant.role = newRole;
- await galleryContext.syncWithRemote(false, true);
+ await galleryContext.syncWithRemote(true);
} catch (e) {
log.error(handleSharingErrors(e), e);
}
@@ -1058,7 +1058,7 @@ const EnablePublicShareOptions: React.FC<EnablePublicShareOptionsProps> = ({
setPending("");
setPublicURL(publicURL);
onLinkCreated();
- void syncWithRemote(false, true);
+ void syncWithRemote(true);
})
.catch((e: unknown) => {
log.error("Could not create public link", e);
@@ -1223,7 +1223,7 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({
try {
galleryContext.setBlockingLoad(true);
setPublicURL(await updatePublicURL(collection.id, updates));
- galleryContext.syncWithRemote(false, true);
+ galleryContext.syncWithRemote(true);
} catch (e) {
log.error("Could not update public link", e);
setSharableLinkError(t("generic_error"));
@@ -1236,7 +1236,7 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({
galleryContext.setBlockingLoad(true);
await deleteShareURL(collection.id);
setPublicURL(undefined);
- galleryContext.syncWithRemote(false, true);
+ galleryContext.syncWithRemote(true);
onClose();
} catch (e) {
log.error("Failed to remove public link", e);
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsx
index 4336e9076b..cf15dd70ac 100644
--- a/web/apps/photos/src/components/Upload.tsx
+++ b/web/apps/photos/src/components/Upload.tsx
@@ -83,7 +83,7 @@ import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";
import { UploadProgress } from "./UploadProgress";
interface UploadProps {
- syncWithRemote: (force?: boolean, silent?: boolean) => Promise<void>;
+ syncWithRemote: (silent?: boolean) => Promise<void>;
closeUploadTypeSelector: () => void;
/**
* Show the collection selector with the given {@link attributes}.
@@ -676,7 +676,7 @@ export const Upload: React.FC<UploadProps> = ({
) => {
uploadManager.prepareForNewUpload(parsedMetadataJSONMap);
setUploadProgressView(true);
- await props.syncWithRemote(true, true);
+ await props.syncWithRemote(true);
};
function postUploadAction() {
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 7fdf5e02df..f4bd96da7d 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -133,9 +133,11 @@ import { getSelectedFiles, handleFileOp, type FileOp } from "utils/file";
* various actions within the gallery and its descendants.
*/
interface RemotePullOpts {
- /** Force a pull to happen (default: no) */
- force?: boolean;
- /** Perform the pull without showing a global loading bar (default: no) */
+ /**
+ * Perform the pull without showing a global loading bar
+ *
+ * Default: `false`.
+ */
silent?: boolean;
}
@@ -331,7 +333,7 @@ const Page: React.FC = () => {
collectionFiles: await savedCollectionFiles(),
trashItems: await savedTrashItems(),
});
- await remotePull({ force: true });
+ await remotePull();
setIsFirstLoad(false);
setJustSignedUp(false);
syncIntervalID = setInterval(
@@ -551,7 +553,7 @@ const Page: React.FC = () => {
const remotePull = useCallback(
async (opts?: RemotePullOpts) => {
- const { force, silent } = opts ?? {};
+ const { silent } = opts ?? {};
// Pre-flight checks.
if (!navigator.onLine) return;
@@ -565,15 +567,10 @@ const Page: React.FC = () => {
return;
}
- // Start or enqueue.
- let isForced = false;
+ // Enqueue if needed.
if (isPullInProgress.current) {
- if (force) {
- isForced = true;
- } else {
- pendingPullOpts.current = { force, silent };
- return;
- }
+ pendingPullOpts.current = { silent };
+ return;
}
// The pull itself.
@@ -582,16 +579,7 @@ const Page: React.FC = () => {
if (!silent) showLoadingBar();
await pullFilesPre();
await remoteFilesPull();
- // remotePull is called with the force flag set to true before
- // doing an upload. So it is possible, say when resuming a
- // pending upload, that we get two remote pulls happening in
- // parallel.
- //
- // Do the non-file-related post operations only for one of these
- // parallel ones.
- if (!isForced) {
- await pullFilesPost();
- }
+ await pullFilesPost();
} catch (e) {
log.error("Remote pull failed", e);
} finally {
@@ -913,8 +901,7 @@ const Page: React.FC = () => {
value={{
...defaultGalleryContext,
setActiveCollectionID: handleShowCollectionSummary,
- syncWithRemote: (force, silent) =>
- remotePull({ force, silent }),
+ syncWithRemote: (silent) => remotePull({ silent }),
setBlockingLoad,
photoListHeader,
user,
@@ -1060,9 +1047,7 @@ const Page: React.FC = () => {
<Upload
activeCollection={activeCollection}
- syncWithRemote={(force, silent) =>
- remotePull({ force, silent })
- }
+ syncWithRemote={(silent) => remotePull({ silent })}
closeUploadTypeSelector={setUploadTypeSelectorView.bind(
null,
false,
diff --git a/web/apps/photos/src/types/gallery/index.ts b/web/apps/photos/src/types/gallery/index.ts
index bb23e2f2d3..adb262ba6f 100644
--- a/web/apps/photos/src/types/gallery/index.ts
+++ b/web/apps/photos/src/types/gallery/index.ts
@@ -40,7 +40,7 @@ export interface MergedSourceURL {
export interface GalleryContextType {
setActiveCollectionID: (collectionID: number) => void;
- syncWithRemote: (force?: boolean, silent?: boolean) => Promise<void>;
+ syncWithRemote: (silent?: boolean) => Promise<void>;
setBlockingLoad: (value: boolean) => void;
photoListHeader: TimeStampListItem;
user: User;