mirror of
https://github.com/hiddify/hiddify-next.git
synced 2026-06-05 21:05:07 +08:00
fixing riverpod issue with adding "agreed" parameter to recurcise method (applyConfigOption) and using this paramter instead of reading provider state in next call
This commit is contained in:
parent
c28b8eb0f1
commit
34c65bc8b3
@ -88,17 +88,17 @@ class ConnectionRepositoryImpl with ExceptionHandler, InfraLogger implements Con
|
||||
applyConfigOption(activeProfile).flatMap((_) => singbox.restart(profilePathResolver.file(activeProfile.id).path, activeProfile.name, disableMemoryLimit).mapLeft(UnexpectedConnectionFailure.new));
|
||||
|
||||
@visibleForTesting
|
||||
TaskEither<ConnectionFailure, Unit> applyConfigOption(ProfileEntity prof) => TaskEither.fromEither(configOptionRepository.fullOptionsOverrided(prof.profileOverride))
|
||||
TaskEither<ConnectionFailure, Unit> applyConfigOption(ProfileEntity prof, {bool? agreed}) => TaskEither.fromEither(configOptionRepository.fullOptionsOverrided(prof.profileOverride))
|
||||
.mapLeft((l) => ConnectionFailure.invalidConfigOption(null, l))
|
||||
.flatMap(
|
||||
(overridedOptions) => TaskEither.tryCatch(() async {
|
||||
final isWarpLicenseAgreed = ref.read(warpLicenseNotifierProvider);
|
||||
final isWarpLicenseAgreed = agreed ?? ref.read(warpLicenseNotifierProvider);
|
||||
final isWarpEnabled = overridedOptions.warp.enable || overridedOptions.warp2.enable;
|
||||
if (!isWarpLicenseAgreed && isWarpEnabled) {
|
||||
if (!isWarpLicenseAgreed! && isWarpEnabled) {
|
||||
final isAgreed = await ref.read(dialogNotifierProvider.notifier).showWarpLicense();
|
||||
if (isAgreed == true) {
|
||||
await ref.read(warpLicenseNotifierProvider.notifier).agree();
|
||||
return (await applyConfigOption(prof).run()).match((l) => throw l, (_) => unit);
|
||||
return (await applyConfigOption(prof, agreed: true).run()).match((l) => throw l, (_) => unit);
|
||||
} else {
|
||||
throw const MissingWarpLicense();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user