Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
updater
Brendan Allan8ac87c595d00
diff --git a/Cargo.lock b/Cargo.lockindex 53e8dce0b..18591e0cf 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1400,7 +1400,7 @@ dependencies = [[[package]]name = "desktop"-version = "0.3.0-alpha.3"+version = "0.3.0-alpha.1"dependencies = ["anyhow","axum",diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.tomlindex 57ad5833e..3efd69a1a 100644--- a/apps/desktop/src-tauri/Cargo.toml+++ b/apps/desktop/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "desktop"-version = "0.3.0-alpha.3"+version = "0.3.0-alpha.1"description = "A Tauri App"authors = ["you"]edition = "2021"diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 15bef1640..ef8e3e5f9 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -10,6 +10,7 @@ mod playback;mod project_recordings;mod recording;mod tray;+mod updater;mod upload;use auth::AuthStore;@@ -1292,12 +1293,15 @@ pub fn run() {.plugin(tauri_plugin_os::init()).plugin(tauri_plugin_process::init()).plugin(tauri_plugin_oauth::init())+ .plugin(tauri_plugin_updater::Builder::new().build()).invoke_handler(specta_builder.invoke_handler()).setup(move |app| {specta_builder.mount_events(app);let app_handle = app.handle().clone();+ tokio::spawn(updater::check_for_updates(app.handle().clone()));+if permissions::do_permissions_check().necessary_granted() {open_main_window(app_handle.clone());} else {diff --git a/apps/desktop/src-tauri/src/updater.rs b/apps/desktop/src-tauri/src/updater.rsnew file mode 100644index 000000000..5c509f302--- /dev/null+++ b/apps/desktop/src-tauri/src/updater.rs@@ -0,0 +1,64 @@+use tauri::AppHandle;+use tauri_plugin_dialog::DialogExt;+use tauri_plugin_updater::UpdaterExt;++#[tauri::command]+#[specta::specta]+pub async fn check_for_updates(app: AppHandle) -> Result<(), ()> {+ let Some(update) = app+ .updater()+ .map_err(|_| {})?+ .check()+ .await+ .map_err(|_| {})?+ else {+ return Ok(());+ };++ let should_update = tokio::task::spawn_blocking({+ let version = update.version.clone();+ let app = app.clone();+ move || {+ app.dialog()+ .message(format!(+ "Version {} of Cap is available, would you like to install it?",+ version+ ))+ .title("Update Cap")+ .ok_button_label("Update")+ .cancel_button_label("Ignore")+ .blocking_show()+ }+ })+ .await+ .unwrap();++ if !should_update {+ return Ok(());+ }++ update.download_and_install(|_, _| {}, || {}).await.unwrap();++ let should_restart = tokio::task::spawn_blocking({+ let version = update.version.clone();+ let app = app.clone();+ move || {+ app.dialog()+ .message(format!(+ "Cap v{version} has been installed, restart Cap to finish updating.",+ ))+ .title("Update Cap")+ .ok_button_label("Restart Now")+ .cancel_button_label("Restart Later")+ .blocking_show()+ }+ })+ .await+ .unwrap();++ if should_restart {+ app.restart();+ }++ return Ok(());+}diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsxindex e6c631a69..a0e9775eb 100644--- a/apps/desktop/src/routes/editor/Editor.tsx+++ b/apps/desktop/src/routes/editor/Editor.tsx@@ -27,14 +27,11 @@ import {createRoot,createSignal,on,- onCleanup,onMount,} from "solid-js";import { platform } from "@tauri-apps/plugin-os";import { createStore, reconcile, unwrap } from "solid-js/store";import { Dynamic } from "solid-js/web";-import { Equal } from "effect";-import { Store } from "@tauri-apps/plugin-store";import { createWritableMemo } from "@solid-primitives/memo";import {@@ -44,7 +41,6 @@ import {type CursorType,type RenderProgress,commands,- ProjectConfiguration,} from "../../utils/tauri";import { EditorContextProvider, useEditorContext } from "./context";import {