GitHub auto-updater: check releases, download installer, update settings UI
This commit is contained in:
1 parent
64e058ad2e
commit
ea21eef396
5 files changed
+480
-5
No files matched your search
@@ -44,6 +44,8 @@
|
||||
- Capture quality and storage settings are exposed: the Settings screen can change resolution, FPS, bitrate, buffer storage cap, excluded window titles, and the separate-audio-tracks toggle via the `set_capture_settings` command, and current values are shown in DesktopStatus.
|
||||
- The configured storage cap is enforced by a backend worker that prunes the oldest rolling buffer segments once the buffer exceeds `storage_limit_gb`.
|
||||
- SQLite schema uses versioned migrations tracked via `PRAGMA user_version`; legacy databases (missing tables or the `title` column) are repaired and upgraded in place, with migration tests.
|
||||
- Auto-update checks the GitHub repo releases (`Alvin-Zilverstand/clipforge-game-clipper`) for the latest MSI/NSIS installer, compares it against the running version, downloads it to temp, launches the installer, and exits the app to finish; version comparison, asset selection, and parsing are unit tested plus one ignored live test against the GitHub API.
|
||||
- The Settings screen shows the current version, checks for updates, and offers a Download & install button when a newer release exists.
|
||||
- Vite TypeScript UI builds and has interactive Library, Recording, Auto Clip, Uploads, and Settings views.
|
||||
- Library search, event/upload filters, and grid/list switching are functional in the UI.
|
||||
- User-visible notices are shown for major actions and failures instead of relying only on console output.
|
||||
@@ -56,7 +58,8 @@
|
||||
- Auto start/stop is conservative but live: when auto-record is enabled, supported detected games can start recording and stop when the game disappears.
|
||||
- Per-game capture quality overrides are still incomplete.
|
||||
- Recorder service still runs inside the Tauri process instead of a separate background service process.
|
||||
- Installer onboarding and auto-update are still not implemented.
|
||||
- Installer onboarding is still not implemented.
|
||||
- Auto-update requires a GitHub release whose tag is newer than the running app version and that ships MSI/NSIS assets (the existing `v0.0.1` release carries 0.1.0 assets, so it correctly reports up to date).
|
||||
|
||||
## Next Engineering Steps
|
||||
|
||||
@@ -64,4 +67,5 @@
|
||||
2. Expand CS2/Dota GSI event mapping beyond the current MVP event parser.
|
||||
3. Add per-game capture quality overrides.
|
||||
4. Add installer/onboarding screens for privacy, capture source, storage, and hotkeys.
|
||||
5. Run manual QA on Windows gaming hardware and tune CPU/GPU overhead.
|
||||
5. Automate building and publishing GitHub releases (e.g. a GitHub Action that runs Tauri + uploads MSI/NSIS assets) so the updater has fresh assets to install.
|
||||
6. Run manual QA on Windows gaming hardware and tune CPU/GPU overhead.
|
||||
@@ -28,6 +28,7 @@ use clipforge::native_wgc::NativeWgcReplayCaptureBackend;
|
||||
use clipforge::recorder::{RecorderAction, RecorderService};
|
||||
use clipforge::settings::{load_or_create_settings, save_settings, AppSettings};
|
||||
use clipforge::storage::{clip_path, is_inside_root, LibraryPaths};
|
||||
use clipforge::updater::{self, UpdateCheck};
|
||||
use clipforge::upload::{
|
||||
CatboxUploader, CustomHttpUploader, LitterboxUploader, UploadMetadata, UploadResult, Uploader,
|
||||
};
|
||||
@@ -128,6 +129,7 @@ struct DesktopStatus {
|
||||
storage_limit_gb: u64,
|
||||
excluded_window_titles: Vec<String>,
|
||||
separate_audio_tracks: bool,
|
||||
app_version: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
@@ -1106,6 +1108,67 @@ fn list_crash_logs(runtime: State<'_, AppRuntime>) -> Result<Vec<String>, String
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn check_for_updates() -> Result<UpdateCheck, String> {
|
||||
let current_version = env!("CARGO_PKG_VERSION").to_string();
|
||||
let repo = updater::DEFAULT_UPDATE_REPO.to_string();
|
||||
let check = tauri::async_runtime::spawn_blocking(move || {
|
||||
updater::check_for_updates(&repo, ¤t_version)
|
||||
})
|
||||
.await
|
||||
.map_err(|error| format!("Update check task failed: {error}"))?;
|
||||
check.map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn download_and_apply_update(
|
||||
app: tauri::AppHandle,
|
||||
download_url: String,
|
||||
installer_file: String,
|
||||
) -> Result<String, String> {
|
||||
let current_version = env!("CARGO_PKG_VERSION").to_string();
|
||||
let installer_path = tauri::async_runtime::spawn_blocking(move || {
|
||||
let updates_dir = std::env::temp_dir().join("clipforge-updates");
|
||||
updater::download_installer(
|
||||
&download_url,
|
||||
&updates_dir,
|
||||
&installer_file,
|
||||
¤t_version,
|
||||
)
|
||||
.map_err(|error| error.to_string())
|
||||
})
|
||||
.await
|
||||
.map_err(|error| format!("Update download task failed: {error}"))??;
|
||||
launch_installer(&installer_path)?;
|
||||
let handle = app.clone();
|
||||
thread::spawn(move || {
|
||||
thread::sleep(Duration::from_millis(800));
|
||||
handle.exit(0);
|
||||
});
|
||||
Ok("Installer downloaded and started. ClipForge will close to finish the update.".to_string())
|
||||
}
|
||||
|
||||
fn launch_installer(path: &PathBuf) -> Result<(), String> {
|
||||
let extension = path
|
||||
.extension()
|
||||
.and_then(|value| value.to_str())
|
||||
.unwrap_or("")
|
||||
.to_ascii_lowercase();
|
||||
let spawned = if extension == "msi" {
|
||||
Command::new("msiexec")
|
||||
.arg("/i")
|
||||
.arg(path)
|
||||
.arg("/passive")
|
||||
.arg("/norestart")
|
||||
.spawn()
|
||||
} else {
|
||||
Command::new(path).arg("/S").spawn()
|
||||
};
|
||||
spawned
|
||||
.map(|_| ())
|
||||
.map_err(|error| format!("Could not launch installer: {error}"))
|
||||
}
|
||||
|
||||
fn upload_clip_with_settings(
|
||||
clip: &Clip,
|
||||
settings: &AppSettings,
|
||||
@@ -1510,6 +1573,8 @@ fn main() {
|
||||
reveal_screenshot,
|
||||
reveal_crash_logs,
|
||||
list_crash_logs,
|
||||
check_for_updates,
|
||||
download_and_apply_update,
|
||||
set_hotkeys
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
@@ -1764,6 +1829,7 @@ fn status_from_recorder(recorder: &RecorderService, capture: Option<&ActiveCaptu
|
||||
storage_limit_gb: recorder.settings.storage_limit_gb,
|
||||
excluded_window_titles: recorder.settings.privacy.excluded_window_titles.clone(),
|
||||
separate_audio_tracks: recorder.settings.privacy.separate_audio_tracks,
|
||||
app_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ pub mod native_wgc;
|
||||
pub mod recorder;
|
||||
pub mod settings;
|
||||
pub mod storage;
|
||||
pub mod updater;
|
||||
pub mod upload;
|
||||
|
||||
pub use models::{Clip, ClipSource, GameEvent, GameEventType, RecordingStatus, UploadProvider};
|
||||
|
||||
+312
@@ -0,0 +1,312 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Duration;
|
||||
|
||||
pub const DEFAULT_UPDATE_REPO: &str = "Alvin-Zilverstand/clipforge-game-clipper";
|
||||
const UPDATE_TIMEOUT_SECS: u64 = 30;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct GitHubRelease {
|
||||
pub tag_name: String,
|
||||
#[serde(default)]
|
||||
pub published_at: Option<String>,
|
||||
#[serde(default)]
|
||||
pub body: Option<String>,
|
||||
#[serde(default)]
|
||||
pub assets: Vec<GitHubAsset>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct GitHubAsset {
|
||||
pub name: String,
|
||||
#[serde(default)]
|
||||
pub size: Option<u64>,
|
||||
pub browser_download_url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, PartialEq)]
|
||||
pub struct UpdateCheck {
|
||||
pub update_available: bool,
|
||||
pub latest_version: String,
|
||||
pub installer_file: Option<String>,
|
||||
pub download_url: Option<String>,
|
||||
pub published_at: Option<String>,
|
||||
pub release_notes: Option<String>,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum UpdateCheckError {
|
||||
Http(String),
|
||||
Json(String),
|
||||
NoReleaseFound,
|
||||
NoInstallerAsset(String),
|
||||
Io(io::Error),
|
||||
}
|
||||
|
||||
impl fmt::Display for UpdateCheckError {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Http(message) => write!(formatter, "Update check HTTP error: {message}"),
|
||||
Self::Json(message) => write!(formatter, "Could not parse update response: {message}"),
|
||||
Self::NoReleaseFound => write!(formatter, "No published releases found yet."),
|
||||
Self::NoInstallerAsset(version) => write!(
|
||||
formatter,
|
||||
"Release {version} has no MSI or NSIS installer asset."
|
||||
),
|
||||
Self::Io(error) => write!(formatter, "Update file error: {error}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for UpdateCheckError {}
|
||||
|
||||
impl From<io::Error> for UpdateCheckError {
|
||||
fn from(error: io::Error) -> Self {
|
||||
Self::Io(error)
|
||||
}
|
||||
}
|
||||
|
||||
fn http_client(current_version: &str) -> Result<reqwest::blocking::Client, UpdateCheckError> {
|
||||
reqwest::blocking::Client::builder()
|
||||
.user_agent(format!("ClipForge/{current_version}"))
|
||||
.timeout(Duration::from_secs(UPDATE_TIMEOUT_SECS))
|
||||
.build()
|
||||
.map_err(|error| UpdateCheckError::Http(error.to_string()))
|
||||
}
|
||||
|
||||
pub fn check_for_updates(
|
||||
repo: &str,
|
||||
current_version: &str,
|
||||
) -> Result<UpdateCheck, UpdateCheckError> {
|
||||
let client = http_client(current_version)?;
|
||||
let url = format!("https://api.github.com/repos/{repo}/releases/latest");
|
||||
let response = client
|
||||
.get(&url)
|
||||
.send()
|
||||
.map_err(|error| UpdateCheckError::Http(error.to_string()))?;
|
||||
|
||||
if response.status() == reqwest::StatusCode::NOT_FOUND {
|
||||
return Err(UpdateCheckError::NoReleaseFound);
|
||||
}
|
||||
if !response.status().is_success() {
|
||||
return Err(UpdateCheckError::Http(format!(
|
||||
"GitHub returned {} for {}",
|
||||
response.status(),
|
||||
url
|
||||
)));
|
||||
}
|
||||
|
||||
let release: GitHubRelease = response
|
||||
.json()
|
||||
.map_err(|error| UpdateCheckError::Json(error.to_string()))?;
|
||||
|
||||
build_update_check(current_version, &release)
|
||||
}
|
||||
|
||||
pub fn build_update_check(
|
||||
current_version: &str,
|
||||
release: &GitHubRelease,
|
||||
) -> Result<UpdateCheck, UpdateCheckError> {
|
||||
let latest_version = normalize_version(&release.tag_name);
|
||||
let update_available = compare_versions(current_version, &latest_version) == Ordering::Less;
|
||||
let installer = select_installer_asset(&release.assets);
|
||||
|
||||
let message = if update_available {
|
||||
let file = installer
|
||||
.as_ref()
|
||||
.map(|asset| asset.name.as_str())
|
||||
.unwrap_or("installer");
|
||||
format!(
|
||||
"A newer version ({latest_version}) is available — {file}, ready to download."
|
||||
)
|
||||
} else {
|
||||
"You are on the latest version.".to_string()
|
||||
};
|
||||
|
||||
Ok(UpdateCheck {
|
||||
update_available,
|
||||
latest_version,
|
||||
installer_file: installer.as_ref().map(|asset| asset.name.clone()),
|
||||
download_url: installer.map(|asset| asset.browser_download_url),
|
||||
published_at: release.published_at.clone(),
|
||||
release_notes: release.body.clone(),
|
||||
message,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn select_installer_asset(assets: &[GitHubAsset]) -> Option<GitHubAsset> {
|
||||
assets
|
||||
.iter()
|
||||
.find(|asset| asset.name.ends_with(".msi"))
|
||||
.or_else(|| {
|
||||
assets.iter().find(|asset| {
|
||||
asset.name.ends_with(".exe") && !asset.name.to_lowercase().contains("uninstall")
|
||||
})
|
||||
})
|
||||
.cloned()
|
||||
}
|
||||
|
||||
pub fn download_installer(
|
||||
url: &str,
|
||||
destination_dir: &Path,
|
||||
file_name: &str,
|
||||
current_version: &str,
|
||||
) -> Result<PathBuf, UpdateCheckError> {
|
||||
std::fs::create_dir_all(destination_dir)?;
|
||||
let destination = destination_dir.join(file_name);
|
||||
let client = http_client(current_version)?;
|
||||
let mut response = client
|
||||
.get(url)
|
||||
.send()
|
||||
.map_err(|error| UpdateCheckError::Http(error.to_string()))?;
|
||||
if !response.status().is_success() {
|
||||
return Err(UpdateCheckError::Http(format!(
|
||||
"Download failed with {}",
|
||||
response.status()
|
||||
)));
|
||||
}
|
||||
|
||||
let mut file = std::fs::File::create(&destination)?;
|
||||
io::copy(&mut response, &mut file)
|
||||
.map_err(|error| UpdateCheckError::Io(error))?;
|
||||
Ok(destination)
|
||||
}
|
||||
|
||||
pub fn normalize_version(tag: &str) -> String {
|
||||
tag.trim().trim_start_matches('v').to_string()
|
||||
}
|
||||
|
||||
pub fn compare_versions(current: &str, latest: &str) -> Ordering {
|
||||
numeric_parts(current).cmp(&numeric_parts(latest))
|
||||
}
|
||||
|
||||
fn numeric_parts(version: &str) -> Vec<u32> {
|
||||
version
|
||||
.trim_start_matches('v')
|
||||
.split('.')
|
||||
.map(|segment| {
|
||||
segment
|
||||
.chars()
|
||||
.take_while(|character| character.is_ascii_digit())
|
||||
.collect::<String>()
|
||||
.parse::<u32>()
|
||||
.unwrap_or(0)
|
||||
})
|
||||
.take(3)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn new_version_is_newer_than_current() {
|
||||
assert_eq!(compare_versions("0.1.0", "0.2.0"), Ordering::Less);
|
||||
assert_eq!(compare_versions("0.1.9", "0.2.0"), Ordering::Less);
|
||||
assert_eq!(compare_versions("0.9.9", "1.0.0"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_version_is_not_newer() {
|
||||
assert_eq!(compare_versions("0.2.0", "0.1.0"), Ordering::Greater);
|
||||
assert_eq!(compare_versions("0.3.0", "0.3.0"), Ordering::Equal);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leading_v_and_prerelease_tags_are_ignored() {
|
||||
assert_eq!(compare_versions("v0.1.0", "v0.2.0"), Ordering::Less);
|
||||
assert_eq!(compare_versions("v0.2.0", "0.2.0"), Ordering::Equal);
|
||||
assert_eq!(compare_versions("0.2.0", "0.2.0-beta.1"), Ordering::Equal);
|
||||
assert_eq!(compare_versions("0.1.0", "0.2.0-beta.1"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn msi_asset_is_preferred_over_exe() {
|
||||
let assets = vec![
|
||||
GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64-setup.exe".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/setup.exe".to_string(),
|
||||
},
|
||||
GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64_en-US.msi".to_string(),
|
||||
size: Some(2),
|
||||
browser_download_url: "https://example.test/setup.msi".to_string(),
|
||||
},
|
||||
];
|
||||
let selected = select_installer_asset(&assets).expect("asset");
|
||||
assert_eq!(selected.name, "ClipForge_0.2.0_x64_en-US.msi");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exe_asset_is_selected_when_no_msi_exists() {
|
||||
let assets = vec![GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64-setup.exe".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/setup.exe".to_string(),
|
||||
}];
|
||||
let selected = select_installer_asset(&assets).expect("asset");
|
||||
assert_eq!(selected.name, "ClipForge_0.2.0_x64-setup.exe");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uninstaller_and_unknown_assets_are_rejected() {
|
||||
let assets = vec![
|
||||
GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64_uninstall.exe".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/uninstall.exe".to_string(),
|
||||
},
|
||||
GitHubAsset {
|
||||
name: "linux-port.AppImage".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/linux.AppImage".to_string(),
|
||||
},
|
||||
GitHubAsset {
|
||||
name: "checksums.txt".to_string(),
|
||||
size: Some(1),
|
||||
browser_download_url: "https://example.test/checksums.txt".to_string(),
|
||||
},
|
||||
];
|
||||
assert!(select_installer_asset(&assets).is_none());
|
||||
assert_eq!(normalize_version("v0.2.0"), "0.2.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn update_check_marks_latest_github_release_as_available() {
|
||||
let release = GitHubRelease {
|
||||
tag_name: "v0.2.0".to_string(),
|
||||
published_at: Some("2026-09-01T00:00:00Z".to_string()),
|
||||
body: Some("Update notes".to_string()),
|
||||
assets: vec![GitHubAsset {
|
||||
name: "ClipForge_0.2.0_x64-setup.exe".to_string(),
|
||||
size: Some(1_000_000),
|
||||
browser_download_url: "https://example.test/ClipForge_0.2.0.exe".to_string(),
|
||||
}],
|
||||
};
|
||||
let check = build_update_check("0.1.0", &release).expect("check");
|
||||
assert!(check.update_available);
|
||||
assert_eq!(check.latest_version, "0.2.0");
|
||||
assert_eq!(
|
||||
check.installer_file.as_deref(),
|
||||
Some("ClipForge_0.2.0_x64-setup.exe")
|
||||
);
|
||||
assert_eq!(check.published_at.as_deref(), Some("2026-09-01T00:00:00Z"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires live network access to the GitHub API"]
|
||||
fn live_check_against_github_repo() {
|
||||
let check = check_for_updates(DEFAULT_UPDATE_REPO, "0.0.1").expect("check");
|
||||
assert!(
|
||||
check.download_url.as_deref().filter(|value| !value.is_empty()).is_some()
|
||||
|| !check.update_available
|
||||
);
|
||||
assert!(!check.latest_version.is_empty());
|
||||
}
|
||||
}
|
||||
+95
-3
@@ -81,6 +81,7 @@ type DesktopStatus = {
|
||||
storage_limit_gb: number;
|
||||
excluded_window_titles: string[];
|
||||
separate_audio_tracks: boolean;
|
||||
app_version: string;
|
||||
};
|
||||
|
||||
type ClipDto = {
|
||||
@@ -118,6 +119,16 @@ type AudioDeviceDto = {
|
||||
kind: "input" | "system_loopback";
|
||||
};
|
||||
|
||||
type UpdateInfo = {
|
||||
checked: boolean;
|
||||
updateAvailable: boolean;
|
||||
latestVersion: string;
|
||||
installerFile: string;
|
||||
downloadUrl: string;
|
||||
message: string;
|
||||
applying: boolean;
|
||||
};
|
||||
|
||||
type AppState = {
|
||||
activeView: "Library" | "Recording" | "Auto Clip" | "Uploads" | "Settings";
|
||||
recordingState: RecordingState;
|
||||
@@ -165,6 +176,8 @@ type AppState = {
|
||||
excludedWindowTitles: string[];
|
||||
excludedWindowText: string;
|
||||
separateAudioTracks: boolean;
|
||||
appVersion: string;
|
||||
update: UpdateInfo;
|
||||
};
|
||||
|
||||
type TauriGlobal = {
|
||||
@@ -248,6 +261,16 @@ const state: AppState = {
|
||||
excludedWindowTitles: [],
|
||||
excludedWindowText: "",
|
||||
separateAudioTracks: false,
|
||||
appVersion: "0.1.0",
|
||||
update: {
|
||||
checked: false,
|
||||
updateAvailable: false,
|
||||
latestVersion: "",
|
||||
installerFile: "",
|
||||
downloadUrl: "",
|
||||
message: "Updates have not been checked yet.",
|
||||
applying: false,
|
||||
},
|
||||
};
|
||||
|
||||
const root = document.querySelector<HTMLDivElement>("#app");
|
||||
@@ -693,9 +716,14 @@ function renderSettingsView() {
|
||||
<p class="muted">Old temporary buffer segments are removed automatically once the buffer reaches the cap; saved clips are kept.</p>
|
||||
</article>
|
||||
<article class="settings-panel">
|
||||
<p class="eyebrow">Support</p>
|
||||
<h2>Crash logs</h2>
|
||||
<p class="muted">Panic details are written to the logs folder so issues can be investigated.</p>
|
||||
<p class="eyebrow">About & support</p>
|
||||
<h2>ClipForge ${escapeHtml(state.appVersion)}</h2>
|
||||
<p class="muted">${escapeHtml(state.update.message)}</p>
|
||||
${state.update.updateAvailable ? `
|
||||
<button data-action="download-update" ${state.update.applying ? "disabled" : ""}>Download & install v${escapeHtml(state.update.latestVersion)}</button>
|
||||
` : `
|
||||
<button data-action="check-updates" ${state.update.applying ? "disabled" : ""}>Check for updates</button>
|
||||
`}
|
||||
<button data-action="reveal-crash-logs">Reveal Crash Logs</button>
|
||||
</article>
|
||||
<article class="settings-panel">
|
||||
@@ -916,6 +944,14 @@ function bindEvents() {
|
||||
void saveCaptureSettings();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='check-updates']")?.addEventListener("click", () => {
|
||||
void checkForUpdates();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='download-update']")?.addEventListener("click", () => {
|
||||
void downloadUpdate();
|
||||
});
|
||||
|
||||
appRoot.querySelector<HTMLButtonElement>("[data-action='reveal-crash-logs']")?.addEventListener("click", () => {
|
||||
void revealCrashLogs();
|
||||
});
|
||||
@@ -1205,6 +1241,7 @@ function applyDesktopStatus(status: DesktopStatus) {
|
||||
state.excludedWindowTitles = status.excluded_window_titles ?? [];
|
||||
state.excludedWindowText = (status.excluded_window_titles ?? []).join(", ");
|
||||
state.separateAudioTracks = status.separate_audio_tracks ?? false;
|
||||
state.appVersion = status.app_version ?? state.appVersion;
|
||||
}
|
||||
|
||||
async function trimSelectedClip() {
|
||||
@@ -1604,6 +1641,61 @@ function parseResolution(value: string): [number, number] {
|
||||
];
|
||||
}
|
||||
|
||||
async function checkForUpdates() {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
}
|
||||
|
||||
state.update.applying = true;
|
||||
state.update.message = "Checking for updates…";
|
||||
render();
|
||||
|
||||
try {
|
||||
const info = await tauriInvoke<{
|
||||
update_available: boolean;
|
||||
latest_version: string;
|
||||
installer_file: string | null;
|
||||
download_url: string | null;
|
||||
message: string;
|
||||
}>("check_for_updates");
|
||||
state.update.checked = true;
|
||||
state.update.updateAvailable = info.update_available;
|
||||
state.update.latestVersion = info.latest_version;
|
||||
state.update.installerFile = info.installer_file ?? "";
|
||||
state.update.downloadUrl = info.download_url ?? "";
|
||||
state.update.message = info.message;
|
||||
} catch (error) {
|
||||
console.warn("Could not check for updates", error);
|
||||
state.update.message = `Could not check for updates: ${String(error)}`;
|
||||
}
|
||||
|
||||
state.update.applying = false;
|
||||
render();
|
||||
}
|
||||
|
||||
async function downloadUpdate() {
|
||||
if (!tauriInvoke || !state.update.downloadUrl || !state.update.installerFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
state.update.applying = true;
|
||||
state.update.message = "Downloading update…";
|
||||
render();
|
||||
|
||||
try {
|
||||
const message = await tauriInvoke<string>("download_and_apply_update", {
|
||||
downloadUrl: state.update.downloadUrl,
|
||||
installerFile: state.update.installerFile,
|
||||
});
|
||||
showNotice(message);
|
||||
} catch (error) {
|
||||
console.warn("Could not download the update", error);
|
||||
state.update.applying = false;
|
||||
state.update.message = `Could not download the update: ${String(error)}`;
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
async function takeScreenshot() {
|
||||
if (!tauriInvoke) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user