Skip to content

Commit

Permalink
Merge pull request #1492 from ardriveapp/PE-5015_leftover
Browse files Browse the repository at this point in the history
PE-5131: ArConnect logout leftover
  • Loading branch information
matibat authored Nov 28, 2023
2 parents 20703df + 4087e48 commit 66c7aaa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
16 changes: 10 additions & 6 deletions lib/authentication/ardrive_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,16 @@ class ArDriveAuthImpl implements ArDriveAuth {
}

Future<void> _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);
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions lib/components/profile_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,12 @@ class __LogoutButtonState extends State<_LogoutButton> {
},
child: InkWell(
onTap: () {
context.read<ArDriveAuth>().logout().then(
final arDriveAuth = context.read<ArDriveAuth>();
final profileCubit = context.read<ProfileCubit>();

arDriveAuth.logout().then(
(value) {
context.read<ProfileCubit>().logoutProfile();
profileCubit.logoutProfile();
PlausibleEventTracker.track(event: PlausibleEvent.logout);
},
);
Expand Down
3 changes: 3 additions & 0 deletions test/authentication/ardrive_auth_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down

0 comments on commit 66c7aaa

Please sign in to comment.