diff --git a/ui/src/lib/utils.ts b/ui/src/lib/utils.ts index c56d3687..db66b3be 100644 --- a/ui/src/lib/utils.ts +++ b/ui/src/lib/utils.ts @@ -29,3 +29,20 @@ const twMerge = extendTailwindMerge({ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } + +// edge still uses the old one +export function getWeekInfo() { + let locale = new Intl.Locale(navigator.language); + + // @ts-ignore + if (locale.getWeekInfo) { + // @ts-ignore + return locale.getWeekInfo(); + // @ts-ignore + } else if (locale.weekInfo) { + // @ts-ignore + return locale.weekInfo; + } + + throw new Error("Could not fetch week info via new or old api"); +} diff --git a/ui/src/state/store.ts b/ui/src/state/store.ts index 3a843d35..1e835cbd 100644 --- a/ui/src/state/store.ts +++ b/ui/src/state/store.ts @@ -17,6 +17,7 @@ import { import { invoke } from "@tauri-apps/api/core"; import { sessionToken, settings } from "./client"; +import { getWeekInfo } from "@/lib/utils"; // I'll probs want to slice this up at some point, but for now a // big blobby lump of state is fine. @@ -47,8 +48,7 @@ let state = (set: any, get: any): AtuinState => ({ shellHistory: [], calendar: [], - // @ts-ignore - weekStart: new Intl.Locale(navigator.language).getWeekInfo().firstDay, + weekStart: getWeekInfo().firstDay, refreshAliases: () => { invoke("aliases").then((aliases: any) => {