mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-20 21:28:41 -04:00
more refactor and dhtrecord multiple-open support
This commit is contained in:
parent
c4c7b264aa
commit
e262b0f777
19 changed files with 782 additions and 419 deletions
|
@ -147,7 +147,7 @@ class ContactInvitationListCubit
|
|||
|
||||
Future<void> deleteInvitation(
|
||||
{required bool accepted,
|
||||
required proto.ContactInvitationRecord contactInvitationRecord}) async {
|
||||
required TypedKey contactRequestInboxRecordKey}) async {
|
||||
final pool = DHTRecordPool.instance;
|
||||
final accountRecordKey =
|
||||
_activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
@ -159,26 +159,25 @@ class ContactInvitationListCubit
|
|||
if (item == null) {
|
||||
throw Exception('Failed to get contact invitation record');
|
||||
}
|
||||
if (item.contactRequestInbox.recordKey ==
|
||||
contactInvitationRecord.contactRequestInbox.recordKey) {
|
||||
if (item.contactRequestInbox.recordKey.toVeilid() ==
|
||||
contactRequestInboxRecordKey) {
|
||||
await shortArray.tryRemoveItem(i);
|
||||
break;
|
||||
|
||||
await (await pool.openOwned(item.contactRequestInbox.toVeilid(),
|
||||
parent: accountRecordKey))
|
||||
.scope((contactRequestInbox) async {
|
||||
// Wipe out old invitation so it shows up as invalid
|
||||
await contactRequestInbox.tryWriteBytes(Uint8List(0));
|
||||
await contactRequestInbox.delete();
|
||||
});
|
||||
if (!accepted) {
|
||||
await (await pool.openRead(item.localConversationRecordKey.toVeilid(),
|
||||
parent: accountRecordKey))
|
||||
.delete();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
await (await pool.openOwned(
|
||||
contactInvitationRecord.contactRequestInbox.toVeilid(),
|
||||
parent: accountRecordKey))
|
||||
.scope((contactRequestInbox) async {
|
||||
// Wipe out old invitation so it shows up as invalid
|
||||
await contactRequestInbox.tryWriteBytes(Uint8List(0));
|
||||
await contactRequestInbox.delete();
|
||||
});
|
||||
if (!accepted) {
|
||||
await (await pool.openRead(
|
||||
contactInvitationRecord.localConversationRecordKey.toVeilid(),
|
||||
parent: accountRecordKey))
|
||||
.delete();
|
||||
}
|
||||
}
|
||||
|
||||
Future<ValidContactInvitation?> validateInvitation(
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'cubits.dart';
|
|||
typedef WaitingInvitationsBlocMapState
|
||||
= BlocMapState<TypedKey, AsyncValue<InvitationStatus>>;
|
||||
|
||||
// Map of contactInvitationListRecordKey to WaitingInvitationCubit
|
||||
// Map of contactRequestInboxRecordKey to WaitingInvitationCubit
|
||||
// Wraps a contact invitation cubit to watch for accept/reject
|
||||
// Automatically follows the state of a ContactInvitationListCubit.
|
||||
class WaitingInvitationsBlocMapCubit extends BlocMapCubit<TypedKey,
|
||||
|
@ -20,6 +20,7 @@ class WaitingInvitationsBlocMapCubit extends BlocMapCubit<TypedKey,
|
|||
TypedKey, proto.ContactInvitationRecord> {
|
||||
WaitingInvitationsBlocMapCubit(
|
||||
{required this.activeAccountInfo, required this.account});
|
||||
|
||||
Future<void> addWaitingInvitation(
|
||||
{required proto.ContactInvitationRecord
|
||||
contactInvitationRecord}) async =>
|
||||
|
|
|
@ -53,7 +53,9 @@ class ContactInvitationItemWidget extends StatelessWidget {
|
|||
context.read<ContactInvitationListCubit>();
|
||||
await contactInvitationListCubit.deleteInvitation(
|
||||
accepted: false,
|
||||
contactInvitationRecord: contactInvitationRecord);
|
||||
contactRequestInboxRecordKey: contactInvitationRecord
|
||||
.contactRequestInbox.recordKey
|
||||
.toVeilid());
|
||||
},
|
||||
backgroundColor: scale.tertiaryScale.background,
|
||||
foregroundColor: scale.tertiaryScale.text,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue