Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions lib/app/modules/profile_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -772,12 +787,16 @@ class ProfileManager {
static Future<void> 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);
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/screens/add_profile_by_url_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down