Skip to content

Build your personal knowledge base with Trilium Notes

chore(client): address requested changes

Elian Dorana569b8452863
diff --git a/apps/client/src/services/font.ts b/apps/client/src/services/font.ts
index 8071a3fa73..b42427117d 100644
--- a/apps/client/src/services/font.ts
+++ b/apps/client/src/services/font.ts
@@ -31,11 +31,11 @@ export function applyFontsFromOptions() {
document.head.appendChild(newLink);
}
- const removeOldLinks = () => {
+ newLink.addEventListener("load", () => {
for (const oldLink of oldLinks) {
oldLink.remove();
}
- };
- newLink.addEventListener("load", removeOldLinks, { once: true });
- newLink.addEventListener("error", removeOldLinks, { once: true });
+ }, { once: true });
+ // If the new stylesheet fails to load, keep the previous one rather than dropping fonts entirely.
+ newLink.addEventListener("error", () => newLink.remove(), { once: true });
}
diff --git a/apps/client/src/services/theme.ts b/apps/client/src/services/theme.ts
index 793c693efb..95b98c74a9 100644
--- a/apps/client/src/services/theme.ts
+++ b/apps/client/src/services/theme.ts
@@ -130,6 +130,13 @@ export async function applyThemeFromOptions() {
// Custom theme — resolve its note to build the CSS URL and the optional `next` base.
const { default: server } = await import("./server.js");
const userThemes = await server.get<CustomThemeInfo[]>("options/user-themes");
+
+ // The theme may have changed again while the request was in flight; applying the stale
+ // one now would override the latest choice (whose own invocation may already have run).
+ if (options.get("theme") !== theme) {
+ return;
+ }
+
const match = userThemes.find((userTheme) => userTheme.val === theme);
applyTheme(
theme,
diff --git a/apps/client/src/widgets/type_widgets/options/advanced.tsx b/apps/client/src/widgets/type_widgets/options/advanced.tsx
index 5d00cf3ab1..f46ec3f733 100644
--- a/apps/client/src/widgets/type_widgets/options/advanced.tsx
+++ b/apps/client/src/widgets/type_widgets/options/advanced.tsx
@@ -1,7 +1,7 @@
import { AnonymizedDbResponse, DatabaseAnonymizeResponse, DatabaseCheckIntegrityResponse, ExistingAnonymizedDatabasesResponse } from "@triliumnext/commons";
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
-import { type ExperimentalFeatureId,getAvailableExperimentalFeatures } from "../../../services/experimental_features";
+import { type ExperimentalFeatureId, getAvailableExperimentalFeatures } from "../../../services/experimental_features";
import { t } from "../../../services/i18n";
import server from "../../../services/server";
import toast from "../../../services/toast";