Skip to content

Commit

Permalink
Not using things before they are declared
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Feb 19, 2024
1 parent 6e31e9a commit 46b68ac
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 42 deletions.
33 changes: 17 additions & 16 deletions src/frontend/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,9 @@
let destination: NamedRecord | null = null;
let errors: Array<MoveError> | 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 {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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(
Expand Down
48 changes: 24 additions & 24 deletions src/frontend/FolderSelection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,6 @@
let items: Array<NamedRecord> | 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":
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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") {
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/Moving.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import { createEventDispatcher } from "svelte";
import { _ } from "svelte-i18n";
let nonEmptyDialogOpen: boolean;
export function showNonEmptyDialog(): void {
nonEmptyDialogOpen = true;
}
Expand All @@ -12,8 +14,6 @@
nonEmptyDialogCancel: null;
nonEmptyDialogConfirm: null;
}>();
let nonEmptyDialogOpen: boolean;
</script>

<p>
Expand Down

0 comments on commit 46b68ac

Please sign in to comment.