feat #14740: check for updates from the settings
Adds a "Nach Updates suchen" button to the settings' new Updates section, next to the app's own version. It runs check_for_update_now, the very same feed check the background loop uses (one implementation, shared via UpdateSchedule), so a manual check counts as an attempt for the same scheduler: success resets the 6 h interval and the failure count, a failure advances the backoff by one step, and a manual and a background check never run at the same time (serialized). An available update leaves the same state the background check does, so the main window's banner still shows it; the settings also show it inline with the existing "Installieren & neu starten" button and busy guard/hint. "None" and "error" results are shown inline (unlike the background check, which never surfaces its errors). On Linux (can_self_update) the button still asks the feed but offers no install, since Debian builds never self-update. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,6 +137,15 @@ export interface UpdateProgress {
|
||||
total: number | null
|
||||
}
|
||||
|
||||
/** Why the install button is disabled, shown next to it as a hint. */
|
||||
export const UPDATE_BUSY_HINT = 'Nach der laufenden Aufnahme/Verarbeitung möglich'
|
||||
|
||||
/** What a check (background or manual) found. */
|
||||
export type UpdateCheckResult =
|
||||
| { status: 'none' }
|
||||
| { status: 'available'; version: string }
|
||||
| { status: 'error'; message: string }
|
||||
|
||||
export interface Levels {
|
||||
mic: number
|
||||
out: number
|
||||
@@ -185,6 +194,14 @@ export const uploadTranscript = (id: CallId) => invoke<void>('upload_transcript'
|
||||
export const getUpdate = () => invoke<UpdateInfo | null>('get_update')
|
||||
/** Resolves only on failure: on success the app restarts. */
|
||||
export const installUpdate = () => invoke<void>('install_update')
|
||||
/** This build's own version, for the settings' "Updates" section. */
|
||||
export const getAppVersion = () => invoke<string>('get_app_version')
|
||||
/** Whether this build can install an update itself (Windows only). */
|
||||
export const canSelfUpdate = () => invoke<boolean>('can_self_update')
|
||||
/** "Nach Updates suchen": runs the same check as the background loop,
|
||||
* immediately. An `available` result leaves the same state `getUpdate`
|
||||
* reads, so the main window's banner shows it too. */
|
||||
export const checkForUpdateNow = () => invoke<UpdateCheckResult>('check_for_update_now')
|
||||
|
||||
export const onRecordingState = (handler: (state: RecordingState) => void): Promise<UnlistenFn> =>
|
||||
listen<RecordingState>('recording-state', (event) => handler(event.payload))
|
||||
@@ -218,6 +235,19 @@ export function meterFill(level: number): number {
|
||||
return Math.min(1, Math.max(0, (db + 60) / 60))
|
||||
}
|
||||
|
||||
function megabytes(bytes: number): string {
|
||||
return (bytes / 1024 / 1024).toLocaleString('de-DE', { maximumFractionDigits: 1 }) + ' MB'
|
||||
}
|
||||
|
||||
/** Text shown while an update installs (the banner and the settings'
|
||||
* Updates section share this). */
|
||||
export function updateProgressText(progress: UpdateProgress | null): string {
|
||||
if (!progress) return 'Update wird heruntergeladen…'
|
||||
if (progress.total === null) return `Update wird heruntergeladen… ${megabytes(progress.downloaded)}`
|
||||
if (progress.downloaded >= progress.total) return 'Update wird installiert…'
|
||||
return `Update wird heruntergeladen… ${Math.floor((progress.downloaded * 100) / progress.total)} %`
|
||||
}
|
||||
|
||||
/** Error text of a rejected command. */
|
||||
export function errorText(err: unknown): string {
|
||||
return typeof err === 'string' ? err : err instanceof Error ? err.message : String(err)
|
||||
|
||||
Reference in New Issue
Block a user