Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

672 B
Raw Blame
import { create } from "zustand/react";

const storageKey = "character-shortcuts";
const readEnabled = () => {
	try {
		return localStorage.getItem(storageKey) !== "off";
	} catch {
		return true;
	}
};

type ShortcutSettings = { characterShortcuts: boolean; setCharacterShortcuts: (enabled: boolean) => void };

export const useShortcutSettings = create<ShortcutSettings>((set) => ({
	characterShortcuts: readEnabled(),
	setCharacterShortcuts: (enabled) => {
		set({ characterShortcuts: enabled });
		try {
			localStorage.setItem(storageKey, enabled ? "on" : "off");
		} catch {
			// Storage may be unavailable; the setting still applies for this session.
		}
	},
}));