fix lints
This commit is contained in:
@@ -17,51 +17,49 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:weblibre/features/geckoview/domain/controllers/overlay.dart';
|
||||
import 'package:weblibre/features/tor/domain/services/tor_proxy.dart';
|
||||
import 'package:weblibre/features/tor/presentation/widgets/tor_dialog.dart';
|
||||
import 'package:weblibre/features/tor/presentation/widgets/tor_notification.dart';
|
||||
|
||||
part 'start_tor_proxy.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class StartProxyController extends _$StartProxyController {
|
||||
// ignore: document_ignores is used for dialog
|
||||
// ignore: avoid_build_context_in_providers
|
||||
Future<void> maybeStartProxy(BuildContext context) async {
|
||||
Future<bool> shouldPromptProxyStart() async {
|
||||
final currentStatus = await ref
|
||||
.read(torProxyServiceProvider.notifier)
|
||||
.requestSync();
|
||||
|
||||
if (!currentStatus.isRunning) {
|
||||
if (context.mounted) {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const TorDialog();
|
||||
},
|
||||
);
|
||||
return !currentStatus.isRunning;
|
||||
}
|
||||
|
||||
if (result == true) {
|
||||
final connection = ref
|
||||
.read(torProxyServiceProvider.notifier)
|
||||
.startOrReconfigure(reconfigureIfRunning: false);
|
||||
Future<void> startProxy() async {
|
||||
if (state) return;
|
||||
|
||||
ref
|
||||
.read(overlayControllerProvider.notifier)
|
||||
.show(
|
||||
(context) =>
|
||||
Positioned(top: 0, left: 0, child: TorNotification()),
|
||||
);
|
||||
state = true;
|
||||
|
||||
await connection;
|
||||
}
|
||||
}
|
||||
try {
|
||||
final connection = ref
|
||||
.read(torProxyServiceProvider.notifier)
|
||||
.startOrReconfigure(reconfigureIfRunning: false);
|
||||
|
||||
ref
|
||||
.read(overlayControllerProvider.notifier)
|
||||
.show(
|
||||
(context) =>
|
||||
const Positioned(top: 0, left: 0, child: TorNotification()),
|
||||
);
|
||||
|
||||
await connection;
|
||||
} finally {
|
||||
state = false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void build() {}
|
||||
bool build() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ part of 'start_tor_proxy.dart';
|
||||
final startProxyControllerProvider = StartProxyControllerProvider._();
|
||||
|
||||
final class StartProxyControllerProvider
|
||||
extends $NotifierProvider<StartProxyController, void> {
|
||||
extends $NotifierProvider<StartProxyController, bool> {
|
||||
StartProxyControllerProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
@@ -33,28 +33,28 @@ final class StartProxyControllerProvider
|
||||
StartProxyController create() => StartProxyController();
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(void value) {
|
||||
Override overrideWithValue(bool value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<void>(value),
|
||||
providerOverride: $SyncValueProvider<bool>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$startProxyControllerHash() =>
|
||||
r'13c6ad9611a2f9525689d370a0511274aa9c0f03';
|
||||
r'899b585bf7f220251ac92f11c79537cc07723241';
|
||||
|
||||
abstract class _$StartProxyController extends $Notifier<void> {
|
||||
void build();
|
||||
abstract class _$StartProxyController extends $Notifier<bool> {
|
||||
bool build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final ref = this.ref as $Ref<void, void>;
|
||||
final ref = this.ref as $Ref<bool, bool>;
|
||||
final element =
|
||||
ref.element
|
||||
as $ClassProviderElement<
|
||||
AnyNotifier<void, void>,
|
||||
void,
|
||||
AnyNotifier<bool, bool>,
|
||||
bool,
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user