Skip to content

Commit 6b44085

Browse files
chore: persistent settings
1 parent d370d96 commit 6b44085

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

packages/frontend/src/views/App.vue

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,37 @@ interface DirectoryInfo {
3030
// Retrieve the SDK instance to interact with the backend
3131
const sdk = useSDK();
3232
33-
// Reactive state
34-
const thresholdMB = ref(10);
35-
const enableWarnings = ref(true);
36-
const warningAt75Percent = ref(true);
37-
const warningAt90Percent = ref(true);
33+
// Load settings from localStorage with defaults
34+
const loadSettings = () => {
35+
const saved = localStorage.getItem('bytecap-settings');
36+
if (saved) {
37+
try {
38+
return JSON.parse(saved);
39+
} catch {
40+
return {};
41+
}
42+
}
43+
return {};
44+
};
45+
46+
// Save settings to localStorage
47+
const saveSettings = () => {
48+
const settings = {
49+
thresholdMB: thresholdMB.value,
50+
enableWarnings: enableWarnings.value,
51+
warningAt75Percent: warningAt75Percent.value,
52+
warningAt90Percent: warningAt90Percent.value,
53+
};
54+
localStorage.setItem('bytecap-settings', JSON.stringify(settings));
55+
};
56+
57+
const savedSettings = loadSettings();
58+
59+
// Reactive state with persisted values
60+
const thresholdMB = ref(savedSettings.thresholdMB ?? 10);
61+
const enableWarnings = ref(savedSettings.enableWarnings ?? true);
62+
const warningAt75Percent = ref(savedSettings.warningAt75Percent ?? true);
63+
const warningAt90Percent = ref(savedSettings.warningAt90Percent ?? true);
3864
const workspaceFiles = ref<DirectoryInfo>({
3965
files: [],
4066
totalSize: 0,
@@ -127,6 +153,9 @@ const onRefreshClick = async () => {
127153
128154
// Apply settings and check thresholds manually
129155
const applySettings = async () => {
156+
// Save settings to localStorage
157+
saveSettings();
158+
130159
// Clear any existing notifications first
131160
clearAllNotifications();
132161

0 commit comments

Comments
 (0)