Merge commit '394fd672'

This commit is contained in:
2026-11-08 16:49:58 +00:00
16 changed files with 615 additions and 58 deletions
@@ -88,7 +88,13 @@ extension _SettingsTopicPages on _SettingsScreenState {
if (widget.showAndroidDownload)
_single('Android app', const SettingsAndroidDownloadSection()),
if (widget.showSignIn && appUpdatesSupported)
_single('App updates', SettingsUpdatesSection(endpoint: _endpoint)),
_single(
'App updates',
SettingsUpdatesSection(
endpoint: _endpoint,
servers: widget.servers,
),
),
if (!widget.showAndroidDownload &&
!(widget.showSignIn && appUpdatesSupported))
_single(
@@ -3,14 +3,20 @@ import 'package:flutter/material.dart';
import '../../ui/adaptive/host.dart';
import '../updates/app_updates.dart';
import 'server_connections.dart';
/// Check for updates: compares this build with the newest one the server
/// offers and installs it on request.
class SettingsUpdatesSection extends StatefulWidget {
const SettingsUpdatesSection({super.key, required this.endpoint});
const SettingsUpdatesSection({
super.key,
required this.endpoint,
this.servers,
});
/// The server's websocket address; its builds sit beside it.
final String endpoint;
final ServerConnections? servers;
@override
State<SettingsUpdatesSection> createState() => _SettingsUpdatesSectionState();
@@ -44,15 +50,25 @@ class _SettingsUpdatesSectionState extends State<SettingsUpdatesSection> {
_available = null;
});
try {
final latest = await fetchLatestUpdate(base);
final latest = widget.servers == null
? await fetchLatestUpdate(base)
: await newestServerUpdate(
widget.servers!.catalog.servers,
stillTrusted: (source, uri) => updateSourceStillTrusted(
widget.servers!.catalog.servers,
source,
uri,
),
);
if (!mounted) return;
final installed = _installed ?? 0;
setState(() {
if (latest.versionCode > installed) {
_available = latest;
_message = 'Build ${latest.versionCode} is available.';
_message =
'Build ${latest.versionCode} is available${latest.sourceName.isEmpty ? '' : ' from ${latest.sourceName}'}.';
} else {
_message = 'Up to date.';
_message = 'No newer compatible build found on reachable servers.';
}
});
} catch (error) {
@@ -77,7 +93,7 @@ class _SettingsUpdatesSectionState extends State<SettingsUpdatesSection> {
if (mounted) setState(() => _progress = value);
},
);
if (mounted) setState(() => _message = 'Opened the installer.');
if (mounted) setState(() => _message = 'Opened the downloaded update.');
} catch (error) {
if (mounted) setState(() => _message = '$error');
} finally {
@@ -139,7 +155,7 @@ class _SettingsUpdatesSectionState extends State<SettingsUpdatesSection> {
if (_available != null)
button(
const Key('settings-install-update'),
'Download and install',
'Download update',
_busy ? null : _install,
true,
),