From 9397badb883a0d0c8092a358c544c51bbf6507ce Mon Sep 17 00:00:00 2001 From: Artem Sedykh Date: Sun, 1 Mar 2026 22:29:07 +0300 Subject: [PATCH] Added profile-update-interval applying logic --- lib/app/modules/profile_manager.dart | 25 +++++++++++++++++++--- lib/screens/add_profile_by_url_screen.dart | 1 - 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/app/modules/profile_manager.dart b/lib/app/modules/profile_manager.dart index 33fef3b..89a58e5 100644 --- a/lib/app/modules/profile_manager.dart +++ b/lib/app/modules/profile_manager.dart @@ -239,6 +239,7 @@ class ProfileSetting { ps.remark = remark; ps.patch = patch; ps.updateInterval = updateInterval; + ps.updateIntervalByProfile = updateIntervalByProfile; ps.update = update; ps.url = url; ps.userAgent = userAgent; @@ -758,6 +759,20 @@ class ProfileManager { } } profile.updateSubscriptionTraffic(result.data); + if (result.data != null) { + final profileUpdateInterval = result.data!.value( + "profile-update-interval", + ); + if (profileUpdateInterval != null) { + var pui = int.tryParse(profileUpdateInterval); + if (pui != null) { + if (pui < 1) { + pui = 1; + } + profile.updateIntervalByProfile = Duration(hours: pui); + } + } + } } await save(); updating.remove(id); @@ -772,12 +787,16 @@ class ProfileManager { static Future updateByTicker() async { DateTime now = DateTime.now(); for (var profile in _config.profiles) { - if (!profile.isRemote() || profile.updateInterval == null) { + if (!profile.isRemote()) { + continue; + } + final interval = + profile.updateIntervalByProfile ?? profile.updateInterval; + if (interval == null) { continue; } if (profile.update == null || - now.difference(profile.update!).inSeconds >= - profile.updateInterval!.inSeconds) { + now.difference(profile.update!).inSeconds >= interval.inSeconds) { update(profile.id); } } diff --git a/lib/screens/add_profile_by_url_screen.dart b/lib/screens/add_profile_by_url_screen.dart index 3094442..e5c4fce 100644 --- a/lib/screens/add_profile_by_url_screen.dart +++ b/lib/screens/add_profile_by_url_screen.dart @@ -45,7 +45,6 @@ class _AddProfileByUrlScreenState final _textControllerLink = TextEditingController(); final _textControllerRemark = TextEditingController(); Duration? _updateInterval = const Duration(hours: 24); - Duration? _updateIntervalByProfile; //todo profile-update-interval String _userAgent = ""; bool _xhwid = false; String _decryptPassword = "";