Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: Update Options #2161

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion launcher/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,31 @@ app.on("ready", async () => {
Menu.setApplicationMenu(menu);

// Check for updates in production
stereumUpdater.checkForUpdates();
const storedConfig = await storageService.readConfig();
if (!storedConfig.lastUpdateCheck) {
try {
const conf = {
...storedConfig,
lastUpdateCheck: { value: Date.now() },
};
await storageService.writeConfig(conf);
} catch (error) {
console.error("Failed to update settings:", error);
}
}

if (storedConfig.lastUpdateCheck + storedConfig.updateTimer * 86400000 + storedConfig.updateTimerTime * 3600000 <= Date.now()) {
try {
const conf = {
...storedConfig,
lastUpdateCheck: { value: Date.now() },
};
await storageService.writeConfig(conf);
} catch (error) {
console.error("Failed to update settings:", error);
}
stereumUpdater.checkForUpdates();
}
}

await createWindow();
Expand Down
4 changes: 4 additions & 0 deletions launcher/src/components/UI/setting-page/SettingScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import CreditButtons from "./section/CreditButtons.vue";
import IdleTimer from "./components/IdleTimer.vue";
import LogBackups from "./components/LogBackups.vue";
import IdleTimerTime from "./components/IdleTimerTime.vue";
import UpdateTimer from "./components/UpdateTimer.vue";
import UpdateTimerTime from "./components/UpdateTimerTime.vue";
import { ref, computed, onMounted } from "vue";
import CreditBtn from "./components/CreditBtn.vue";
import { useRouter } from "vue-router";
Expand Down Expand Up @@ -107,6 +109,8 @@ const itemConfigurations = computed(() => {
{ title: "Idle Timeout", component: IdleTimer },
{ title: "Idle Timeout Time (in minutes)", component: IdleTimerTime },
{ title: "Stereum Log Backups", component: LogBackups },
{ title: "Auto Update Interval (in days)", component: UpdateTimer },
{ title: "Auto Update Time", component: UpdateTimerTime },
];
} else if (mainBox.value === "audio") {
items = [
Expand Down
75 changes: 75 additions & 0 deletions launcher/src/components/UI/setting-page/components/UpdateTimer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<template>
<div class="UpdateTimer-parent w-full h-full justify-center items-center flex">
<input
type="number"
:value="footerStore.updateTimer"
class="lang-btn-parent w-full h-full bg-[#33393E] rounded-md flex justify-center items-center cursor-pointer border border-[#33393E] uppercase pl-3 pr-3 text-gray-200 text-base"
@change="onChange($event)"
/>
</div>
</template>

<script setup>
import { onMounted } from "vue";
import ControlService from "@/store/ControlService";
import { useFooter } from "@/store/theFooter";

const footerStore = useFooter();

const checkSettings = async () => {
try {
const savedConfig = await ControlService.readConfig();
if (typeof savedConfig.updateTimer?.value !== "undefined") {
footerStore.updateTimer = savedConfig.updateTimer.value;
} else {
updateSettings(7);
}
} catch (error) {
console.error("Failed to load saved settings:", error);
}
};

const updateSettings = async (updateTime) => {
try {
const prevConf = await ControlService.readConfig();
const conf = {
...prevConf,
updateTimer: { value: updateTime },
};
await ControlService.writeConfig(conf);
useFooter.updateTimer = updateTime;
checkSettings();
} catch (error) {
console.error("Failed to update settings:", error);
}
};

const onChange = async (event) => {
if (event.target.value == "" || event.target.value < 7) {
event.target.value = 7;
}
updateSettings(event.target.value);
};

onMounted(() => {
checkSettings();
});
</script>

<style scoped>
input[type="number"] {
text-align: center;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}

.UpdateTimer-parent {
display: flex;
align-items: center;
justify-content: center;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<template>
<div class="UpdateTimerTime-parent w-full h-full justify-center items-center flex">
<input
type="number"
:value="footerStore.updateTimerTime"
class="lang-btn-parent w-full h-full bg-[#33393E] rounded-md flex justify-center items-center cursor-pointer border border-[#33393E] uppercase pl-3 pr-3 text-gray-200 text-base"
@change="onChange($event)"
/>
</div>
</template>

<script setup>
import { onMounted } from "vue";
import ControlService from "@/store/ControlService";
import { useFooter } from "@/store/theFooter";

const footerStore = useFooter();

const checkSettings = async () => {
try {
const savedConfig = await ControlService.readConfig();
if (typeof savedConfig.updateTimerTime?.value !== "undefined") {
footerStore.updateTimerTime = savedConfig.updateTimerTime.value;
} else {
updateSettings(12);
}
} catch (error) {
console.error("Failed to load saved settings:", error);
}
};

const updateSettings = async (updateTimeT) => {
try {
const prevConf = await ControlService.readConfig();
const conf = {
...prevConf,
updateTimerTime: { value: updateTimeT },
};
await ControlService.writeConfig(conf);
useFooter.updateTimer = updateTimeT;
checkSettings();
} catch (error) {
console.error("Failed to update settings:", error);
}
};

const onChange = async (event) => {
if (event.target.value == "" || event.target.value < 12) {
event.target.value = 12;
}
updateSettings(event.target.value);
};

onMounted(() => {
checkSettings();
});
</script>

<style scoped>
input[type="number"] {
text-align: center;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}

.UpdateTimerTime-parent {
display: flex;
align-items: center;
justify-content: center;
}
</style>
2 changes: 2 additions & 0 deletions launcher/src/store/theFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const useFooter = defineStore("theFooter", {
idleTimer: false,
idleTimerTime: 5,
logBackups: 3,
updateTimer: 7,
updateTimerTime: 12,
};
},
getters: {},
Expand Down
Loading