Merge branch 'main' of https://github.com/amirsaam/hiddify-next
This commit is contained in:
@@ -154,6 +154,21 @@ public class MethodHandler: NSObject, FlutterPlugin {
|
||||
return
|
||||
}
|
||||
result(true)
|
||||
case "generate_config":
|
||||
guard
|
||||
let args = call.arguments as? [String:Any?],
|
||||
let path = args["path"] as? String
|
||||
else {
|
||||
result(FlutterError(code: "INVALID_ARGS", message: nil, details: nil))
|
||||
return
|
||||
}
|
||||
var error: NSError?
|
||||
let config = MobileBuildConfig(path, VPNConfig.shared.configOptions, &error)
|
||||
if let error {
|
||||
result(FlutterError(code: "BUILD_CONFIG", message: error.localizedDescription, details: nil))
|
||||
return
|
||||
}
|
||||
result(config)
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
abstract interface class ConnectionRepository {
|
||||
TaskEither<ConnectionFailure, Unit> setup();
|
||||
Stream<ConnectionStatus> watchConnectionStatus();
|
||||
TaskEither<ConnectionFailure, Unit> connect(
|
||||
String fileName,
|
||||
@@ -120,7 +121,7 @@ class ConnectionRepositoryImpl
|
||||
);
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
@override
|
||||
TaskEither<ConnectionFailure, Unit> setup() {
|
||||
if (_initialized) return TaskEither.of(unit);
|
||||
return exceptionHandler(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:hiddify/core/preferences/general_preferences.dart';
|
||||
import 'package:hiddify/core/preferences/service_preferences.dart';
|
||||
import 'package:hiddify/features/connection/data/connection_data_providers.dart';
|
||||
@@ -14,7 +16,13 @@ part 'connection_notifier.g.dart';
|
||||
@Riverpod(keepAlive: true)
|
||||
class ConnectionNotifier extends _$ConnectionNotifier with AppLogger {
|
||||
@override
|
||||
Stream<ConnectionStatus> build() {
|
||||
Stream<ConnectionStatus> build() async* {
|
||||
if (Platform.isIOS) {
|
||||
await _connectionRepo.setup().mapLeft((l) {
|
||||
loggy.error("error setting up connection repository", l);
|
||||
}).run();
|
||||
}
|
||||
|
||||
ref.listen(
|
||||
activeProfileProvider.select((value) => value.asData?.value),
|
||||
(previous, next) async {
|
||||
@@ -25,7 +33,7 @@ class ConnectionNotifier extends _$ConnectionNotifier with AppLogger {
|
||||
}
|
||||
},
|
||||
);
|
||||
return _connectionRepo.watchConnectionStatus().doOnData((event) {
|
||||
yield* _connectionRepo.watchConnectionStatus().doOnData((event) {
|
||||
if (event case Disconnected(connectionFailure: final _?)
|
||||
when PlatformUtils.isDesktop) {
|
||||
ref.read(startedByUserProvider.notifier).update(false);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
@@ -37,8 +38,18 @@ class PlatformSingboxService with InfraLogger implements SingboxService {
|
||||
TaskEither<String, Unit> setup(
|
||||
Directories directories,
|
||||
bool debug,
|
||||
) =>
|
||||
TaskEither.of(unit);
|
||||
) {
|
||||
return TaskEither(
|
||||
() async {
|
||||
if (!Platform.isIOS) {
|
||||
return right(unit);
|
||||
}
|
||||
|
||||
await _methodChannel.invokeMethod("setup");
|
||||
return right(unit);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
TaskEither<String, Unit> validateConfigByPath(
|
||||
|
||||
Reference in New Issue
Block a user