From 0077d1bfe278896710977a863aebc7676968f4f6 Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:18:02 +1030 Subject: [PATCH 1/8] Add update checker --- commet/lib/config/build_config.dart | 3 + commet/lib/config/preferences.dart | 9 +++ commet/lib/main.dart | 8 ++ .../ui/organisms/home_screen/home_screen.dart | 7 ++ .../about/settings_category_about.dart | 15 +++- .../categories/app/general_settings_page.dart | 4 + .../pages/setup/menus/check_for_updates.dart | 75 ++++++++++++++++++ commet/lib/ui/pages/setup/setup_page.dart | 4 - commet/lib/utils/update_checker.dart | 79 +++++++++++++++++++ 9 files changed, 197 insertions(+), 7 deletions(-) create mode 100644 commet/lib/ui/pages/setup/menus/check_for_updates.dart create mode 100644 commet/lib/utils/update_checker.dart diff --git a/commet/lib/config/build_config.dart b/commet/lib/config/build_config.dart index e342733a5..c23409534 100644 --- a/commet/lib/config/build_config.dart +++ b/commet/lib/config/build_config.dart @@ -19,6 +19,9 @@ class BuildConfig { static const String BUILD_DETAIL = String.fromEnvironment('BUILD_DETAIL', defaultValue: "default"); + static DateTime BUILD_DATE = DateTime.fromMillisecondsSinceEpoch( + int.parse(String.fromEnvironment('BUILD_DETAIL', defaultValue: "0"))); + static const bool ENABLE_GOOGLE_SERVICES = bool.fromEnvironment("ENABLE_GOOGLE_SERVICES", defaultValue: false); diff --git a/commet/lib/config/preferences.dart b/commet/lib/config/preferences.dart index ac7267c86..d2f1d91e7 100644 --- a/commet/lib/config/preferences.dart +++ b/commet/lib/config/preferences.dart @@ -74,6 +74,8 @@ class Preferences { static const String _hideRoomSidePanel = "hide_room_side_panel"; + static const String _checkForUpdates = "check_for_updates"; + final StreamController _onSettingChanged = StreamController.broadcast(); Stream get onSettingChanged => _onSettingChanged.stream; bool isInit = false; @@ -471,4 +473,11 @@ class Preferences { _preferences!.setBool(_hideRoomSidePanel, value); _onSettingChanged.add(null); } + + bool? get checkForUpdates => _preferences!.getBool(_checkForUpdates); + + Future setCheckForUpdates(bool value) async { + await _preferences!.setBool(_checkForUpdates, value); + _onSettingChanged.add(null); + } } diff --git a/commet/lib/main.dart b/commet/lib/main.dart index ad898ad65..6e735b9f1 100644 --- a/commet/lib/main.dart +++ b/commet/lib/main.dart @@ -17,14 +17,17 @@ import 'package:commet/ui/pages/bubble/bubble_page.dart'; import 'package:commet/ui/pages/fatal_error/fatal_error_page.dart'; import 'package:commet/ui/pages/login/login_page.dart'; import 'package:commet/ui/pages/main/main_page.dart'; +import 'package:commet/ui/pages/setup/menus/check_for_updates.dart'; import 'package:commet/utils/android_intent_helper.dart'; import 'package:commet/utils/custom_uri.dart'; import 'package:commet/utils/background_tasks/background_task_manager.dart'; import 'package:commet/utils/database/database_server.dart'; import 'package:commet/utils/emoji/unicode_emoji.dart'; import 'package:commet/utils/event_bus.dart'; +import 'package:commet/utils/first_time_setup.dart'; import 'package:commet/utils/scaled_app.dart'; import 'package:commet/utils/shortcuts_manager.dart'; +import 'package:commet/utils/update_checker.dart'; import 'package:commet/utils/window_management.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/foundation.dart'; @@ -251,6 +254,11 @@ Future startGui() async { var initialTheme = await preferences.resolveTheme(); + if (preferences.checkForUpdates == null && + UpdateChecker.shouldCheckForUpdates) { + FirstTimeSetup.registerPostLoginSetup(UpdateCheckerSetup()); + } + runApp(App( clientManager: clientManager!, initialTheme: initialTheme, diff --git a/commet/lib/ui/organisms/home_screen/home_screen.dart b/commet/lib/ui/organisms/home_screen/home_screen.dart index e401302a0..608fe5ae1 100644 --- a/commet/lib/ui/organisms/home_screen/home_screen.dart +++ b/commet/lib/ui/organisms/home_screen/home_screen.dart @@ -2,9 +2,11 @@ import 'dart:async'; import 'package:commet/client/client.dart'; import 'package:commet/client/client_manager.dart'; +import 'package:commet/main.dart'; import 'package:commet/ui/organisms/invitation_view/incoming_invitations_view.dart'; import 'package:commet/utils/event_bus.dart'; import 'package:commet/ui/organisms/home_screen/home_screen_view.dart'; +import 'package:commet/utils/update_checker.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -28,6 +30,11 @@ class _HomeScreenState extends State { @override void initState() { syncSub = widget.clientManager.onSync.stream.listen(onSync); + + if (preferences.checkForUpdates == true) { + UpdateChecker.checkForUpdates(); + } + updateRecent(); super.initState(); } diff --git a/commet/lib/ui/pages/settings/categories/about/settings_category_about.dart b/commet/lib/ui/pages/settings/categories/about/settings_category_about.dart index fc7d265d5..305c454a0 100644 --- a/commet/lib/ui/pages/settings/categories/about/settings_category_about.dart +++ b/commet/lib/ui/pages/settings/categories/about/settings_category_about.dart @@ -16,6 +16,7 @@ import 'package:flutter/material.dart' as m; import 'package:tiamat/tiamat.dart' as tiamat; import 'package:vodozemac/vodozemac.dart' as vod; +import 'package:intl/intl.dart' as intl; class SettingsCategoryAbout implements SettingsCategory { String get labelSettingsAppLogs => Intl.message("Logs", @@ -140,8 +141,16 @@ class _AppInfoState extends State<_AppInfo> { const tiamat.Text.largeTitle(BuildConfig.appName), const tiamat.Text.labelEmphasised( BuildConfig.VERSION_TAG), - tiamat.Text.labelLow( - "${BuildConfig.GIT_HASH.substring(0, 7)} ${BuildConfig.BUILD_DETAIL}"), + Row( + spacing: 8, + children: [ + tiamat.Text.labelLow( + "${BuildConfig.GIT_HASH.substring(0, 7)} ${BuildConfig.BUILD_DETAIL}"), + tiamat.Text.labelLow("Built: " + + intl.DateFormat(intl.DateFormat.YEAR_MONTH_DAY) + .format(BuildConfig.BUILD_DATE)), + ], + ), if (deviceInfo != null) Row( children: [ @@ -214,7 +223,7 @@ Platform: `${BuildConfig.PLATFORM}` Version: `${BuildConfig.VERSION_TAG}` Git Hash: `${BuildConfig.GIT_HASH}` Detail: `${BuildConfig.BUILD_DETAIL}` - +Build Timestamp: `${BuildConfig.BUILD_DATE.millisecondsSinceEpoch} (${intl.DateFormat(intl.DateFormat.YEAR_MONTH_DAY).format(BuildConfig.BUILD_DATE)})` **System Info** ${deviceInfo?.data["name"] is String ? "Name: `${deviceInfo!.data["name"]}`" : ""} diff --git a/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart b/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart index 2de7528c9..dad9240fd 100644 --- a/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart +++ b/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart @@ -1,4 +1,6 @@ import 'package:commet/main.dart'; +import 'package:commet/ui/pages/setup/menus/check_for_updates.dart'; +import 'package:commet/utils/update_checker.dart'; import 'package:flutter/widgets.dart'; import 'package:intl/intl.dart'; @@ -127,6 +129,8 @@ class GeneralSettingsPageState extends State { }); }, ), + if (UpdateChecker.shouldCheckForUpdates) + CheckForUpdatesSettingWidget(), ]), ), const SizedBox( diff --git a/commet/lib/ui/pages/setup/menus/check_for_updates.dart b/commet/lib/ui/pages/setup/menus/check_for_updates.dart new file mode 100644 index 000000000..fe61f5d2a --- /dev/null +++ b/commet/lib/ui/pages/setup/menus/check_for_updates.dart @@ -0,0 +1,75 @@ +import 'dart:async'; + +import 'package:commet/main.dart'; +import 'package:commet/ui/pages/settings/categories/app/general_settings_page.dart'; +import 'package:commet/ui/pages/setup/setup_menu.dart'; +import 'package:flutter/material.dart'; +import 'package:tiamat/tiamat.dart' as tiamat; + +class UpdateCheckerSetup implements SetupMenu { + StreamController controller = StreamController(); + + GlobalKey key = GlobalKey(); + + @override + Widget builder(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + tiamat.Text.largeTitle("Check for updates"), + tiamat.Text.label( + "Would you like Commet to automatically check for new updates?"), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + decoration: BoxDecoration( + color: ColorScheme.of(context).surfaceContainerLowest, + borderRadius: BorderRadius.circular(8), + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: CheckForUpdatesSettingWidget(), + )), + ), + ], + ); + } + + @override + Stream get onStateChanged => controller.stream; + + @override + SetupMenuState state = SetupMenuState.canProgress; + + @override + Future submit() async { + if (preferences.checkForUpdates == null) { + preferences.setCheckForUpdates(false); + } + } +} + +class CheckForUpdatesSettingWidget extends StatefulWidget { + const CheckForUpdatesSettingWidget({super.key}); + + @override + State createState() => + _CheckForUpdatesSettingWidgetState(); +} + +class _CheckForUpdatesSettingWidgetState + extends State { + @override + Widget build(BuildContext context) { + return GeneralSettingsPageState.settingToggle( + preferences.checkForUpdates ?? false, + title: "Check for updates", + description: + "Automatically check if there is a newer version of Commet available", + onChanged: (v) { + preferences.setCheckForUpdates(v); + setState(() {}); + }, + ); + } +} diff --git a/commet/lib/ui/pages/setup/setup_page.dart b/commet/lib/ui/pages/setup/setup_page.dart index 763c16d51..26e315124 100644 --- a/commet/lib/ui/pages/setup/setup_page.dart +++ b/commet/lib/ui/pages/setup/setup_page.dart @@ -19,9 +19,6 @@ class _SetupPageState extends State { int currentMenuIndex = 0; late SetupMenu currentMenu; - String get setupPageBeforeYouBegin => Intl.message("Before you begin...", - name: "setupPageBeforeYouBegin", desc: "Title for first time setup page"); - @override void initState() { super.initState(); @@ -40,7 +37,6 @@ class _SetupPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ - tiamat.Text.largeTitle(setupPageBeforeYouBegin), Flexible( child: ClipRRect( borderRadius: BorderRadius.circular(10), diff --git a/commet/lib/utils/update_checker.dart b/commet/lib/utils/update_checker.dart new file mode 100644 index 000000000..905650ece --- /dev/null +++ b/commet/lib/utils/update_checker.dart @@ -0,0 +1,79 @@ +import 'dart:convert'; + +import 'package:commet/client/alert.dart'; +import 'package:commet/client/matrix/matrix_client.dart'; +import 'package:commet/config/build_config.dart'; +import 'package:commet/config/platform_utils.dart'; +import 'package:commet/debug/log.dart'; +import 'package:commet/main.dart'; +import 'package:commet/utils/link_utils.dart'; + +import 'package:http/http.dart' as http; + +class UpdateChecker { + static bool foundUpdate = false; + + static Future checkForUpdates() async { + if (foundUpdate) return; + + if (!shouldCheckForUpdates) { + return; + } + + const key = "chat.commet.published_version"; + + var url = Uri.parse( + "https://data.commet.chat/_matrix/federation/v1/query/profile?user_id=@updates:data.commet.chat"); + + var response = await http.get(url); + + if (response.statusCode == 200) { + foundUpdate = true; + } + + Log.i("Got update data: ${response.body}"); + + var fields = jsonDecode(response.body) as Map; + + if (fields.containsKey(key)) { + var date = fields["chat.commet.build_date_ms"]; + + var val = int.parse(date); + var time = DateTime.fromMillisecondsSinceEpoch(val); + + if (time.isAfter(BuildConfig.BUILD_DATE)) { + var tag = fields[key]; + clientManager!.alertManager.addAlert(Alert(AlertType.info, + messageGetter: () => + "There is a newer version of Commet available: ${tag}", + titleGetter: () => "Update Available", + action: doUpdateAction)); + } else { + Log.i( + "Found an update, but it's build date is not after the current build, current: ${BuildConfig.BUILD_DATE.millisecondsSinceEpoch} remote: ${time.millisecondsSinceEpoch}"); + } + + return; + } + } + + static bool get shouldCheckForUpdates { + if (PlatformUtils.isWeb) { + return false; + } + + if (preferences.checkForUpdates != true) { + return false; + } + + if (BuildConfig.VERSION_TAG == "v0.0.0-artifact") { + return false; + } + + return true; + } + + static doUpdateAction() { + LinkUtils.open(Uri.parse("https://github.com/commetchat/commet/releases")); + } +} From 47877a75b2805ca2516ea00a891f06507d62c060 Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:18:17 +1030 Subject: [PATCH 2/8] Update setup_page.dart --- commet/lib/ui/pages/setup/setup_page.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/commet/lib/ui/pages/setup/setup_page.dart b/commet/lib/ui/pages/setup/setup_page.dart index 26e315124..849ab6824 100644 --- a/commet/lib/ui/pages/setup/setup_page.dart +++ b/commet/lib/ui/pages/setup/setup_page.dart @@ -2,8 +2,6 @@ import 'package:commet/config/build_config.dart'; import 'package:commet/ui/atoms/scaled_safe_area.dart'; import 'package:commet/ui/pages/setup/setup_menu.dart'; import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; - import 'package:tiamat/tiamat.dart'; import 'package:tiamat/tiamat.dart' as tiamat; From 9f475a4222775051ffe40538ea6995e38cc3fb0a Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:48:04 +1030 Subject: [PATCH 3/8] run update installer if it exists --- commet/lib/client/alert.dart | 3 +- .../notification_manager.dart | 2 +- commet/lib/ui/molecules/alert_view.dart | 2 +- commet/lib/utils/update_checker.dart | 75 +++++++++++++++++-- 4 files changed, 71 insertions(+), 11 deletions(-) diff --git a/commet/lib/client/alert.dart b/commet/lib/client/alert.dart index b12ea2a1e..50ab51659 100644 --- a/commet/lib/client/alert.dart +++ b/commet/lib/client/alert.dart @@ -1,11 +1,12 @@ import 'package:commet/utils/notifying_list.dart'; +import 'package:flutter/widgets.dart'; enum AlertType { info, warning, critical } class Alert { late String Function() _messageGetter; late String Function() _titleGetter; - late Function()? action; + late Function(BuildContext context)? action; AlertType type; String get title => _titleGetter(); diff --git a/commet/lib/client/components/push_notification/notification_manager.dart b/commet/lib/client/components/push_notification/notification_manager.dart index e11c9436b..1f25f57e5 100644 --- a/commet/lib/client/components/push_notification/notification_manager.dart +++ b/commet/lib/client/components/push_notification/notification_manager.dart @@ -46,7 +46,7 @@ class NotificationManager { messageGetter: () => "The last attempt to start the notification updating service failed. Push notifications will not be updated in the background until this is resolved. Tap for more info", titleGetter: () => "Couldn't update notifications in background", - action: () => LinkUtils.open(Uri.parse( + action: (_) => LinkUtils.open(Uri.parse( "https://commet.chat/troubleshoot/android-background-service-failed/")), ); diff --git a/commet/lib/ui/molecules/alert_view.dart b/commet/lib/ui/molecules/alert_view.dart index aab107bbc..568f160ef 100644 --- a/commet/lib/ui/molecules/alert_view.dart +++ b/commet/lib/ui/molecules/alert_view.dart @@ -11,7 +11,7 @@ class AlertView extends StatelessWidget { return Material( color: Colors.transparent, child: InkWell( - onTap: alert.action, + onTap: alert.action == null ? null : () => alert.action?.call(context), child: Row(children: [ Padding( padding: const EdgeInsets.all(8.0), diff --git a/commet/lib/utils/update_checker.dart b/commet/lib/utils/update_checker.dart index 905650ece..5ef0576fb 100644 --- a/commet/lib/utils/update_checker.dart +++ b/commet/lib/utils/update_checker.dart @@ -1,12 +1,16 @@ import 'dart:convert'; +import 'dart:io'; import 'package:commet/client/alert.dart'; -import 'package:commet/client/matrix/matrix_client.dart'; import 'package:commet/config/build_config.dart'; import 'package:commet/config/platform_utils.dart'; import 'package:commet/debug/log.dart'; import 'package:commet/main.dart'; +import 'package:commet/ui/navigation/adaptive_dialog.dart'; +import 'package:commet/utils/error_utils.dart'; import 'package:commet/utils/link_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:path/path.dart' as path; import 'package:http/http.dart' as http; @@ -20,6 +24,10 @@ class UpdateChecker { return; } + if (preferences.checkForUpdates != true) { + return; + } + const key = "chat.commet.published_version"; var url = Uri.parse( @@ -50,7 +58,7 @@ class UpdateChecker { action: doUpdateAction)); } else { Log.i( - "Found an update, but it's build date is not after the current build, current: ${BuildConfig.BUILD_DATE.millisecondsSinceEpoch} remote: ${time.millisecondsSinceEpoch}"); + "Found an update, but it's build date is not after the current build, current: ${BuildConfig.BUILD_DATE.toString()} remote: ${time.toString()}"); } return; @@ -62,10 +70,6 @@ class UpdateChecker { return false; } - if (preferences.checkForUpdates != true) { - return false; - } - if (BuildConfig.VERSION_TAG == "v0.0.0-artifact") { return false; } @@ -73,7 +77,62 @@ class UpdateChecker { return true; } - static doUpdateAction() { - LinkUtils.open(Uri.parse("https://github.com/commetchat/commet/releases")); + static doUpdateAction(BuildContext context) async { + if (PlatformUtils.isWindows) { + windowsUpdateAction(context); + } + + if (PlatformUtils.isAndroid) { + LinkUtils.open(Uri.parse("https://commet.chat/install/android/")); + } + + if (PlatformUtils.isLinux) { + LinkUtils.open(Uri.parse("https://commet.chat/install/linux/")); + } + } + + static windowsUpdateAction(BuildContext context) async { + var exe = Platform.resolvedExecutable; + + var installPath = path.dirname(exe); + + var installerPath = + path.join(installPath, "installer", "commet-installer.exe"); + + Log.i("Installed at: $installerPath"); + + if (await File(installerPath).exists()) { + var confirmation = await AdaptiveDialog.confirmation(context, + prompt: "Would you like to run the update installer?"); + + if (confirmation == true) { + ErrorUtils.tryRun(context, () async { + Log.i("Found installer, doing automatic update"); + + for (var client in clientManager!.clients) { + await client.close(); + } + + Process.run( + installerPath, + [ + "--command", + "update", + ], + runInShell: true); + + // TODO: not this + await Future.delayed(Duration(seconds: 1)); + + exit(0); + }); + + return; + } + + if (confirmation == null) return; + } + + LinkUtils.open(Uri.parse("https://commet.chat/install/windows/")); } } From bda329a4c95ac9cc2334fcad2915b4b54d106cdd Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Mon, 26 Jan 2026 20:13:29 +1030 Subject: [PATCH 4/8] Update build_config.dart --- commet/lib/config/build_config.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commet/lib/config/build_config.dart b/commet/lib/config/build_config.dart index c23409534..856cfca53 100644 --- a/commet/lib/config/build_config.dart +++ b/commet/lib/config/build_config.dart @@ -19,8 +19,11 @@ class BuildConfig { static const String BUILD_DETAIL = String.fromEnvironment('BUILD_DETAIL', defaultValue: "default"); - static DateTime BUILD_DATE = DateTime.fromMillisecondsSinceEpoch( - int.parse(String.fromEnvironment('BUILD_DETAIL', defaultValue: "0"))); + static const String _BUILD_DATE = + String.fromEnvironment('BUILD_DETAIL', defaultValue: "0"); + + static DateTime get BUILD_DATE => + DateTime.fromMillisecondsSinceEpoch(int.parse(_BUILD_DATE)); static const bool ENABLE_GOOGLE_SERVICES = bool.fromEnvironment("ENABLE_GOOGLE_SERVICES", defaultValue: false); From 4c136ae73751060400dafede38e78c226414d650 Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Mon, 26 Jan 2026 21:38:38 +1030 Subject: [PATCH 5/8] Update build_config.dart --- commet/lib/config/build_config.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/commet/lib/config/build_config.dart b/commet/lib/config/build_config.dart index 856cfca53..353d9a27b 100644 --- a/commet/lib/config/build_config.dart +++ b/commet/lib/config/build_config.dart @@ -19,12 +19,6 @@ class BuildConfig { static const String BUILD_DETAIL = String.fromEnvironment('BUILD_DETAIL', defaultValue: "default"); - static const String _BUILD_DATE = - String.fromEnvironment('BUILD_DETAIL', defaultValue: "0"); - - static DateTime get BUILD_DATE => - DateTime.fromMillisecondsSinceEpoch(int.parse(_BUILD_DATE)); - static const bool ENABLE_GOOGLE_SERVICES = bool.fromEnvironment("ENABLE_GOOGLE_SERVICES", defaultValue: false); @@ -61,6 +55,12 @@ class BuildConfig { static Uri donationRewardsApiHost = Uri.https("stripe-rewards.commet.chat"); + static const String _BUILD_DATE = + String.fromEnvironment('BUILD_DATE', defaultValue: "0"); + + static DateTime get BUILD_DATE => + DateTime.fromMillisecondsSinceEpoch(int.parse(_BUILD_DATE)); + // IM SO SORRY static const String appName = MOBILE ? (ANDROID From cd44b422ed51a7864cb8955ec0b8c94f167846b0 Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Mon, 26 Jan 2026 21:42:41 +1030 Subject: [PATCH 6/8] Update build_release.dart --- commet/scripts/build_release.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commet/scripts/build_release.dart b/commet/scripts/build_release.dart index 2ffbaa169..dd42a1938 100644 --- a/commet/scripts/build_release.dart +++ b/commet/scripts/build_release.dart @@ -79,6 +79,8 @@ Future main(List args) async { "VERSION_TAG=$version", "--dart-define", "ENABLE_GOOGLE_SERVICES=$enableGoogleServices", + "--dart-define", + "BUILD_DATE=${DateTime.now().millisecondsSinceEpoch}", if (buildDetail != null) "--dart-define", if (buildDetail != null) "BUILD_DETAIL=$buildDetail", if (platform == "web") "--dart-define", From 5869a018a860ae02eb0e52ff50d3390ba62ca429 Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Mon, 26 Jan 2026 22:49:55 +1030 Subject: [PATCH 7/8] add a way to disable auto update prompt --- commet/lib/utils/update_checker.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/commet/lib/utils/update_checker.dart b/commet/lib/utils/update_checker.dart index 5ef0576fb..255771199 100644 --- a/commet/lib/utils/update_checker.dart +++ b/commet/lib/utils/update_checker.dart @@ -49,13 +49,15 @@ class UpdateChecker { var val = int.parse(date); var time = DateTime.fromMillisecondsSinceEpoch(val); + var canAutoUpdate = fields["chat.commet.auto_update"] == "true"; + Log.i("Supports auto update: $canAutoUpdate"); if (time.isAfter(BuildConfig.BUILD_DATE)) { var tag = fields[key]; clientManager!.alertManager.addAlert(Alert(AlertType.info, messageGetter: () => "There is a newer version of Commet available: ${tag}", titleGetter: () => "Update Available", - action: doUpdateAction)); + action: (context) => doUpdateAction(context, canAutoUpdate))); } else { Log.i( "Found an update, but it's build date is not after the current build, current: ${BuildConfig.BUILD_DATE.toString()} remote: ${time.toString()}"); @@ -77,9 +79,9 @@ class UpdateChecker { return true; } - static doUpdateAction(BuildContext context) async { + static doUpdateAction(BuildContext context, bool canAutoUpdate) async { if (PlatformUtils.isWindows) { - windowsUpdateAction(context); + windowsUpdateAction(context, canAutoUpdate); } if (PlatformUtils.isAndroid) { @@ -91,7 +93,7 @@ class UpdateChecker { } } - static windowsUpdateAction(BuildContext context) async { + static windowsUpdateAction(BuildContext context, bool canAutoUpdate) async { var exe = Platform.resolvedExecutable; var installPath = path.dirname(exe); @@ -101,12 +103,12 @@ class UpdateChecker { Log.i("Installed at: $installerPath"); - if (await File(installerPath).exists()) { + if (await File(installerPath).exists() && canAutoUpdate) { var confirmation = await AdaptiveDialog.confirmation(context, prompt: "Would you like to run the update installer?"); if (confirmation == true) { - ErrorUtils.tryRun(context, () async { + await ErrorUtils.tryRun(context, () async { Log.i("Found installer, doing automatic update"); for (var client in clientManager!.clients) { @@ -123,11 +125,9 @@ class UpdateChecker { // TODO: not this await Future.delayed(Duration(seconds: 1)); - - exit(0); }); - return; + exit(0); } if (confirmation == null) return; From 653f2b2582a1ff8cf94a9c59d6a0a3a30c3e58f3 Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Mon, 26 Jan 2026 22:49:59 +1030 Subject: [PATCH 8/8] Update settings_category_about.dart --- .../categories/about/settings_category_about.dart | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/commet/lib/ui/pages/settings/categories/about/settings_category_about.dart b/commet/lib/ui/pages/settings/categories/about/settings_category_about.dart index 305c454a0..4ead0ae3f 100644 --- a/commet/lib/ui/pages/settings/categories/about/settings_category_about.dart +++ b/commet/lib/ui/pages/settings/categories/about/settings_category_about.dart @@ -141,16 +141,11 @@ class _AppInfoState extends State<_AppInfo> { const tiamat.Text.largeTitle(BuildConfig.appName), const tiamat.Text.labelEmphasised( BuildConfig.VERSION_TAG), - Row( - spacing: 8, - children: [ - tiamat.Text.labelLow( - "${BuildConfig.GIT_HASH.substring(0, 7)} ${BuildConfig.BUILD_DETAIL}"), - tiamat.Text.labelLow("Built: " + - intl.DateFormat(intl.DateFormat.YEAR_MONTH_DAY) - .format(BuildConfig.BUILD_DATE)), - ], - ), + tiamat.Text.labelLow( + "${BuildConfig.GIT_HASH.substring(0, 7)} ${BuildConfig.BUILD_DETAIL}"), + tiamat.Text.labelLow("Built: " + + intl.DateFormat(intl.DateFormat.YEAR_MONTH_DAY) + .format(BuildConfig.BUILD_DATE)), if (deviceInfo != null) Row( children: [