mirror of
https://github.com/open-webui/computer.git
synced 2026-11-26 15:21:01 -05:00
refac
This commit is contained in:
1 parent
27d404ba59
commit
c5d4bf76a5
12 files changed
+461
-324
No files matched your search
@@ -0,0 +1,29 @@
|
||||
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);
|
||||
});
|
||||
Reference in new issue
Block a user