Skip to content

Commit

Permalink
Auto Update Toggle / Fix Store
Browse files Browse the repository at this point in the history
  • Loading branch information
Cattn committed Sep 20, 2024
1 parent 48da39d commit 6800a2d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
20 changes: 18 additions & 2 deletions src/internal/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Settings: Plugin = {

page({ sdk }) {
const [pluginLocation, setPluginLocation] = useState(sdk.config.get("storageLocation"));
const [autoUpdate, setAutoUpdate] = useState(sdk.config.get("autoUpdate") === "true");
function setStorageLocation(checked: boolean) {
if (checked) {
sdk.config.set("storageLocation", "internal")
Expand All @@ -23,14 +24,29 @@ const Settings: Plugin = {
}
}

function autoUpdateSet(checked: boolean) {
if (checked) {
sdk.config.set("autoUpdate", "true")
setAutoUpdate(true);
} else {
sdk.config.set("autoUpdate", "false")
setAutoUpdate(false);
}
}

return (
<div className="flex flex-col items-center w-full pt-16">
<h1 className="font-bold text-5xl">Settings </h1>

<div className="flex flex-wrap justify-center gap-4 mt-8">
<div className="flex flex-col justify-center gap-4 mt-8">
<div className="flex flex-row items-center gap-4 mt-8">
<Switch id="storage-location" checked={pluginLocation === "internal"} onCheckedChange={(checked) => setStorageLocation(checked)} />
<Label className="text-md" htmlFor="storage-location">Store Plugins Internally</Label>
</div>
<div className="flex flex-row items-center gap-4 mt-2">
<Switch id="auto-update" checked={autoUpdate} onCheckedChange={(checked) => autoUpdateSet(checked)} />
<Label className="text-md" htmlFor="auto-update">Auto Update</Label>
</div>
</div>
</div>
)
},
Expand Down
6 changes: 4 additions & 2 deletions src/internal/Updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ const Updater: Plugin = {
checkIfUpToDate()
}
}

getLatestVersion()
if (bunker.autoUpdate === "true") {
console.log(bunker.autoUpdate)
getLatestVersion()
}

async function checkIfUpToDate() {
if (latestVersion == undefined) return
Expand Down
14 changes: 11 additions & 3 deletions src/lib/bunker.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { SDK } from "./sdk"
let version = "v0.2.4"
let pluginLocation = "internal"
let version: string = "v0.2.4"
let pluginLocation: string = "internal"
let autoUpdate: string = "true"



let Settings = new SDK("bunker.settings")

pluginLocation = Settings.config.get("storageLocation") || pluginLocation

pluginLocation = Settings.config.get("storageLocation") || pluginLocation
// @ts-ignore
autoUpdate = Settings.config.get("autoUpdate") || autoUpdate;

const bunker = {
version,
pluginLocation,
autoUpdate,
}
export default bunker
2 changes: 2 additions & 0 deletions src/routes/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function Store() {
<div className="flex flex-col items-center w-full pt-16 space-y-8">
<h1 className="font-bold text-5xl">Store</h1>

<div className="flex flex-wrap justify-center gap-4">
{!isLoading &&
data!.plugins.map((plugin: StoreItem) => {
return (
Expand Down Expand Up @@ -86,6 +87,7 @@ export default function Store() {
</Card>
)
})}
</div>
</div>
)
}

0 comments on commit 6800a2d

Please sign in to comment.