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
+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