diff --git a/src/lib/stores/settings.ts b/src/lib/stores/settings.ts index 51dab38dda2..18c55ce6e54 100644 --- a/src/lib/stores/settings.ts +++ b/src/lib/stores/settings.ts @@ -1,5 +1,7 @@ import { browser } from "$app/environment"; +import { invalidate } from "$app/navigation"; import { base } from "$app/paths"; +import { UrlDependency } from "$lib/types/UrlDependency"; import { getContext, setContext } from "svelte"; import { type Writable, writable, get } from "svelte/store"; @@ -53,6 +55,7 @@ export function createSettingsStore(initialValue: Omit { updatedAt: 1, createdAt: 1, }) - .map((conv) => ({ - id: conv._id.toString(), - title: settings?.hideEmojiOnSidebar ? conv.title.replace(/\p{Emoji}/gu, "") : conv.title, - model: conv.model ?? defaultModel, - updatedAt: conv.updatedAt, - })) + .map((conv) => { + // remove emojis if settings say so + if (settings?.hideEmojiOnSidebar) { + conv.title = conv.title.replace(/\p{Emoji}/gu, ""); + } + + // remove invalid unicode and trim whitespaces + conv.title = conv.title.replace(/\uFFFD/gu, "").trimStart(); + return { + id: conv._id.toString(), + title: settings?.hideEmojiOnSidebar ? conv.title.replace(/\p{Emoji}/gu, "") : conv.title, + model: conv.model ?? defaultModel, + updatedAt: conv.updatedAt, + }; + }) .toArray(), settings: { searchEnabled: !!(