mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
30 lines
991 B
TypeScript
30 lines
991 B
TypeScript
import { writable } from 'svelte/store';
|
|
|
|
const HIDE_WHITESPACE_KEY = 'gitDiff:hideWhitespace';
|
|
const DISPLAY_MODE_KEY = 'gitDiff:displayMode';
|
|
export type DiffDisplayMode = 'unified' | 'split';
|
|
|
|
function persistedBoolean(key: string, fallback: boolean) {
|
|
const initial =
|
|
typeof localStorage !== 'undefined' ? localStorage.getItem(key) === 'true' : fallback;
|
|
const store = writable(initial);
|
|
store.subscribe((value) => {
|
|
if (typeof localStorage !== 'undefined') localStorage.setItem(key, String(value));
|
|
});
|
|
return store;
|
|
}
|
|
|
|
export const hideWhitespaceChanges = persistedBoolean(HIDE_WHITESPACE_KEY, false);
|
|
|
|
const initialDisplayMode =
|
|
typeof localStorage !== 'undefined'
|
|
? localStorage.getItem(DISPLAY_MODE_KEY) === 'split'
|
|
? 'split'
|
|
: 'unified'
|
|
: 'unified';
|
|
|
|
export const diffDisplayMode = writable<DiffDisplayMode>(initialDisplayMode);
|
|
diffDisplayMode.subscribe((value) => {
|
|
if (typeof localStorage !== 'undefined') localStorage.setItem(DISPLAY_MODE_KEY, value);
|
|
});
|