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
chore(toast): fix typecheck issues
Elian Doranf1d87c29d333
diff --git a/apps/client/src/desktop.ts b/apps/client/src/desktop.tsindex 6462c13388..e77ba845b7 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.tsindex 5672fa3701..e5a5158e13 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<Response>(`notes/${childNoteId}/clone-to-branch/${parentBranchId}`, {- prefix: prefix+ prefix});if (!resp.success) {@@ -252,7 +252,7 @@ async function cloneNoteToBranch(childNoteId: string, parentBranchId: string, prasync function cloneNoteToParentNote(childNoteId: string, parentNoteId: string, prefix?: string) {const resp = await server.put<Response>(`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.tsindex c346fce8df..e925253ce2 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.tsindex 3e54fd4a38..80f0572823 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.tsindex e9382a16cd..395a844bb1 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: bawait 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.tsindex 1c7554348a..37049d7257 100644--- a/apps/client/src/widgets/basic_widget.ts+++ b/apps/client/src/widgets/basic_widget.ts@@ -169,10 +169,11 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedComponconsole.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<T extends TypedComponent<any>> 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.tsxindex a8682df80b..2f10f8063b 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"};}