Change proxies lifecycle
This commit is contained in:
@@ -21,9 +21,7 @@
|
|||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
"traffic": "Live Traffic",
|
"traffic": "Live Traffic",
|
||||||
"trafficTotal": "Total Traffic",
|
"trafficTotal": "Total Traffic"
|
||||||
"uplink": "↑",
|
|
||||||
"downlink": "↓"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
@@ -32,7 +30,7 @@
|
|||||||
"subscription": {
|
"subscription": {
|
||||||
"traffic": "Traffic",
|
"traffic": "Traffic",
|
||||||
"updatedTimeAgo": "Updated ${timeago}",
|
"updatedTimeAgo": "Updated ${timeago}",
|
||||||
"remainingDuration": "📅 ${duration} Days Remaining",
|
"remainingDuration": "${duration} Days Remaining",
|
||||||
"expired": "Expired",
|
"expired": "Expired",
|
||||||
"noTraffic": "No more traffic"
|
"noTraffic": "No more traffic"
|
||||||
},
|
},
|
||||||
@@ -109,7 +107,7 @@
|
|||||||
"silentStart": "Silent Start",
|
"silentStart": "Silent Start",
|
||||||
"openWorkingDir": "Open Working Directory",
|
"openWorkingDir": "Open Working Directory",
|
||||||
"ignoreBatteryOptimizations": "Ignore Battery Optimization",
|
"ignoreBatteryOptimizations": "Ignore Battery Optimization",
|
||||||
"ignoreBatteryOptimizationsMsg": "Remove restrictions for optimal VPN performance"
|
"ignoreBatteryOptimizationsMsg": "Remove restrictions for optimal VPN performance"
|
||||||
},
|
},
|
||||||
"advanced": {
|
"advanced": {
|
||||||
"sectionTitle": "Advanced",
|
"sectionTitle": "Advanced",
|
||||||
|
|||||||
@@ -21,9 +21,7 @@
|
|||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
"traffic": "مصرف لحظهای",
|
"traffic": "مصرف لحظهای",
|
||||||
"trafficTotal": "مصرف کل",
|
"trafficTotal": "مصرف کل"
|
||||||
"uplink": "↑",
|
|
||||||
"downlink": "↓"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
@@ -32,7 +30,7 @@
|
|||||||
"subscription": {
|
"subscription": {
|
||||||
"traffic": "ترافیک",
|
"traffic": "ترافیک",
|
||||||
"updatedTimeAgo": "بروزرسانی شده در ${timeago}",
|
"updatedTimeAgo": "بروزرسانی شده در ${timeago}",
|
||||||
"remainingDuration": "📅 ${duration} روز باقی مانده",
|
"remainingDuration": "${duration} روز باقی مانده",
|
||||||
"expired": "منقضی شده",
|
"expired": "منقضی شده",
|
||||||
"noTraffic": "پایان ترافیک"
|
"noTraffic": "پایان ترافیک"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class Profile with _$Profile {
|
|||||||
if (title.isEmpty) {
|
if (title.isEmpty) {
|
||||||
final contentDisposition = headers['content-disposition']?.single;
|
final contentDisposition = headers['content-disposition']?.single;
|
||||||
if (contentDisposition != null) {
|
if (contentDisposition != null) {
|
||||||
final RegExp regExp = RegExp(r'filename="([^"]*)"');
|
final RegExp regExp = RegExp('filename="([^"]*)"');
|
||||||
final match = regExp.firstMatch(contentDisposition);
|
final match = regExp.firstMatch(contentDisposition);
|
||||||
if (match != null && match.groupCount >= 1) {
|
if (match != null && match.groupCount >= 1) {
|
||||||
title = match.group(1) ?? '';
|
title = match.group(1) ?? '';
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ class StatsOverview extends HookConsumerWidget {
|
|||||||
_StatCard(
|
_StatCard(
|
||||||
title: t.home.stats.traffic,
|
title: t.home.stats.traffic,
|
||||||
firstStat: (
|
firstStat: (
|
||||||
label: t.home.stats.uplink,
|
label: "↑",
|
||||||
data: stats.uplink.speed(),
|
data: stats.uplink.speed(),
|
||||||
),
|
),
|
||||||
secondStat: (
|
secondStat: (
|
||||||
label: t.home.stats.downlink,
|
label: "↓",
|
||||||
data: stats.downlink.speed(),
|
data: stats.downlink.speed(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -36,11 +36,11 @@ class StatsOverview extends HookConsumerWidget {
|
|||||||
_StatCard(
|
_StatCard(
|
||||||
title: t.home.stats.trafficTotal,
|
title: t.home.stats.trafficTotal,
|
||||||
firstStat: (
|
firstStat: (
|
||||||
label: t.home.stats.uplink,
|
label: "↑",
|
||||||
data: stats.uplinkTotal.size(),
|
data: stats.uplinkTotal.size(),
|
||||||
),
|
),
|
||||||
secondStat: (
|
secondStat: (
|
||||||
label: t.home.stats.downlink,
|
label: "↓",
|
||||||
data: stats.downlinkTotal.size(),
|
data: stats.downlinkTotal.size(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -80,7 +80,7 @@ class _StatCard extends HookConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
firstStat.label,
|
firstStat.label,
|
||||||
style: TextStyle(color: Colors.green),
|
style: const TextStyle(color: Colors.green),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
firstStat.data,
|
firstStat.data,
|
||||||
@@ -93,7 +93,7 @@ class _StatCard extends HookConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
secondStat.label,
|
secondStat.label,
|
||||||
style: TextStyle(color: Colors.red),
|
style: TextStyle(color: theme.colorScheme.error),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
secondStat.data,
|
secondStat.data,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:hiddify/domain/core_service_failure.dart';
|
|||||||
import 'package:hiddify/domain/singbox/singbox.dart';
|
import 'package:hiddify/domain/singbox/singbox.dart';
|
||||||
import 'package:hiddify/features/common/connectivity/connectivity_controller.dart';
|
import 'package:hiddify/features/common/connectivity/connectivity_controller.dart';
|
||||||
import 'package:hiddify/utils/pref_notifier.dart';
|
import 'package:hiddify/utils/pref_notifier.dart';
|
||||||
|
import 'package:hiddify/utils/riverpod_utils.dart';
|
||||||
import 'package:hiddify/utils/utils.dart';
|
import 'package:hiddify/utils/utils.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ final proxiesSortProvider = AlwaysAlivePrefNotifier.provider(
|
|||||||
class ProxiesNotifier extends _$ProxiesNotifier with AppLogger {
|
class ProxiesNotifier extends _$ProxiesNotifier with AppLogger {
|
||||||
@override
|
@override
|
||||||
Stream<List<OutboundGroup>> build() async* {
|
Stream<List<OutboundGroup>> build() async* {
|
||||||
|
ref.disposeDelay(const Duration(seconds: 15));
|
||||||
final serviceRunning = await ref.watch(serviceRunningProvider.future);
|
final serviceRunning = await ref.watch(serviceRunningProvider.future);
|
||||||
if (!serviceRunning) {
|
if (!serviceRunning) {
|
||||||
throw const CoreServiceNotRunning();
|
throw const CoreServiceNotRunning();
|
||||||
|
|||||||
23
lib/utils/riverpod_utils.dart
Normal file
23
lib/utils/riverpod_utils.dart
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
|
||||||
|
extension RefLifeCycle<T> on AutoDisposeRef<T> {
|
||||||
|
void disposeDelay(Duration duration) {
|
||||||
|
final link = keepAlive();
|
||||||
|
Timer? timer;
|
||||||
|
|
||||||
|
onCancel(() {
|
||||||
|
timer?.cancel();
|
||||||
|
timer = Timer(duration, link.close);
|
||||||
|
});
|
||||||
|
|
||||||
|
onDispose(() {
|
||||||
|
timer?.cancel();
|
||||||
|
});
|
||||||
|
|
||||||
|
onResume(() {
|
||||||
|
timer?.cancel();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user