Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(import): show OneNote import progress toasts correctly
Elian Dorana066ca32a227
diff --git a/apps/client/src/services/onenote_import.ts b/apps/client/src/services/onenote_import.tsindex f77444295d..3fa90714e1 100644--- a/apps/client/src/services/onenote_import.ts+++ b/apps/client/src/services/onenote_import.ts@@ -1,3 +1,8 @@+// Loading import.ts registers the shared "importNotes" WebSocket toast handlers (progress + success).+// The OneNote import reuses that taskType, but the OneNote dialog never loads import.ts on its own, so+// without this side-effect import the progress/finished toasts would never appear.+import "./import.js";+import server from "./server.js";export interface OneNoteAccount {diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 381a64d78b..0454ecac63 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -245,7 +245,6 @@"no_notebooks": "No notebooks were found in this account.","select_sections": "Select the sections to import:","import": "Import selected",- "import_started": "OneNote import started…","attach_source": "Attach original HTML (debug)","attach_source_hint": "Saves each page's unmodified OneNote HTML as an attachment on the imported note, for comparing against the converted result."},diff --git a/apps/client/src/widgets/dialogs/import_providers/onenote.tsx b/apps/client/src/widgets/dialogs/import_providers/onenote.tsxindex 1ad59f6038..f08569d24a 100644--- a/apps/client/src/widgets/dialogs/import_providers/onenote.tsx+++ b/apps/client/src/widgets/dialogs/import_providers/onenote.tsx@@ -17,7 +17,6 @@ function OneNotePanel({ parentNoteId, closeDialog }: ImportProviderPanelProps) {const [notebooks, setNotebooks] = useState<OneNoteNotebook[]>([]);const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());const [debug, setDebug] = useState(false);- const [importing, setImporting] = useState(false);const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);const stopPolling = useCallback(() => {@@ -110,14 +109,13 @@ function OneNotePanel({ parentNoteId, closeDialog }: ImportProviderPanelProps) {return;}- setImporting(true);+ // Close immediately and let the shared import toasts report progress and completion. The+ // server request stays open for the whole import, so we don't await before closing.+ closeDialog();try {await onenoteImport.runImport({ parentNoteId, sections, taskId: randomString(10), debug });- toast.showMessage(t("onenote_import.import_started"));- closeDialog();} catch (e) {toast.showError(e instanceof Error ? e.message : String(e));- setImporting(false);}}, [notebooks, selectedIds, parentNoteId, debug, closeDialog]);@@ -178,7 +176,7 @@ function OneNotePanel({ parentNoteId, closeDialog }: ImportProviderPanelProps) {<Buttontext={t("onenote_import.import")}kind="primary"- disabled={importing || selectedIds.size === 0}+ disabled={selectedIds.size === 0}onClick={doImport}/></div>