mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-06-06 10:41:21 +02:00
feat: timestamps and user locale
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useAtom } from "jotai";
|
||||
import { atomWithStorage } from "jotai/utils";
|
||||
import { GrimoireState, AppId } from "@/types/app";
|
||||
import { useLocale } from "@/hooks/useLocale";
|
||||
import * as Logic from "./logic";
|
||||
|
||||
// Initial State Definition - Empty canvas on first load
|
||||
@@ -26,9 +27,16 @@ export const grimoireStateAtom = atomWithStorage<GrimoireState>(
|
||||
// The Hook
|
||||
export const useGrimoire = () => {
|
||||
const [state, setState] = useAtom(grimoireStateAtom);
|
||||
const browserLocale = useLocale();
|
||||
|
||||
// Initialize locale from browser if not set
|
||||
if (!state.locale) {
|
||||
setState((prev) => ({ ...prev, locale: browserLocale }));
|
||||
}
|
||||
|
||||
return {
|
||||
state,
|
||||
locale: state.locale || browserLocale,
|
||||
activeWorkspace: state.workspaces[state.activeWorkspaceId],
|
||||
createWorkspace: () => {
|
||||
const count = Object.keys(state.workspaces).length + 1;
|
||||
|
||||
Reference in New Issue
Block a user