Reads the grammar frame (AquaSynth docs/soundscape-grammar.md @ aeae510) into a
per-mind table, plans voices (neutral overrides all, Muted, cap, master mute,
weak-device off) and the drawn set. No activity source exists yet
(ratatoskr❓activity-feed-source) and no audio assets, so nothing sounds.
Cites heimdall-body:follow_up:ratatoskr-creature-projection-v2.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
117 lines
2.6 KiB
TypeScript
117 lines
2.6 KiB
TypeScript
import { atom } from 'jotai';
|
|
|
|
const STORAGE_KEY = 'settings';
|
|
export type DateFormat =
|
|
| 'D MMM YYYY'
|
|
| 'DD/MM/YYYY'
|
|
| 'MM/DD/YYYY'
|
|
| 'YYYY/MM/DD'
|
|
| 'YYYY-MM-DD'
|
|
| '';
|
|
export type MessageSpacing = '0' | '100' | '200' | '300' | '400' | '500';
|
|
export enum MessageLayout {
|
|
Modern = 0,
|
|
Compact = 1,
|
|
Bubble = 2,
|
|
}
|
|
|
|
export interface Settings {
|
|
themeId?: string;
|
|
useSystemTheme: boolean;
|
|
lightThemeId?: string;
|
|
darkThemeId?: string;
|
|
monochromeMode?: boolean;
|
|
isMarkdown: boolean;
|
|
editorToolbar: boolean;
|
|
twitterEmoji: boolean;
|
|
pageZoom: number;
|
|
hideActivity: boolean;
|
|
|
|
isPeopleDrawer: boolean;
|
|
memberSortFilterIndex: number;
|
|
enterForNewline: boolean;
|
|
messageLayout: MessageLayout;
|
|
messageSpacing: MessageSpacing;
|
|
hideMembershipEvents: boolean;
|
|
hideNickAvatarEvents: boolean;
|
|
mediaAutoLoad: boolean;
|
|
urlPreview: boolean;
|
|
encUrlPreview: boolean;
|
|
showHiddenEvents: boolean;
|
|
legacyUsernameColor: boolean;
|
|
|
|
showNotifications: boolean;
|
|
isNotificationSounds: boolean;
|
|
|
|
hour24Clock: boolean;
|
|
dateFormatString: string;
|
|
|
|
developerTools: boolean;
|
|
|
|
/** Soundscape flag: default off, and muted by default even when on. */
|
|
soundscapeEnabled: boolean;
|
|
soundscapeMuted: boolean;
|
|
soundscapeVolume: number;
|
|
soundscapeVoiceCap: number;
|
|
}
|
|
|
|
const defaultSettings: Settings = {
|
|
themeId: 'gamecult-theme',
|
|
useSystemTheme: false,
|
|
lightThemeId: undefined,
|
|
darkThemeId: undefined,
|
|
monochromeMode: false,
|
|
isMarkdown: true,
|
|
editorToolbar: false,
|
|
twitterEmoji: false,
|
|
pageZoom: 100,
|
|
hideActivity: false,
|
|
|
|
isPeopleDrawer: false,
|
|
memberSortFilterIndex: 0,
|
|
enterForNewline: false,
|
|
messageLayout: 2,
|
|
messageSpacing: '400',
|
|
hideMembershipEvents: false,
|
|
hideNickAvatarEvents: true,
|
|
mediaAutoLoad: true,
|
|
urlPreview: true,
|
|
encUrlPreview: false,
|
|
showHiddenEvents: false,
|
|
legacyUsernameColor: false,
|
|
|
|
showNotifications: true,
|
|
isNotificationSounds: true,
|
|
|
|
hour24Clock: false,
|
|
dateFormatString: 'D MMM YYYY',
|
|
|
|
developerTools: false,
|
|
|
|
soundscapeEnabled: false,
|
|
soundscapeMuted: true,
|
|
soundscapeVolume: 0.5,
|
|
soundscapeVoiceCap: 4,
|
|
};
|
|
|
|
export const getSettings = () => {
|
|
const settings = localStorage.getItem(STORAGE_KEY);
|
|
if (settings === null) return defaultSettings;
|
|
return {
|
|
...defaultSettings,
|
|
...(JSON.parse(settings) as Settings),
|
|
};
|
|
};
|
|
|
|
export const setSettings = (settings: Settings) => {
|
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
|
|
};
|
|
|
|
const baseSettings = atom<Settings>(getSettings());
|
|
export const settingsAtom = atom<Settings, [Settings], undefined>(
|
|
(get) => get(baseSettings),
|
|
(get, set, update) => {
|
|
set(baseSettings, update);
|
|
setSettings(update);
|
|
}
|
|
);
|