From b536a497bb05e9a380fe09bd5cd437b83b8027ac Mon Sep 17 00:00:00 2001 From: medProgAyat Date: Mon, 6 Oct 2025 18:35:17 +0330 Subject: [PATCH 01/10] solved issue: error code removed and error page styled and close button added --- ftl/core/importing.ftl | 2 +- ts/lib/components/ErrorPage.svelte | 41 +++++++++++++++++---- ts/lib/generated/post.ts | 3 +- ts/routes/import-csv/[...path]/+page.svelte | 7 +++- ts/routes/import-csv/[...path]/+page.ts | 25 ++++++++----- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/ftl/core/importing.ftl b/ftl/core/importing.ftl index b23d12654..891c5e05d 100644 --- a/ftl/core/importing.ftl +++ b/ftl/core/importing.ftl @@ -160,7 +160,7 @@ importing-cards-added = [one] { $count } card added. *[other] { $count } cards added. } -importing-file-empty = The file you selected is empty. +importing-file-empty = The selected file is empty. Please choose a valid file. importing-notes-added = { $count -> [one] { $count } new note imported. diff --git a/ts/lib/components/ErrorPage.svelte b/ts/lib/components/ErrorPage.svelte index 01bcb1224..d5ad86c4b 100644 --- a/ts/lib/components/ErrorPage.svelte +++ b/ts/lib/components/ErrorPage.svelte @@ -2,17 +2,42 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> - -
- {error.message} + + +
+

{error.message}

+
diff --git a/ts/lib/generated/post.ts b/ts/lib/generated/post.ts index 90e372520..704d3d132 100644 --- a/ts/lib/generated/post.ts +++ b/ts/lib/generated/post.ts @@ -41,7 +41,8 @@ async function postProtoInner(url: string, body: Uint8Array): Promise - +{#if data.initialError} + +{:else} + +{/if} diff --git a/ts/routes/import-csv/[...path]/+page.ts b/ts/routes/import-csv/[...path]/+page.ts index cda2bace9..2f947f791 100644 --- a/ts/routes/import-csv/[...path]/+page.ts +++ b/ts/routes/import-csv/[...path]/+page.ts @@ -6,14 +6,19 @@ import { ImportCsvState } from "../lib"; import type { PageLoad } from "./$types"; export const load = (async ({ params }) => { - const [notetypes, decks, metadata] = await Promise.all([ - getNotetypeNames({}), - getDeckNames({ - skipEmptyDefault: false, - includeFiltered: false, - }), - getCsvMetadata({ path: params.path }, { alertOnError: false }), - ]); - const state = new ImportCsvState(params.path, notetypes, decks, metadata); - return { state }; + try { + const [notetypes, decks, metadata] = await Promise.all([ + getNotetypeNames({}), + getDeckNames({ + skipEmptyDefault: false, + includeFiltered: false, + }), + getCsvMetadata({ path: params.path }, { alertOnError: false }), + ]); + const state = new ImportCsvState(params.path, notetypes, decks, metadata); + return { state }; + } catch (error: any) { + const rawMsg = error?.message ?? String(error ?? ""); + return { initialError: new Error(rawMsg) }; + } }) satisfies PageLoad; From bc08907f14061f043359a4cc29903782e2536642 Mon Sep 17 00:00:00 2001 From: medProgAyat Date: Mon, 6 Oct 2025 18:58:01 +0330 Subject: [PATCH 02/10] i forgot to add my self to contributers --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a18833b04..983ffa017 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -250,6 +250,7 @@ Danilo Spillebeen Matbe766 Amanda Sternberg arold0 +medProgAyat ******************** From 63803e0ff3ec7f8657ec1509011b7041a4e11d8c Mon Sep 17 00:00:00 2001 From: medProgAyat Date: Mon, 6 Oct 2025 19:05:34 +0330 Subject: [PATCH 03/10] format using ninja format --- ts/lib/components/ErrorPage.svelte | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ts/lib/components/ErrorPage.svelte b/ts/lib/components/ErrorPage.svelte index d5ad86c4b..c17f7d273 100644 --- a/ts/lib/components/ErrorPage.svelte +++ b/ts/lib/components/ErrorPage.svelte @@ -25,19 +25,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html From 021d0cd968871dfed15840758cb4700483203a96 Mon Sep 17 00:00:00 2001 From: medProgAyat Date: Tue, 7 Oct 2025 19:47:27 +0330 Subject: [PATCH 04/10] format post.ts to meet ninja check --- ts/lib/generated/post.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ts/lib/generated/post.ts b/ts/lib/generated/post.ts index 704d3d132..e6f77cdf9 100644 --- a/ts/lib/generated/post.ts +++ b/ts/lib/generated/post.ts @@ -19,7 +19,10 @@ export async function postProto( return outputType.fromBinary(outputBytes); } catch (err) { const { alertOnError = true } = options; - if (alertOnError && !(err instanceof Error && err.message === "500: Interrupted")) { + if ( + alertOnError && + !(err instanceof Error && err.message === "500: Interrupted") + ) { alert(err); } throw err; @@ -42,7 +45,11 @@ async function postProtoInner(url: string, body: Uint8Array): Promise Date: Tue, 7 Oct 2025 19:51:37 +0330 Subject: [PATCH 05/10] fix style again because the last one was using pretier not dprint --- ts/lib/generated/post.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ts/lib/generated/post.ts b/ts/lib/generated/post.ts index e6f77cdf9..35310007a 100644 --- a/ts/lib/generated/post.ts +++ b/ts/lib/generated/post.ts @@ -19,10 +19,7 @@ export async function postProto( return outputType.fromBinary(outputBytes); } catch (err) { const { alertOnError = true } = options; - if ( - alertOnError && - !(err instanceof Error && err.message === "500: Interrupted") - ) { + if (alertOnError && !(err instanceof Error && err.message === "500: Interrupted")) { alert(err); } throw err; @@ -46,9 +43,7 @@ async function postProtoInner(url: string, body: Uint8Array): Promise Date: Tue, 7 Oct 2025 19:56:22 +0330 Subject: [PATCH 06/10] format using dprint --- ts/lib/generated/post.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ts/lib/generated/post.ts b/ts/lib/generated/post.ts index 35310007a..dab9c1b9c 100644 --- a/ts/lib/generated/post.ts +++ b/ts/lib/generated/post.ts @@ -19,7 +19,9 @@ export async function postProto( return outputType.fromBinary(outputBytes); } catch (err) { const { alertOnError = true } = options; - if (alertOnError && !(err instanceof Error && err.message === "500: Interrupted")) { + if ( + alertOnError && !(err instanceof Error && err.message === "500: Interrupted") + ) { alert(err); } throw err; @@ -43,7 +45,9 @@ async function postProtoInner(url: string, body: Uint8Array): Promise Date: Thu, 9 Oct 2025 17:42:23 +0330 Subject: [PATCH 07/10] fix: use bridgeCommand instead pycmd for now "till add rpc in future" --- ts/lib/components/ErrorPage.svelte | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ts/lib/components/ErrorPage.svelte b/ts/lib/components/ErrorPage.svelte index c17f7d273..d4ea80054 100644 --- a/ts/lib/components/ErrorPage.svelte +++ b/ts/lib/components/ErrorPage.svelte @@ -2,16 +2,14 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> -