This commit is contained in:
Christien Rioux 2024-07-03 20:59:54 -04:00
parent 8c89ce91cf
commit 9dfb8c3f71
16 changed files with 305 additions and 162 deletions

View file

@ -168,7 +168,15 @@ class AccountRepository {
}
/// Remove an account and wipe the messages for this account from this device
Future<bool> deleteLocalAccount(TypedKey superIdentityRecordKey) async {
Future<bool> deleteLocalAccount(TypedKey superIdentityRecordKey,
OwnedDHTRecordPointer? accountRecord) async {
// Delete the account record locally which causes a deep delete
// of all the contacts, invites, chats, and messages in the dht record
// pool
if (accountRecord != null) {
await DHTRecordPool.instance.deleteRecord(accountRecord.recordKey);
}
await logout(superIdentityRecordKey);
final localAccounts = await _localAccounts.get();
@ -178,8 +186,6 @@ class AccountRepository {
await _localAccounts.set(newLocalAccounts);
_streamController.add(AccountRepositoryChange.localAccounts);
// TO DO: wipe messages
return true;
}
@ -367,6 +373,11 @@ class AccountRepository {
return;
}
if (logoutUser == activeLocalAccount) {
await switchToAccount(
_localAccounts.value.firstOrNull?.superIdentity.recordKey);
}
final logoutUserLogin = fetchUserLogin(logoutUser);
if (logoutUserLogin == null) {
// Already logged out