feat(updater): refactor update check to ensure it only runs in Tauri context

This commit is contained in:
2026-02-20 01:39:37 +11:00
parent 7e7f017768
commit bb6604e819

View File

@@ -12,10 +12,7 @@ import './index.css';
import { trimTrailingSlash } from './app/utils/common'; import { trimTrailingSlash } from './app/utils/common';
import App from './app/pages/App'; import App from './app/pages/App';
import { applySafeAreaInsets } from './app/utils/tauri'; import { applySafeAreaInsets, isTauri } 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 i18n (needs to be bundled ;))
import './app/i18n'; import './app/i18n';
@@ -50,8 +47,18 @@ if ('serviceWorker' in navigator) {
* Prompts user if update is available and handles download/install * Prompts user if update is available and handles download/install
*/ */
async function checkForUpdates() { async function checkForUpdates() {
// Only run in Tauri context
if (!isTauri()) {
console.log('Update check skipped - not running in Tauri');
return;
}
console.log('Checking for updates...'); console.log('Checking for updates...');
try { try {
const { check } = await import('@tauri-apps/plugin-updater');
const { ask } = await import('@tauri-apps/plugin-dialog');
const { relaunch } = await import('@tauri-apps/plugin-process');
const update = await check(); const update = await check();
console.log('Update check result:', update); console.log('Update check result:', update);
if (update) { if (update) {