diff --git a/apps/client/src/desktop.ts b/apps/client/src/desktop.ts index 6462c1338..e77ba845b 100644 --- a/apps/client/src/desktop.ts +++ b/apps/client/src/desktop.ts @@ -22,6 +22,7 @@ bundleService.getWidgetBundlesByParent().then(async (widgetBundles) => { appContext.setLayout(new DesktopLayout(widgetBundles)); appContext.start().catch((e) => { toastService.showPersistent({ + id: "critical-error", title: t("toast.critical-error.title"), icon: "alert", message: t("toast.critical-error.message", { message: e.message }) diff --git a/apps/client/src/services/branches.ts b/apps/client/src/services/branches.ts index 5672fa370..e5a5158e1 100644 --- a/apps/client/src/services/branches.ts +++ b/apps/client/src/services/branches.ts @@ -1,6 +1,6 @@ import utils from "./utils.js"; import server from "./server.js"; -import toastService, { type ToastOptions } from "./toast.js"; +import toastService, { type ToastOptionsWithRequiredId } from "./toast.js"; import froca from "./froca.js"; import hoistedNoteService from "./hoisted_note.js"; import ws from "./ws.js"; @@ -195,11 +195,11 @@ function filterRootNote(branchIds: string[]) { }); } -function makeToast(id: string, message: string): ToastOptions { +function makeToast(id: string, message: string): ToastOptionsWithRequiredId { return { - id: id, + id, title: t("branches.delete-status"), - message: message, + message, icon: "trash" }; } @@ -242,7 +242,7 @@ ws.subscribeToMessages(async (message) => { async function cloneNoteToBranch(childNoteId: string, parentBranchId: string, prefix?: string) { const resp = await server.put(`notes/${childNoteId}/clone-to-branch/${parentBranchId}`, { - prefix: prefix + prefix }); if (!resp.success) { @@ -252,7 +252,7 @@ async function cloneNoteToBranch(childNoteId: string, parentBranchId: string, pr async function cloneNoteToParentNote(childNoteId: string, parentNoteId: string, prefix?: string) { const resp = await server.put(`notes/${childNoteId}/clone-to-note/${parentNoteId}`, { - prefix: prefix + prefix }); if (!resp.success) { diff --git a/apps/client/src/services/bundle.ts b/apps/client/src/services/bundle.ts index c346fce8d..e925253ce 100644 --- a/apps/client/src/services/bundle.ts +++ b/apps/client/src/services/bundle.ts @@ -37,6 +37,7 @@ export async function executeBundle(bundle: Bundle, originEntity?: Entity | null } catch (e: any) { const note = await froca.getNote(bundle.noteId); toastService.showPersistent({ + id: `custom-script-failure-${note?.noteId}`, title: t("toast.bundle-error.title"), icon: "bx bx-error-circle", message: t("toast.bundle-error.message", { @@ -108,6 +109,7 @@ async function getWidgetBundlesByParent() { const noteId = bundle.noteId; const note = await froca.getNote(noteId); toastService.showPersistent({ + id: `custom-script-failure-${noteId}`, title: t("toast.bundle-error.title"), icon: "bx bx-error-circle", message: t("toast.bundle-error.message", { diff --git a/apps/client/src/services/import.ts b/apps/client/src/services/import.ts index 3e54fd4a3..80f057282 100644 --- a/apps/client/src/services/import.ts +++ b/apps/client/src/services/import.ts @@ -1,4 +1,4 @@ -import toastService, { type ToastOptions } from "./toast.js"; +import toastService, { type ToastOptionsWithRequiredId } from "./toast.js"; import server from "./server.js"; import ws from "./ws.js"; import utils from "./utils.js"; @@ -57,11 +57,11 @@ export async function uploadFiles(entityType: string, parentNoteId: string, file } } -function makeToast(id: string, message: string): ToastOptions { +function makeToast(id: string, message: string): ToastOptionsWithRequiredId { return { - id: id, + id, title: t("import.import-status"), - message: message, + message, icon: "plus" }; } diff --git a/apps/client/src/services/protected_session.ts b/apps/client/src/services/protected_session.ts index e9382a16c..395a844bb 100644 --- a/apps/client/src/services/protected_session.ts +++ b/apps/client/src/services/protected_session.ts @@ -1,7 +1,7 @@ import server from "./server.js"; import protectedSessionHolder from "./protected_session_holder.js"; import toastService from "./toast.js"; -import type { ToastOptions } from "./toast.js"; +import type { ToastOptionsWithRequiredId } from "./toast.js"; import ws from "./ws.js"; import appContext from "../components/app_context.js"; import froca from "./froca.js"; @@ -97,7 +97,7 @@ async function protectNote(noteId: string, protect: boolean, includingSubtree: b await server.put(`notes/${noteId}/protect/${protect ? 1 : 0}?subtree=${includingSubtree ? 1 : 0}`); } -function makeToast(message: Message, title: string, text: string): ToastOptions { +function makeToast(message: Message, title: string, text: string): ToastOptionsWithRequiredId { return { id: message.taskId, title, diff --git a/apps/client/src/widgets/basic_widget.ts b/apps/client/src/widgets/basic_widget.ts index 1c7554348..37049d725 100644 --- a/apps/client/src/widgets/basic_widget.ts +++ b/apps/client/src/widgets/basic_widget.ts @@ -169,10 +169,11 @@ export class TypedBasicWidget> extends TypedCompon console.log("Got issue in widget ", this); console.error(e); - let noteId = this._noteId; + const noteId = this._noteId; if (this._noteId) { froca.getNote(noteId, true).then((note) => { toastService.showPersistent({ + id: `custom-widget-failure-${noteId}`, title: t("toast.widget-error.title"), icon: "bx bx-error-circle", message: t("toast.widget-error.message-custom", { @@ -182,16 +183,16 @@ export class TypedBasicWidget> extends TypedCompon }) }); }); - return; + } else { + toastService.showPersistent({ + id: `custom-widget-failure-${noteId}`, + title: t("toast.widget-error.title"), + icon: "bx bx-error-circle", + message: t("toast.widget-error.message-unknown", { + message: e.message || e.toString() + }) + }); } - - toastService.showPersistent({ - title: t("toast.widget-error.title"), - icon: "bx bx-error-circle", - message: t("toast.widget-error.message-unknown", { - message: e.message || e.toString() - }) - }); } /** diff --git a/apps/client/src/widgets/dialogs/export.tsx b/apps/client/src/widgets/dialogs/export.tsx index a8682df80..2f10f8063 100644 --- a/apps/client/src/widgets/dialogs/export.tsx +++ b/apps/client/src/widgets/dialogs/export.tsx @@ -6,7 +6,7 @@ import FormRadioGroup from "../react/FormRadioGroup"; import Modal from "../react/Modal"; import "./export.css"; import ws from "../../services/ws"; -import toastService, { ToastOptions } from "../../services/toast"; +import toastService, { type ToastOptionsWithRequiredId } from "../../services/toast"; import utils from "../../services/utils"; import open from "../../services/open"; import froca from "../../services/froca"; @@ -132,11 +132,11 @@ function exportBranch(branchId: string, type: string, format: string, version: s } ws.subscribeToMessages(async (message) => { - function makeToast(id: string, message: string): ToastOptions { + function makeToast(id: string, message: string): ToastOptionsWithRequiredId { return { - id: id, + id, title: t("export.export_status"), - message: message, + message, icon: "export" }; }