feat(updater): integrate Tauri updater and dialog for version checks

This commit is contained in:
2026-02-19 20:43:37 +11:00
parent 168d44d262
commit eb3768ae30
3 changed files with 73 additions and 0 deletions

View File

@@ -13,6 +13,9 @@ import './index.css';
import { trimTrailingSlash } from './app/utils/common';
import App from './app/pages/App';
import { applySafeAreaInsets } from './app/utils/tauri';
import { check } from '@tauri-apps/plugin-updater';
import { ask } from '@tauri-apps/plugin-dialog';
import { relaunch } from '@tauri-apps/plugin-process';
// import i18n (needs to be bundled ;))
import './app/i18n';
@@ -42,6 +45,28 @@ if ('serviceWorker' in navigator) {
});
}
/**
* Check for app updates using Tauri updater
* Prompts user if update is available and handles download/install
*/
async function checkForUpdates() {
try {
const update = await check();
if (update) {
const shouldUpdate = await ask(
`A new version (${update.version}) is available. Would you like to update now?`,
{ title: 'Update Available', kind: 'info' }
);
if (shouldUpdate) {
await update.downloadAndInstall();
await relaunch();
}
}
} catch (error) {
console.error('Failed to check for updates:', error);
}
}
const mountApp = () => {
const rootContainer = document.getElementById('root');
@@ -55,3 +80,8 @@ const mountApp = () => {
};
mountApp();
// Check for updates after app loads (with delay to not block startup)
setTimeout(() => {
checkForUpdates();
}, 3000);