fix: remove update check from the ui

it is no longer necessary
This commit is contained in:
2025-04-12 11:59:02 +00:00
parent f3016eb029
commit 7db36b7bc0
4 changed files with 25 additions and 52 deletions

View File

@ -11,7 +11,6 @@ use tauri::AppHandle;
pub struct GlobalState {
pub remain_open: bool,
pub has_updated: bool,
}
pub struct AppData {
@ -50,7 +49,7 @@ impl AppData {
profile: profile,
pkgs: PackageStore::new(apph.clone()),
cfg,
state: GlobalState { remain_open: true, has_updated: false },
state: GlobalState { remain_open: true },
patch_set
}
}

View File

@ -469,12 +469,4 @@ pub async fn list_patches(state: State<'_, Mutex<AppData>>, target: String) -> R
let list = appd.patch_set.find_patches(target).map_err(|e| e.to_string())?;
Ok(list)
}
#[tauri::command]
pub async fn has_updated(state: State<'_, Mutex<AppData>>) -> Result<bool, ()> {
log::debug!("invoke: has_updated");
let appd = state.lock().await;
Ok(appd.state.has_updated)
}

View File

@ -17,7 +17,7 @@ use fern::colors::{Color, ColoredLevelConfig};
use model::misc::Game;
use pkg::PkgKey;
use pkg_store::Payload;
use tauri::{AppHandle, Emitter, Listener, Manager, RunEvent};
use tauri::{AppHandle, Listener, Manager, RunEvent};
use tauri_plugin_deep_link::DeepLinkExt;
use tauri_plugin_cli::CliExt;
use tokio::{fs, sync::Mutex, try_join};
@ -248,8 +248,6 @@ pub async fn run(_args: Vec<String>) {
cmd::list_com_ports,
cmd::list_patches,
cmd::has_updated,
])
.build(tauri::generate_context!())
.expect("error while building tauri application");
@ -311,14 +309,10 @@ fn deep_link(app: AppHandle, args: Vec<String>) {
async fn update(app: tauri::AppHandle) -> tauri_plugin_updater::Result<()> {
let mutex = app.state::<Mutex<AppData>>();
{
let mut appd = mutex.lock().await;
let appd = mutex.lock().await;
if !appd.cfg.enable_autoupdates {
log::info!("skipping auto-update");
// The frontend may not be available at this point
// So emit isn't suitable
appd.state.has_updated = true;
return Ok(());
}
}
@ -326,6 +320,7 @@ async fn update(app: tauri::AppHandle) -> tauri_plugin_updater::Result<()> {
#[cfg(not(debug_assertions))]
{
use tauri_plugin_updater::UpdaterExt;
use tauri::Emitter;
if let Some(update) = app.updater()?.check().await? {
let mut downloaded = 0;
update.download_and_install(
@ -345,21 +340,20 @@ async fn update(app: tauri::AppHandle) -> tauri_plugin_updater::Result<()> {
}
// One day I will write proper tests
#[cfg(debug_assertions)]
{
std::thread::sleep(std::time::Duration::from_millis(2000));
let mut downloaded = 0;
while downloaded < 200 {
std::thread::sleep(std::time::Duration::from_millis(10));
downloaded += 1;
app.emit("update-progress", (downloaded as f32) / 200f32)?;
}
}
// #[cfg(debug_assertions)]
// {
// use tauri::Emitter;
// std::thread::sleep(std::time::Duration::from_millis(5000));
// let mut downloaded = 0;
// while downloaded < 500 {
// std::thread::sleep(std::time::Duration::from_millis(10));
// downloaded += 1;
// _ = app.emit("update-progress", (downloaded as f32) / 500f32);
// }
// app.restart();
// }
log::info!("ending auto-update check");
let mut appd = mutex.lock().await;
appd.state.has_updated = true;
Ok(())
}

View File

@ -40,30 +40,20 @@ const pkgSearchTerm = ref('');
const isProfileDisabled = computed(() => prf.current === null);
const updateVisible = ref(false);
const updateProgress = ref(-1);
const hasUpdatedCheck = async () => {
const res = await invoke('has_updated');
if (res == false) {
updateVisible.value = true;
setTimeout(hasUpdatedCheck, 200);
} else {
updateVisible.value = false;
}
};
const updateProgress: Ref<number | null> = ref(null);
listen<number>('update-progress', (ev) => {
updateProgress.value = ev.payload;
});
listen<undefined>('update-end', (_) => {
updateProgress.value = null;
});
onMounted(async () => {
invoke('list_directories').then((d) => {
general.dirs = d as Dirs;
client.load();
if (client.enableAutoupdates) {
hasUpdatedCheck();
}
});
const fetch_promise = pkg.fetch(true);
@ -157,14 +147,12 @@ listen<{ message: string; header: string }>('invoke-error', (event) => {
</Dialog>
<Dialog
modal
:visible="updateVisible"
:visible="updateProgress !== null"
:closable="false"
:header="updateProgress < 0 ? 'Checking for updates' : 'Updating'"
:style="{ width: '50vw' }"
header="Updating"
:style="{ width: '200px' }"
>
<div v-if="updateProgress >= 0">
{{ (updateProgress * 100).toFixed(0) }}%
</div>
{{ ((updateProgress ?? 0) * 100).toFixed(0) }}%
</Dialog>
<Tabs