diff --git a/ui/flutter/lib/api/model/downloader_config.dart b/ui/flutter/lib/api/model/downloader_config.dart index e05ac3b4..4685db02 100644 --- a/ui/flutter/lib/api/model/downloader_config.dart +++ b/ui/flutter/lib/api/model/downloader_config.dart @@ -81,6 +81,7 @@ class ExtraConfig { bool lastDeleteTaskKeep; bool defaultDirectDownload; bool defaultBtClient; + bool notifyWhenNewVersion; ExtraConfigBt bt = ExtraConfigBt(); @@ -90,6 +91,7 @@ class ExtraConfig { this.lastDeleteTaskKeep = false, this.defaultDirectDownload = false, this.defaultBtClient = true, + this.notifyWhenNewVersion = true, }); factory ExtraConfig.fromJson(Map? json) => diff --git a/ui/flutter/lib/api/model/downloader_config.g.dart b/ui/flutter/lib/api/model/downloader_config.g.dart index b7f2aa52..3603b0e9 100644 --- a/ui/flutter/lib/api/model/downloader_config.g.dart +++ b/ui/flutter/lib/api/model/downloader_config.g.dart @@ -74,6 +74,7 @@ ExtraConfig _$ExtraConfigFromJson(Map json) => ExtraConfig( lastDeleteTaskKeep: json['lastDeleteTaskKeep'] as bool? ?? false, defaultDirectDownload: json['defaultDirectDownload'] as bool? ?? false, defaultBtClient: json['defaultBtClient'] as bool? ?? true, + notifyWhenNewVersion: json['notifyWhenNewVersion'] as bool? ?? true, )..bt = ExtraConfigBt.fromJson(json['bt'] as Map); Map _$ExtraConfigToJson(ExtraConfig instance) => @@ -83,6 +84,7 @@ Map _$ExtraConfigToJson(ExtraConfig instance) => 'lastDeleteTaskKeep': instance.lastDeleteTaskKeep, 'defaultDirectDownload': instance.defaultDirectDownload, 'defaultBtClient': instance.defaultBtClient, + 'notifyWhenNewVersion': instance.notifyWhenNewVersion, 'bt': instance.bt.toJson(), }; diff --git a/ui/flutter/lib/app/modules/app/controllers/app_controller.dart b/ui/flutter/lib/app/modules/app/controllers/app_controller.dart index 86188b0e..7fc966aa 100644 --- a/ui/flutter/lib/app/modules/app/controllers/app_controller.dart +++ b/ui/flutter/lib/app/modules/app/controllers/app_controller.dart @@ -506,6 +506,11 @@ class AppController extends GetxController with WindowListener, TrayListener { } Future _initCheckUpdate() async { + // Check if auto check update is enabled + if (!downloaderConfig.value.extra.notifyWhenNewVersion) { + return; + } + final versionInfo = await checkUpdate(); if (versionInfo != null) { await showUpdateDialog(Get.context!, versionInfo); diff --git a/ui/flutter/lib/app/modules/setting/views/setting_view.dart b/ui/flutter/lib/app/modules/setting/views/setting_view.dart index c1b64f2b..46725954 100644 --- a/ui/flutter/lib/app/modules/setting/views/setting_view.dart +++ b/ui/flutter/lib/app/modules/setting/views/setting_view.dart @@ -531,6 +531,25 @@ class SettingView extends GetView { ); } + final buildAutoCheckUpdate = _buildConfigItem( + 'notifyWhenNewVersion', + () => + downloaderCfg.value.extra.notifyWhenNewVersion ? 'on'.tr : 'off'.tr, + (Key key) { + return Container( + alignment: Alignment.centerLeft, + child: Switch( + value: downloaderCfg.value.extra.notifyWhenNewVersion, + onChanged: (bool value) async { + downloaderCfg.update((val) { + val!.extra.notifyWhenNewVersion = value; + }); + await debounceSave(); + }, + ), + ); + }); + buildThanks() { const thankPage = 'https://github.com/GopeedLab/gopeed/graphs/contributors'; @@ -957,6 +976,7 @@ class SettingView extends GetView { children: _addDivider([ buildHomepage(), buildVersion(), + buildAutoCheckUpdate(), buildThanks(), ]), )), diff --git a/ui/flutter/lib/i18n/langs/en_us.dart b/ui/flutter/lib/i18n/langs/en_us.dart index da6f5547..a40bcc90 100644 --- a/ui/flutter/lib/i18n/langs/en_us.dart +++ b/ui/flutter/lib/i18n/langs/en_us.dart @@ -52,6 +52,7 @@ const enUS = { 'themeLight': 'Light', 'themeDark': 'Dark', 'locale': 'Language', + 'notifyWhenNewVersion': 'Notify for updates', 'about': 'About', 'homepage': 'Homepage', 'version': 'Version', diff --git a/ui/flutter/lib/i18n/langs/zh_cn.dart b/ui/flutter/lib/i18n/langs/zh_cn.dart index acd437b6..b0debcd2 100644 --- a/ui/flutter/lib/i18n/langs/zh_cn.dart +++ b/ui/flutter/lib/i18n/langs/zh_cn.dart @@ -51,6 +51,7 @@ const zhCN = { 'themeLight': '明亮主题', 'themeDark': '暗黑主题', 'locale': '语言', + 'notifyWhenNewVersion': '有新版本时提醒', 'about': '关于', 'homepage': '主页', 'version': '版本',