diff --git a/SOEdownload_manager/src/updater/github/releases_fetcher.rs b/SOEdownload_manager/src/updater/github/releases_fetcher.rs index 3cb3150..039b2e0 100644 --- a/SOEdownload_manager/src/updater/github/releases_fetcher.rs +++ b/SOEdownload_manager/src/updater/github/releases_fetcher.rs @@ -1,10 +1,14 @@ use super::release::Releases; +use log::info; use reqwest::header::USER_AGENT; use reqwest::Client; pub async fn fetch_releases(url: &str) -> Result> { let user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36"; + info!("Downloading latest release from {url}"); + info!("User agent set to {user_agent}"); + let client = Client::new(); let response = client .get(url) @@ -16,9 +20,3 @@ pub async fn fetch_releases(url: &str) -> Result { settings = data; - darkmode = settings.darkmode; settings_toggle_darkmode(null); - -}) - - +}); invoke("correct_pos").then((cor) => { if (cor) { - setInterval(load_mods, 5000) - load_mods() + setInterval(load_mods, 5000); + load_mods(); } else { - popup("comp/fetcherr") + popup("comp/fetcherr"); } -}) +}); function load_mods() { invoke("fetch_modlist").then((modlist) => { - let htmllist = document.getElementById("modlist") - htmllist.innerHTML = " " - console.log(modlist) - console.log(modlist.length) + let htmllist = document.getElementById("modlist"); + htmllist.innerHTML = " "; + console.log(modlist); + console.log(modlist.length); for (let i = 0; i < modlist.length; i++) { - console.log("adding list") - const is_mod_on = settings.active_mods.includes(modlist[i]) - const li = document.createElement("li") + console.log("adding list"); + const is_mod_on = settings.active_mods.includes(modlist[i]); + const li = document.createElement("li"); li.innerHTML = `
  • @@ -50,113 +44,92 @@ function load_mods() {
  • - ` + `; - htmllist.appendChild(li) + htmllist.appendChild(li); } - console.log("done") - }) + console.log("done"); + }); } -var r = document.querySelector(':root'); - - - +function settings_toggle_darkmode(id) { + const r = document.querySelector(":root"); - - -function settings_toggle_darkmode(id){ - - - if (darkmode){ - if (id != null){ - document.getElementById(id).className = "popup_button red" + if (settings.darkmode) { + if (id != null) { + document.getElementById(id).className = "popup_button red"; } - r.style.setProperty('--background', 'white'); - r.style.setProperty('--background_inverse', 'black'); - r.style.setProperty('--mod_row', 'lightgray'); - - - - }else{ - if (id != null){ - document.getElementById(id).className = "popup_button green" + r.style.setProperty("--background", "white"); + r.style.setProperty("--background_inverse", "black"); + r.style.setProperty("--mod_row", "lightgray"); + } else { + if (id != null) { + document.getElementById(id).className = "popup_button green"; } - r.style.setProperty('--background', '#272727'); - r.style.setProperty('--background_inverse', 'darkgray'); - r.style.setProperty('--mod_row', '#2e2e2e'); - - - + r.style.setProperty("--background", "#272727"); + r.style.setProperty("--background_inverse", "darkgray"); + r.style.setProperty("--mod_row", "#2e2e2e"); } - - - darkmode = !darkmode; - - - settings.darkmode = !darkmode; - - + settings.darkmode = !settings.darkmode; } -function save_settings(){ +function save_settings() { console.log(settings); - invoke("save_launcher_settings", {settings: settings}); + invoke("save_launcher_settings", { settings: settings }); } - - - function toggle_mod(buttonId) { - const button = document.getElementById(buttonId) - const mod_name = document.getElementById(buttonId + "sub").innerText + const button = document.getElementById(buttonId); + const mod_name = document.getElementById(buttonId + "sub").innerText; - const index = settings.active_mods.indexOf(mod_name) + const index = settings.active_mods.indexOf(mod_name); if (index == -1) { - button.classList.replace("red", "green") - button.innerText = "On" - settings.active_mods.push(mod_name) + button.classList.replace("red", "green"); + button.innerText = "On"; + settings.active_mods.push(mod_name); } else { - button.innerText = "Off" - button.classList.replace("green", "red") - settings.active_mods.splice(index, 1) + button.innerText = "Off"; + button.classList.replace("green", "red"); + settings.active_mods.splice(index, 1); } - console.log("pt" + path) - console.log(settings.active_mods) + console.log("pt" + path); + console.log(settings.active_mods); } - - function close_popup() { - document.getElementById("portal").innerHTML = "" + document.getElementById("portal").innerHTML = ""; } + function load(component) { - return fetch(component + ".html").then((response) => response.text()) + return fetch(component + ".html").then((response) => response.text()); } + function popup(strs) { invoke("report_backend", { data: strs }) .then((response) => { - str = response - console.log("ok" + response) - load(str).then((text) => (document.getElementById("portal").innerHTML = text)) + str = response; + console.log("ok" + response); + load(str).then((text) => (document.getElementById("portal").innerHTML = text)); }) .catch((error) => { - console.log("err" + error) - }) + console.log("err" + error); + }); } + function open_web() { - invoke("open_web") + invoke("open_web"); } + function open_git() { - invoke("open_web_git") + invoke("open_web_git"); } function start_game() { - invoke("start", { data: settings.active_mods }) + invoke("start", { data: settings.active_mods }); } window.__TAURI__.event.listen("tauri://window-created", function (event) { - response_container.innerText += "Got window-created event\n\n" -}) + response_container.innerText += "Got window-created event\n\n"; +});