Skip to content

Commit 2c95438

Browse files
committed
Replace tauri-settings with localStorage
1 parent 8c672fa commit 2c95438

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/lib/RegisterProjectDirectory.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838
3939
async function saveStableDiffusionDirectory() {
40-
stableDiffusionDirectory.register(stableDiffusionDirectoryInput.value);
40+
stableDiffusionDirectory.set(stableDiffusionDirectoryInput.value);
4141
stableDiffusionDirectoryInput.value = "";
4242
isReregistering = false;
4343
}

src/store.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { readable, writable } from "svelte/store";
22
import type { Run } from "./types";
3-
import { get, set } from "tauri-settings";
3+
// import { get, set } from "tauri-settings";
44

5-
type directory = {
5+
/* type directory = {
66
stableDiffusionDirectory: string;
77
};
8-
98
const getStableDiffusionDirectory = async () => {
109
let sdDir = "";
1110
@@ -36,11 +35,27 @@ async function stableDiffusionDirectoryStore() {
3635
register: (sdDirectory: string) => setStableDiffusionDirectory(sdDirectory),
3736
};
3837
}
39-
export const stableDiffusionDirectory = await stableDiffusionDirectoryStore();
38+
export const stableDiffusionDirectory = await stableDiffusionDirectoryStore(); */
4039

4140
// Use this in lieu of an event bus to assign a prompt from a saved run to the prompt input
4241
export const reusePrompt = writable('');
4342

43+
// Store runs to localStorage for now
44+
function createStableDiffusionDirectory() {
45+
let storedStableDiffusionDirectory = JSON.parse(localStorage.getItem("stableDiffusionDirectory")) || "";
46+
const { subscribe, set } = writable(storedStableDiffusionDirectory);
47+
48+
return {
49+
subscribe,
50+
set: (sdDir: string) => {
51+
localStorage.setItem("stableDiffusionDirectory", JSON.stringify(sdDir));
52+
set(sdDir);
53+
}
54+
};
55+
}
56+
57+
export const stableDiffusionDirectory = createStableDiffusionDirectory();
58+
4459
// Store runs to localStorage for now
4560
function createRunsStore() {
4661
let storedRuns = JSON.parse(localStorage.getItem("runs")) || [];

0 commit comments

Comments
 (0)