mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-09-21 13:04:37 -04:00
more locking work
This commit is contained in:
parent
41bb198d92
commit
5a8b1caf93
12 changed files with 481 additions and 484 deletions
|
@ -83,12 +83,10 @@ class ChatListCubit extends DHTShortArrayCubit<proto.Chat> {
|
|||
Future<void> deleteChat(
|
||||
{required TypedKey remoteConversationRecordKey}) async {
|
||||
final remoteConversationKey = remoteConversationRecordKey.toProto();
|
||||
final accountRecordKey =
|
||||
_activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
||||
// Remove Chat from account's list
|
||||
// if this fails, don't keep retrying, user can try again later
|
||||
await operate((shortArray) async {
|
||||
final deletedItem = await operate((shortArray) async {
|
||||
if (activeChatCubit.state == remoteConversationRecordKey) {
|
||||
activeChatCubit.setActiveChat(null);
|
||||
}
|
||||
|
@ -101,19 +99,21 @@ class ChatListCubit extends DHTShortArrayCubit<proto.Chat> {
|
|||
if (c.remoteConversationRecordKey == remoteConversationKey) {
|
||||
// Found the right chat
|
||||
if (await shortArray.tryRemoveItem(i) != null) {
|
||||
try {
|
||||
await (await DHTShortArray.openOwned(
|
||||
c.reconciledChatRecord.toVeilid(),
|
||||
parent: accountRecordKey))
|
||||
.delete();
|
||||
} on Exception catch (e) {
|
||||
log.debug('error removing reconciled chat record: $e', e);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
if (deletedItem != null) {
|
||||
try {
|
||||
await DHTRecordPool.instance
|
||||
.delete(deletedItem.reconciledChatRecord.toVeilid().recordKey);
|
||||
} on Exception catch (e) {
|
||||
log.debug('error removing reconciled chat record: $e', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final ActiveChatCubit activeChatCubit;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue