From e79426e47ff2f29390b60750900f643c96fb0578 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 7 Jul 2025 11:11:05 +0530 Subject: [PATCH] Types --- .../gallery/components/utils/save-groups.ts | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/web/packages/gallery/components/utils/save-groups.ts b/web/packages/gallery/components/utils/save-groups.ts index cb9c15dde9..5dcfd8aa7d 100644 --- a/web/packages/gallery/components/utils/save-groups.ts +++ b/web/packages/gallery/components/utils/save-groups.ts @@ -58,7 +58,7 @@ export interface SaveGroup { */ total: number; /** - * The number of files that have already been save. + * The number of files that have been saved so far. */ success: number; /** @@ -68,7 +68,7 @@ export interface SaveGroup { /** * An {@link AbortController} that can be used to cancel the save. */ - canceller?: AbortController; + canceller: AbortController; } export const isSaveStarted = (group: SaveGroup) => group.total > 0; @@ -90,7 +90,7 @@ export const isSaveCompleteWithErrors = (group: SaveGroup) => * Return `true` if this save was cancelled on a user request. */ export const isSaveCancelled = (group: SaveGroup) => - group.canceller?.signal.aborted; + group.canceller.signal.aborted; /** * A function that can be used to add a save group. @@ -99,7 +99,17 @@ export const isSaveCancelled = (group: SaveGroup) => * by applying a transform to it (see {@link UpdateSaveGroup}). The UI will * react and update itself on updates done this way. */ -export type AddSaveGroup = (group: Partial) => UpdateSaveGroup; +export type AddSaveGroup = ( + group: Pick< + SaveGroup, + | "title" + | "collectionSummaryID" + | "isHiddenCollectionSummary" + | "downloadDirPath" + | "total" + | "canceller" + >, +) => UpdateSaveGroup; /** * A function that can be used to update a instance of a save group by applying @@ -133,15 +143,7 @@ export const useSaveGroups = () => { const id = Math.random(); setSaveGroups((groups) => [ ...groups, - { - ...saveGroup, - id, - // TODO(RE): - title: saveGroup.title ?? "", - total: saveGroup.total ?? 0, - success: 0, - failed: 0, - }, + { ...saveGroup, id, success: 0, failed: 0 }, ]); return (tx: (group: SaveGroup) => SaveGroup) => { setSaveGroups((groups) =>