mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-03 03:36:23 -04:00
fix head issue and refactor
This commit is contained in:
parent
c48305cba1
commit
48c9c67ab8
20 changed files with 229 additions and 327 deletions
|
@ -139,8 +139,8 @@ class ContactInvitationListCubit
|
|||
|
||||
// Add ContactInvitationRecord to account's list
|
||||
// if this fails, don't keep retrying, user can try again later
|
||||
await operate((shortArray) async {
|
||||
if (await shortArray.tryAddItem(cinvrec.writeToBuffer()) == false) {
|
||||
await operateWrite((writer) async {
|
||||
if (await writer.tryAddItem(cinvrec.writeToBuffer()) == false) {
|
||||
throw Exception('Failed to add contact invitation record');
|
||||
}
|
||||
});
|
||||
|
@ -158,16 +158,16 @@ class ContactInvitationListCubit
|
|||
_activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||
|
||||
// Remove ContactInvitationRecord from account's list
|
||||
final deletedItem = await operate((shortArray) async {
|
||||
for (var i = 0; i < shortArray.length; i++) {
|
||||
final item = await shortArray.getItemProtobuf(
|
||||
final (deletedItem, success) = await operateWrite((writer) async {
|
||||
for (var i = 0; i < writer.length; i++) {
|
||||
final item = await writer.getItemProtobuf(
|
||||
proto.ContactInvitationRecord.fromBuffer, i);
|
||||
if (item == null) {
|
||||
throw Exception('Failed to get contact invitation record');
|
||||
}
|
||||
if (item.contactRequestInbox.recordKey.toVeilid() ==
|
||||
contactRequestInboxRecordKey) {
|
||||
if (await shortArray.tryRemoveItem(i) != null) {
|
||||
if (await writer.tryRemoveItem(i) != null) {
|
||||
return item;
|
||||
}
|
||||
return null;
|
||||
|
@ -176,7 +176,7 @@ class ContactInvitationListCubit
|
|||
return null;
|
||||
});
|
||||
|
||||
if (deletedItem != null) {
|
||||
if (success && deletedItem != null) {
|
||||
// Delete the contact request inbox
|
||||
final contactRequestInbox = deletedItem.contactRequestInbox.toVeilid();
|
||||
await (await pool.openOwned(contactRequestInbox,
|
||||
|
|
|
@ -14,11 +14,11 @@ class ContactRequestInboxCubit
|
|||
contactInvitationRecord: contactInvitationRecord),
|
||||
decodeState: proto.SignedContactResponse.fromBuffer);
|
||||
|
||||
ContactRequestInboxCubit.value(
|
||||
{required super.record,
|
||||
required this.activeAccountInfo,
|
||||
required this.contactInvitationRecord})
|
||||
: super.value(decodeState: proto.SignedContactResponse.fromBuffer);
|
||||
// ContactRequestInboxCubit.value(
|
||||
// {required super.record,
|
||||
// required this.activeAccountInfo,
|
||||
// required this.contactInvitationRecord})
|
||||
// : super.value(decodeState: proto.SignedContactResponse.fromBuffer);
|
||||
|
||||
static Future<DHTRecord> _open(
|
||||
{required ActiveAccountInfo activeAccountInfo,
|
||||
|
|
|
@ -23,7 +23,7 @@ class WaitingInvitationsBlocMapCubit extends BlocMapCubit<TypedKey,
|
|||
WaitingInvitationsBlocMapCubit(
|
||||
{required this.activeAccountInfo, required this.account});
|
||||
|
||||
Future<void> addWaitingInvitation(
|
||||
Future<void> _addWaitingInvitation(
|
||||
{required proto.ContactInvitationRecord
|
||||
contactInvitationRecord}) async =>
|
||||
add(() => MapEntry(
|
||||
|
@ -54,7 +54,7 @@ class WaitingInvitationsBlocMapCubit extends BlocMapCubit<TypedKey,
|
|||
|
||||
@override
|
||||
Future<void> updateState(TypedKey key, proto.ContactInvitationRecord value) =>
|
||||
addWaitingInvitation(contactInvitationRecord: value);
|
||||
_addWaitingInvitation(contactInvitationRecord: value);
|
||||
|
||||
////
|
||||
final ActiveAccountInfo activeAccountInfo;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue