diff --git a/src/frontend/App.svelte b/src/frontend/App.svelte index 9c0cbf77..887a8c5f 100644 --- a/src/frontend/App.svelte +++ b/src/frontend/App.svelte @@ -62,19 +62,9 @@ let destination: NamedRecord | null = null; let errors: Array | null = null; - function move(forceNonEmpty = false): void { - currentTab = "moving"; - moving = true; - google.script.run - .withSuccessHandler(moveSuccessHandler) - .withFailureHandler(moveErrorHandler) - .move( - source!.id, - destination!.id, - copyComments, - mergeFolders, - forceNonEmpty, - ); + function showErrorDialog(message: string): void { + errorMessage = message; + errorDialogOpen = true; } function moveSuccessHandler(response: MoveResponse): void { @@ -109,6 +99,7 @@ function moveErrorHandler(response: Error): void { if (response.name === "ScriptError") { + // eslint-disable-next-line @typescript-eslint/no-use-before-define -- Cyclical dependency move(); return; } @@ -119,9 +110,19 @@ ); } - function showErrorDialog(message: string): void { - errorMessage = message; - errorDialogOpen = true; + function move(forceNonEmpty = false): void { + currentTab = "moving"; + moving = true; + google.script.run + .withSuccessHandler(moveSuccessHandler) + .withFailureHandler(moveErrorHandler) + .move( + source!.id, + destination!.id, + copyComments, + mergeFolders, + forceNonEmpty, + ); } function showErrorDialogWithEvent( diff --git a/src/frontend/FolderSelection.svelte b/src/frontend/FolderSelection.svelte index f96b550b..23a39079 100644 --- a/src/frontend/FolderSelection.svelte +++ b/src/frontend/FolderSelection.svelte @@ -16,24 +16,6 @@ let items: Array | null = null; - function rootNavigation(): void { - selected = null; - path = []; - getItems(); - } - - function breadcrumbNavigation(segment: NamedRecord): void { - selected = null; - path = path.slice(0, path.findIndex((item) => item.id === segment.id) + 1); - getItems(); - } - - function itemNavigation(item: NamedRecord): void { - selected = null; - path = [...path, item]; - getItems(); - } - function handleListError(type: string): void { switch (type) { case "DriveAPIError": @@ -62,6 +44,12 @@ items = [{ id: "root", name: $_("drive.myDrive") }, ...response.response]; } + function handleError(response: Error): void { + dispatch("error", { + message: $_("errorDialog.unknownErrorWithMessage") + response.message, + }); + } + function handleFolderResponse(response: ListResponse): void { if (response.status === "error") { handleListError(response.type); @@ -70,12 +58,6 @@ items = response.response; } - function handleError(response: Error): void { - dispatch("error", { - message: $_("errorDialog.unknownErrorWithMessage") + response.message, - }); - } - function getItems(): void { items = null; if (path.length === 0) { @@ -91,6 +73,24 @@ } } + function rootNavigation(): void { + selected = null; + path = []; + getItems(); + } + + function breadcrumbNavigation(segment: NamedRecord): void { + selected = null; + path = path.slice(0, path.findIndex((item) => item.id === segment.id) + 1); + getItems(); + } + + function itemNavigation(item: NamedRecord): void { + selected = null; + path = [...path, item]; + getItems(); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Needed because SMUI doesn't provide types for the event function handleItemKeydown(e: any, item: NamedRecord): void { if ((e as KeyboardEvent).key === "ArrowRight") { diff --git a/src/frontend/Moving.svelte b/src/frontend/Moving.svelte index 3a4cc95d..c7c30e26 100644 --- a/src/frontend/Moving.svelte +++ b/src/frontend/Moving.svelte @@ -4,6 +4,8 @@ import { createEventDispatcher } from "svelte"; import { _ } from "svelte-i18n"; + let nonEmptyDialogOpen: boolean; + export function showNonEmptyDialog(): void { nonEmptyDialogOpen = true; } @@ -12,8 +14,6 @@ nonEmptyDialogCancel: null; nonEmptyDialogConfirm: null; }>(); - - let nonEmptyDialogOpen: boolean;