aboutsummaryrefslogtreecommitdiff
path: root/src-ui/src/main.ts
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-09 23:44:32 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-09 23:44:32 +0200
commit397c850fb9fc12bc9ba7afe4fc0968e0964548f5 (patch)
treee186ac8608495b102eb72843c2bd77a539f4c165 /src-ui/src/main.ts
parent5158d22ab215e7672d1b73cc2d637c438b862ec2 (diff)
downloadFlightCore-397c850fb9fc12bc9ba7afe4fc0968e0964548f5.tar.gz
FlightCore-397c850fb9fc12bc9ba7afe4fc0968e0964548f5.zip
Move duplicate into dedicated function
Diffstat (limited to 'src-ui/src/main.ts')
-rw-r--r--src-ui/src/main.ts45
1 files changed, 15 insertions, 30 deletions
diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts
index a8cf4ad2..040539e2 100644
--- a/src-ui/src/main.ts
+++ b/src-ui/src/main.ts
@@ -15,6 +15,18 @@ var globalState = {
current_view: "" // Note sure if this is the right way to do it
}
+async function get_northstar_version_number_and_set_button_accordingly(omniButtonEl: HTMLElement) {
+ let northstar_version_number = await invoke("get_northstar_version_number_caller") as string;
+ if (northstar_version_number && northstar_version_number.length > 0) {
+ globalState.installed_northstar_version = northstar_version_number;
+ omniButtonEl.textContent = `Play (${northstar_version_number})`;
+ let northstar_is_outdated = await invoke("check_is_northstar_outdated") as boolean;
+ if (northstar_is_outdated) {
+ omniButtonEl.textContent = button_update_string;
+ }
+ }
+}
+
document.addEventListener("DOMContentLoaded", async function () {
// get the elements
// const helloEl = $("div.hello")! as HTMLElement;
@@ -66,16 +78,7 @@ document.addEventListener("DOMContentLoaded", async function () {
// omniButtonEl.textContent = button_install_string;
// // Check for Northstar install
- // let northstar_version_number = await invoke("get_northstar_version_number_caller") as string;
- // if (northstar_version_number && northstar_version_number.length > 0) {
- // globalState.installed_northstar_version = northstar_version_number;
- // omniButtonEl.textContent = `Play (${northstar_version_number})`;
- // // Check for updated Northstar
- // let northstar_is_outdated = await invoke("check_is_northstar_outdated") as boolean;
- // if (northstar_is_outdated) {
- // omniButtonEl.textContent = button_update_string;
- // }
- // }
+ // get_northstar_version_number_and_set_button_accordingly();
// }
// else {
// // Not valid Titanfall2 install
@@ -91,17 +94,7 @@ document.addEventListener("DOMContentLoaded", async function () {
await invoke("install_northstar_caller", { gamePath: globalState.gamepath }) as boolean;
alert("Done?");
- // TODO: move this to function
- let northstar_version_number = await invoke("get_northstar_version_number_caller") as string;
- if (northstar_version_number && northstar_version_number.length > 0) {
- globalState.installed_northstar_version = northstar_version_number;
- omniButtonEl.textContent = `Play (${northstar_version_number})`;
- let northstar_is_outdated = await invoke("check_is_northstar_outdated") as boolean;
- if (northstar_is_outdated) {
- omniButtonEl.textContent = button_update_string;
- }
- }
-
+ get_northstar_version_number_and_set_button_accordingly(omniButtonEl);
break;
default:
alert("Not implemented yet");
@@ -146,15 +139,7 @@ document.addEventListener("DOMContentLoaded", async function () {
globalState.gamepath = install_location;
// Check installed Northstar version if found
- let northstar_version_number = await invoke("get_northstar_version_number_caller") as string;
- if (northstar_version_number && northstar_version_number.length > 0) {
- globalState.installed_northstar_version = northstar_version_number;
- omniButtonEl.textContent = `${button_play_string} (${northstar_version_number})`;
- let northstar_is_outdated = await invoke("check_is_northstar_outdated") as boolean;
- if (northstar_is_outdated) {
- omniButtonEl.textContent = button_update_string;
- }
- }
+ get_northstar_version_number_and_set_button_accordingly(omniButtonEl);
console.log(globalState);
}
else {