deactivateAndDestroyCurrentClient method
Implementation
Future<bool> deactivateAndDestroyCurrentClient(String password) async {
final client = currentClient;
if (client == null) {
return false;
}
final account = client.account();
final userId = client.userId().toString();
// take it out of the loop
if (_index >= 0 && _index < _clients.length) {
_clients.removeAt(_index);
_index = _index > 0 ? _index - 1 : 0;
}
try {
if (!await account.deactivate(password)) {
throw 'Deactivating the account failed';
}
} catch (e) {
// reset the client locally
_clients.add(client);
_index = clients.length - 1;
rethrow;
}
await _persistSessions();
String appDocPath = await appDir();
String appCachePath = await appCacheDir();
return await _api.destroyLocalData(
appDocPath,
appCachePath,
userId,
defaultServerName,
);
}