diff --git a/lib/data/repository/core_facade_impl.dart b/lib/data/repository/core_facade_impl.dart index 3bd9303d..909b2676 100644 --- a/lib/data/repository/core_facade_impl.dart +++ b/lib/data/repository/core_facade_impl.dart @@ -75,7 +75,6 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade { ) { return exceptionHandler( () { - loggy.info("changing config options: ${options.format()}"); return singbox .changeConfigOptions(options) .mapLeft(CoreServiceFailure.invalidConfigOptions) @@ -93,8 +92,13 @@ class CoreFacadeImpl with ExceptionHandler, InfraLogger implements CoreFacade { return exceptionHandler( () { final configPath = filesEditor.configPath(fileName); + final options = configOptions(); + loggy.info( + "config options: ${options.format()}\nMemory Limit: ${!disableMemoryLimit}", + ); + return setup() - .andThen(() => changeConfigOptions(configOptions())) + .andThen(() => changeConfigOptions(options)) .andThen( () => singbox .start(configPath, disableMemoryLimit) diff --git a/lib/features/common/connectivity/connectivity_controller.dart b/lib/features/common/connectivity/connectivity_controller.dart index 936e7aef..d0a17ce9 100644 --- a/lib/features/common/connectivity/connectivity_controller.dart +++ b/lib/features/common/connectivity/connectivity_controller.dart @@ -48,9 +48,10 @@ class ConnectivityController extends _$ConnectivityController with AppLogger { Future reconnect(String? profileId) async { if (state case AsyncData(:final value) when value == const Connected()) { if (profileId == null) { + loggy.info("no active profile, disconnecting"); return _disconnect(); } - loggy.debug("reconnecting, profile: [$profileId]"); + loggy.info("active profile changed, reconnecting"); await _core .restart(profileId, ref.read(disableMemoryLimitProvider)) .mapLeft((err) { diff --git a/lib/features/profiles/notifier/profiles_notifier.dart b/lib/features/profiles/notifier/profiles_notifier.dart index e4425562..684c1bcc 100644 --- a/lib/features/profiles/notifier/profiles_notifier.dart +++ b/lib/features/profiles/notifier/profiles_notifier.dart @@ -53,50 +53,66 @@ class ProfilesNotifier extends _$ProfilesNotifier with AppLogger { final activeProfile = await ref.read(activeProfileProvider.future); final markAsActive = activeProfile == null || ref.read(markNewProfileActiveProvider); + final TaskEither task; if (LinkParser.parse(rawInput) case (final link)?) { loggy.debug("adding profile, url: [${link.url}]"); - return ref + task = ref .read(profilesRepositoryProvider) - .addByUrl(link.url, markAsActive: markAsActive) - .getOrElse((err) { - loggy.warning("failed to add profile", err); - throw err; - }).run(); + .addByUrl(link.url, markAsActive: markAsActive); } else if (LinkParser.protocol(rawInput) case (final parsed)?) { loggy.debug("adding profile, content"); - return ref - .read(profilesRepositoryProvider) - .addByContent( + task = ref.read(profilesRepositoryProvider).addByContent( parsed.content, name: parsed.name, markAsActive: markAsActive, - ) - .getOrElse((err) { - loggy.warning("failed to add profile", err); - throw err; - }).run(); + ); } else { loggy.debug("invalid content"); throw const ProfileInvalidUrlFailure(); } + return task.match( + (err) { + loggy.warning("failed to add profile", err); + throw err; + }, + (_) { + loggy.info( + "successfully added profile, mark as active? [$markAsActive]", + ); + return unit; + }, + ).run(); } Future updateProfile(RemoteProfile profile) async { loggy.debug("updating profile"); - return ref - .read(profilesRepositoryProvider) - .update(profile) - .getOrElse((l) => throw l) - .run(); + return ref.read(profilesRepositoryProvider).update(profile).match( + (err) { + loggy.warning("failed to update profile", err); + throw err; + }, + (_) { + loggy.info( + 'successfully updated profile, was active? [${profile.active}]', + ); + return unit; + }, + ).run(); } Future deleteProfile(Profile profile) async { loggy.debug('deleting profile: ${profile.name}'); - await _profilesRepo.delete(profile.id).mapLeft( + await _profilesRepo.delete(profile.id).match( (err) { loggy.warning('failed to delete profile', err); throw err; }, + (_) { + loggy.info( + 'successfully deleted profile, was active? [${profile.active}]', + ); + return unit; + }, ).run(); } }