diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 779cce3a..d198d9c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: if: matrix.settings.platform == 'ubuntu-22.04' run: | sudo apt-get update - sudo apt-get install -y build-essential libssl-dev libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf + sudo apt-get install -y build-essential libssl-dev libayatana-appindicator3-dev libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf - name: Install pnpm uses: pnpm/action-setup@v2 with: diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index e7f12b7c..24b5a5ee 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -107,6 +107,13 @@ fn secure_remove(key: String) -> Result<(), ()> { fn main() { tauri::Builder::default() + .setup(|app| { + #[cfg(desktop)] + app + .handle() + .plugin(tauri_plugin_updater::Builder::new().build())?; + Ok(()) + }) .plugin(tauri_plugin_app::init()) .plugin(tauri_plugin_clipboard_manager::init()) .plugin(tauri_plugin_dialog::init()) diff --git a/src/libs/ndk/provider.tsx b/src/libs/ndk/provider.tsx index a6b33d1f..525e5e26 100644 --- a/src/libs/ndk/provider.tsx +++ b/src/libs/ndk/provider.tsx @@ -28,7 +28,10 @@ const NDKProvider = ({ children }: PropsWithChildren) => { data-tauri-drag-region className="flex h-screen w-screen items-center justify-center bg-neutral-50 dark:bg-neutral-950" > - +
+ +

Connecting to relays

+
); } diff --git a/src/libs/storage/provider.tsx b/src/libs/storage/provider.tsx index de1cdf6d..59f29ebf 100644 --- a/src/libs/storage/provider.tsx +++ b/src/libs/storage/provider.tsx @@ -1,11 +1,15 @@ import { appConfigDir } from '@tauri-apps/api/path'; import { message } from '@tauri-apps/plugin-dialog'; import { platform } from '@tauri-apps/plugin-os'; +import { relaunch } from '@tauri-apps/plugin-process'; import Database from '@tauri-apps/plugin-sql'; +import { check } from '@tauri-apps/plugin-updater'; import { PropsWithChildren, createContext, useContext, useEffect, useState } from 'react'; import { LumeStorage } from '@libs/storage/instance'; +import { LoaderIcon } from '@shared/icons'; + interface StorageContext { db: LumeStorage; } @@ -16,6 +20,7 @@ const StorageContext = createContext({ const StorageProvider = ({ children }: PropsWithChildren) => { const [db, setDB] = useState(undefined); + const [isNewVersion, setIsNewVersion] = useState(false); const initLumeStorage = async () => { try { @@ -26,6 +31,15 @@ const StorageProvider = ({ children }: PropsWithChildren) => { const lumeStorage = new LumeStorage(sqlite, platformName); if (!lumeStorage.account) await lumeStorage.getActiveAccount(); + // check update + const update = await check(); + if (update) { + setIsNewVersion(true); + + await update.downloadAndInstall(); + await relaunch(); + } + setDB(lumeStorage); console.info(dir); } catch (e) { @@ -40,9 +54,23 @@ const StorageProvider = ({ children }: PropsWithChildren) => { if (!db) initLumeStorage(); }, []); - if (db) { - return {children}; + if (!db) { + return ( +
+
+ +

+ {isNewVersion ? 'Found a new version, updating' : 'Checking for updates'} +

+
+
+ ); } + + return {children}; }; const useStorage = () => {