Skip to content

armgit / VERT

Public Imported from GitHub
0

The next-generation file converter. Open source, fully local* and free forever.

feat: more dynamic settings system

not-nullptr35e98a597195
diff --git a/bun.lockb b/bun.lockb
deleted file mode 100644
index e067663..0000000
Binary files a/bun.lockb and /dev/null differ
diff --git a/src/lib/sections/settings/Conversion.svelte b/src/lib/sections/settings/Conversion.svelte
index 8fa6e19..83e242d 100644
--- a/src/lib/sections/settings/Conversion.svelte
+++ b/src/lib/sections/settings/Conversion.svelte
@@ -7,24 +7,32 @@
import { RefreshCwIcon, SaveAllIcon } from "lucide-svelte";
import { onMount } from "svelte";
- let filenameFormat = "VERT_%name%";
+ // let filenameFormat = "VERT_%name%";
+ let settings = $state({
+ filenameFormat: "VERT_%name%",
+ });
function save() {
- log(["settings"], "Saving settings");
+ log(["settings"], "saving settings");
if (!browser) return;
try {
- localStorage.setItem("filenameFormat", filenameFormat);
- log(["settings"], `Saving filename format: ${filenameFormat}`);
- addToast("success", "Settings saved!");
+ localStorage.setItem("settings", JSON.stringify(settings));
+ addToast("success", "settings saved!");
} catch (error) {
- log(["settings", "error"], `Failed to save settings: ${error}`);
+ log(["settings", "error"], `failed to save settings: ${error}`);
addToast("error", "Failed to save settings!");
}
}
onMount(() => {
- const format = localStorage.getItem("filenameFormat");
- if (format) filenameFormat = format;
+ const savedSettings = localStorage.getItem("settings");
+ if (savedSettings) {
+ const parsedSettings = JSON.parse(savedSettings);
+ settings = {
+ ...settings,
+ ...parsedSettings,
+ };
+ }
});
</script>
@@ -59,7 +67,7 @@
</div>
<FancyTextInput
placeholder="VERT_%name%"
- bind:value={filenameFormat}
+ bind:value={settings.filenameFormat}
extension=".ext"
type="text"
/>
diff --git a/src/lib/store/index.svelte.ts b/src/lib/store/index.svelte.ts
index 39425ad..08a1013 100644
--- a/src/lib/store/index.svelte.ts
+++ b/src/lib/store/index.svelte.ts
@@ -186,8 +186,8 @@ class Files {
const blob = await downloadZip(dlFiles, "converted.zip").blob();
const url = URL.createObjectURL(blob);
- const filenameFormat =
- localStorage.getItem("filenameFormat") ?? "VERT_%name%";
+ const settings = JSON.parse(localStorage.getItem("settings") ?? "{}");
+ const filenameFormat = settings.filenameFormat ?? "VERT_%name%";
const format = (name: string) => {
const date = new Date().toISOString();
diff --git a/src/lib/types/file.svelte.ts b/src/lib/types/file.svelte.ts
index 7142777..28e1068 100644
--- a/src/lib/types/file.svelte.ts
+++ b/src/lib/types/file.svelte.ts
@@ -57,8 +57,8 @@ export class VertFile {
public async download() {
if (!this.result) throw new Error("No result found");
- const filenameFormat =
- localStorage.getItem("filenameFormat") ?? "VERT_%name%";
+ const settings = JSON.parse(localStorage.getItem("settings") ?? "{}");
+ const filenameFormat = settings.filenameFormat ?? "VERT_%name%";
const format = (name: string) => {
const date = new Date().toISOString();
diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte
index 10ea613..6de20ee 100644
--- a/src/routes/about/+page.svelte
+++ b/src/routes/about/+page.svelte
@@ -52,7 +52,7 @@
const cachedContribs = sessionStorage.getItem("ghContribs");
if (cachedContribs) {
ghContribs = JSON.parse(cachedContribs);
- log(["about"], "Loaded GitHub contributors from cache");
+ log(["about"], "loaded GitHub contributors from cache");
return;
}