diff --git a/lib/authentication/ardrive_auth.dart b/lib/authentication/ardrive_auth.dart index bcea3421ad..c583616d4b 100644 --- a/lib/authentication/ardrive_auth.dart +++ b/lib/authentication/ardrive_auth.dart @@ -237,12 +237,16 @@ class ArDriveAuthImpl implements ArDriveAuth { } Future _disconnectFromArConnect() async { - final hasArConnectPermissions = await _arConnectService.checkPermissions(); - if (hasArConnectPermissions) { - try { - await _arConnectService.disconnect(); - } catch (e) { - logger.e('Failed to disconnect from ArConnect', e); + final isExtensionAvailable = _arConnectService.isExtensionPresent(); + if (isExtensionAvailable) { + final hasArConnectPermissions = + await _arConnectService.checkPermissions(); + if (hasArConnectPermissions) { + try { + await _arConnectService.disconnect(); + } catch (e) { + logger.e('Failed to disconnect from ArConnect', e); + } } } } diff --git a/lib/components/profile_card.dart b/lib/components/profile_card.dart index d021b3557c..f0bc9ef928 100644 --- a/lib/components/profile_card.dart +++ b/lib/components/profile_card.dart @@ -367,9 +367,12 @@ class __LogoutButtonState extends State<_LogoutButton> { }, child: InkWell( onTap: () { - context.read().logout().then( + final arDriveAuth = context.read(); + final profileCubit = context.read(); + + arDriveAuth.logout().then( (value) { - context.read().logoutProfile(); + profileCubit.logoutProfile(); PlausibleEventTracker.track(event: PlausibleEvent.logout); }, ); diff --git a/test/authentication/ardrive_auth_test.dart b/test/authentication/ardrive_auth_test.dart index 89b542dfec..dd8b84a1fb 100644 --- a/test/authentication/ardrive_auth_test.dart +++ b/test/authentication/ardrive_auth_test.dart @@ -59,6 +59,9 @@ void main() { when(() => mockArConnectService.checkPermissions()).thenAnswer( (invocation) => Future.value(true), ); + when(() => mockArConnectService.isExtensionPresent()).thenAnswer( + (invocation) => true, + ); when(() => mockArConnectService.disconnect()).thenAnswer( (invocation) => Future.value(null), );