checkpoint

This commit is contained in:
Christien Rioux 2024-06-20 19:04:39 -04:00
parent 3f8b4d2a41
commit 17211f3515
22 changed files with 701 additions and 353 deletions

View file

@ -38,9 +38,23 @@ class PerAccountCollectionBlocMapCubit extends BlocMapCubit<TypedKey,
Future<void> removeFromState(TypedKey key) => remove(key);
@override
Future<void> updateState(TypedKey key, LocalAccount value) async {
Future<void> updateState(
TypedKey key, LocalAccount? oldValue, LocalAccount newValue) async {
// Don't replace unless this is a totally different account
// The sub-cubit's subscription will update our state later
if (oldValue != null) {
if (oldValue.superIdentity.recordKey !=
newValue.superIdentity.recordKey) {
throw StateError(
'should remove LocalAccount and make a new one, not change it, if '
'the superidentity record key has changed');
}
// This never changes anything that should result in rebuildin the
// sub-cubit
return;
}
await _addPerAccountCollectionCubit(
superIdentityRecordKey: value.superIdentity.recordKey);
superIdentityRecordKey: newValue.superIdentity.recordKey);
}
////////////////////////////////////////////////////////////////////////////

View file

@ -136,15 +136,17 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
: (accountInfo, contactListRecordPointer));
// WaitingInvitationsBlocMapCubit
final waitingInvitationsBlocMapCubit =
waitingInvitationsBlocMapCubitUpdater.update(
accountInfo.userLogin == null || contactInvitationListCubit == null
? null
: (
accountInfo,
accountRecordCubit!,
contactInvitationListCubit
));
final waitingInvitationsBlocMapCubit = waitingInvitationsBlocMapCubitUpdater
.update(accountInfo.userLogin == null ||
contactInvitationListCubit == null ||
contactListCubit == null
? null
: (
accountInfo,
accountRecordCubit!,
contactInvitationListCubit,
contactListCubit,
));
// ActiveChatCubit
final activeChatCubit = activeChatCubitUpdater
@ -179,15 +181,11 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
final activeSingleContactChatBlocMapCubit =
activeSingleContactChatBlocMapCubitUpdater.update(
accountInfo.userLogin == null ||
activeConversationsBlocMapCubit == null ||
chatListCubit == null ||
contactListCubit == null
activeConversationsBlocMapCubit == null
? null
: (
accountInfo,
activeConversationsBlocMapCubit,
chatListCubit,
contactListCubit
));
// Update available blocs in our state
@ -260,11 +258,18 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
));
final waitingInvitationsBlocMapCubitUpdater = BlocUpdater<
WaitingInvitationsBlocMapCubit,
(AccountInfo, AccountRecordCubit, ContactInvitationListCubit)>(
(
AccountInfo,
AccountRecordCubit,
ContactInvitationListCubit,
ContactListCubit
)>(
create: (params) => WaitingInvitationsBlocMapCubit(
accountInfo: params.$1,
accountRecordCubit: params.$2,
contactInvitationListCubit: params.$3));
accountInfo: params.$1,
accountRecordCubit: params.$2,
contactInvitationListCubit: params.$3,
contactListCubit: params.$4,
));
final activeChatCubitUpdater =
BlocUpdater<ActiveChatCubit, bool>(create: (_) => ActiveChatCubit(null));
final chatListCubitUpdater = BlocUpdater<ChatListCubit,
@ -286,13 +291,9 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
(
AccountInfo,
ActiveConversationsBlocMapCubit,
ChatListCubit,
ContactListCubit
)>(
create: (params) => ActiveSingleContactChatBlocMapCubit(
accountInfo: params.$1,
activeConversationsBlocMapCubit: params.$2,
chatListCubit: params.$3,
contactListCubit: params.$4,
));
}

View file

@ -116,7 +116,14 @@ class _EditAccountPageState extends State<EditAccountPage> {
});
try {
// Look up account cubit for this specific account
final accountRecordCubit = context.read<AccountRecordCubit>();
final perAccountCollectionBlocMapCubit =
context.read<PerAccountCollectionBlocMapCubit>();
final accountRecordCubit = await perAccountCollectionBlocMapCubit
.operate(widget.superIdentityRecordKey,
closure: (c) async => c.accountRecordCubit);
if (accountRecordCubit == null) {
return;
}
// Update account profile DHT record
// This triggers ConversationCubits to update