Remove potentially illdefined forcing support

This commit is contained in:
Manav Rathi
2025-06-25 20:41:02 +05:30
parent 217b40a107
commit e38a39200a
5 changed files with 24 additions and 39 deletions

View File

@@ -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],

View File

@@ -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);

View File

@@ -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() {

View File

@@ -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,

View File

@@ -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;