diff --git a/src/internal/Settings.tsx b/src/internal/Settings.tsx
index 6898f2f..e64c9f2 100644
--- a/src/internal/Settings.tsx
+++ b/src/internal/Settings.tsx
@@ -1,10 +1,9 @@
import { Plugin } from "@/lib/types"
-import bunker from "@/lib/bunker"
import { Settings2 } from "lucide-react"
import { Switch } from "@/components/ui/switch"
import { Label } from "@/components/ui/label"
-import { useEffect, useState } from "react"
+import { useState } from "react"
const Settings: Plugin = {
name: "Settings",
@@ -13,19 +12,23 @@ const Settings: Plugin = {
icon: Settings2,
page({ sdk }) {
+ const [pluginLocation, setPluginLocation] = useState(sdk.config.get("storageLocation"));
function setStorageLocation(checked: boolean) {
if (checked) {
- sdk.config.set("pluginLocation", "internal")
+ sdk.config.set("storageLocation", "internal")
+ setPluginLocation("internal");
} else {
- sdk.config.set("pluginLocation", "external")
+ sdk.config.set("storageLocation", "external")
+ setPluginLocation("external");
}
}
+
return (
Settings
- setStorageLocation(checked)} />
+ setStorageLocation(checked)} />
@@ -34,7 +37,7 @@ const Settings: Plugin = {
onReady() {
- console.log("Status")
+ console.log("Settings")
},
}
diff --git a/src/lib/bunker.ts b/src/lib/bunker.ts
index 293536e..2cbf0db 100644
--- a/src/lib/bunker.ts
+++ b/src/lib/bunker.ts
@@ -1,5 +1,9 @@
-const version = "v0.2.3"
-const pluginLocation = "internal"
+import { SDK } from "./sdk"
+let version = "v0.2.3"
+let pluginLocation = "internal"
+let Settings = new SDK("bunker.settings")
+
+pluginLocation = Settings.config.get("storageLocation") || pluginLocation
const bunker = {
version,
diff --git a/src/lib/sdk.ts b/src/lib/sdk.ts
index b1b6e24..27a82b7 100644
--- a/src/lib/sdk.ts
+++ b/src/lib/sdk.ts
@@ -20,12 +20,14 @@ export class SDK {
public config = {
get: (key: string) => {
+ console.log(`[${this.id}] Getting config value for key ${key}`)
const value = localStorage.getItem(`${this.id}.${key}`)
if (value) {
return value
}
},
set: (key: string, value: string) => {
+ console.log(`[${this.id}] Setting config value for key ${key} to ${value}`)
localStorage.setItem(`${this.id}.${key}`, value)
return value
},
@@ -33,6 +35,7 @@ export class SDK {
public plugins = {
isInstalled: (pluginId: string) => {
+ console.log(`[${this.id}] Checking if plugin ${pluginId} is installed`)
const plugins = $plugins.get()
return plugins.some((plugin) => plugin.id === pluginId)
},