mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-10-01 06:55:46 -04:00
fix messages select
This commit is contained in:
parent
2cf1c5f4e9
commit
cd329c7bad
@ -16,7 +16,9 @@ class _MessageQueueEntry {
|
|||||||
IList<proto.Message> remoteMessages;
|
IList<proto.Message> remoteMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MessagesCubit extends Cubit<AsyncValue<IList<proto.Message>>> {
|
typedef MessagesState = AsyncValue<IList<proto.Message>>;
|
||||||
|
|
||||||
|
class MessagesCubit extends Cubit<MessagesState> {
|
||||||
MessagesCubit(
|
MessagesCubit(
|
||||||
{required ActiveAccountInfo activeAccountInfo,
|
{required ActiveAccountInfo activeAccountInfo,
|
||||||
required TypedKey remoteIdentityPublicKey,
|
required TypedKey remoteIdentityPublicKey,
|
||||||
|
@ -19,20 +19,20 @@ import '../chat.dart';
|
|||||||
class ChatComponent extends StatelessWidget {
|
class ChatComponent extends StatelessWidget {
|
||||||
const ChatComponent._(
|
const ChatComponent._(
|
||||||
{required TypedKey localUserIdentityKey,
|
{required TypedKey localUserIdentityKey,
|
||||||
required TypedKey remoteConversationRecordKey,
|
|
||||||
required MessagesCubit messagesCubit,
|
required MessagesCubit messagesCubit,
|
||||||
|
required MessagesState messagesState,
|
||||||
required types.User localUser,
|
required types.User localUser,
|
||||||
required types.User remoteUser,
|
required types.User remoteUser,
|
||||||
super.key})
|
super.key})
|
||||||
: _localUserIdentityKey = localUserIdentityKey,
|
: _localUserIdentityKey = localUserIdentityKey,
|
||||||
_remoteConversationRecordKey = remoteConversationRecordKey,
|
|
||||||
_messagesCubit = messagesCubit,
|
_messagesCubit = messagesCubit,
|
||||||
|
_messagesState = messagesState,
|
||||||
_localUser = localUser,
|
_localUser = localUser,
|
||||||
_remoteUser = remoteUser;
|
_remoteUser = remoteUser;
|
||||||
|
|
||||||
final TypedKey _localUserIdentityKey;
|
final TypedKey _localUserIdentityKey;
|
||||||
final TypedKey _remoteConversationRecordKey;
|
|
||||||
final MessagesCubit _messagesCubit;
|
final MessagesCubit _messagesCubit;
|
||||||
|
final MessagesState _messagesState;
|
||||||
final types.User _localUser;
|
final types.User _localUser;
|
||||||
final types.User _remoteUser;
|
final types.User _remoteUser;
|
||||||
|
|
||||||
@ -78,21 +78,21 @@ class ChatComponent extends StatelessWidget {
|
|||||||
firstName: editedName);
|
firstName: editedName);
|
||||||
|
|
||||||
// Get the messages cubit
|
// Get the messages cubit
|
||||||
final messagesCubit = context
|
final messages = context.select<ActiveConversationMessagesBlocMapCubit,
|
||||||
.select<ActiveConversationMessagesBlocMapCubit, MessagesCubit?>(
|
(MessagesCubit, MessagesState)?>(
|
||||||
(x) => x.tryOperate(remoteConversationRecordKey,
|
(x) => x.tryOperate(remoteConversationRecordKey,
|
||||||
closure: (cubit) => cubit));
|
closure: (cubit) => (cubit, cubit.state)));
|
||||||
|
|
||||||
// Get the messages to display
|
// Get the messages to display
|
||||||
// and ensure it is safe to operate() on the MessageCubit for this chat
|
// and ensure it is safe to operate() on the MessageCubit for this chat
|
||||||
if (messagesCubit == null) {
|
if (messages == null) {
|
||||||
return waitingPage();
|
return waitingPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ChatComponent._(
|
return ChatComponent._(
|
||||||
localUserIdentityKey: localUserIdentityKey,
|
localUserIdentityKey: localUserIdentityKey,
|
||||||
remoteConversationRecordKey: remoteConversationRecordKey,
|
messagesCubit: messages.$1,
|
||||||
messagesCubit: messagesCubit,
|
messagesState: messages.$2,
|
||||||
localUser: localUser,
|
localUser: localUser,
|
||||||
remoteUser: remoteUser,
|
remoteUser: remoteUser,
|
||||||
key: key);
|
key: key);
|
||||||
@ -140,10 +140,9 @@ class ChatComponent extends StatelessWidget {
|
|||||||
final textTheme = Theme.of(context).textTheme;
|
final textTheme = Theme.of(context).textTheme;
|
||||||
final chatTheme = makeChatTheme(scale, textTheme);
|
final chatTheme = makeChatTheme(scale, textTheme);
|
||||||
|
|
||||||
final avmessages = _messagesCubit.state;
|
final messages = _messagesState.data?.value;
|
||||||
final messages = avmessages.data?.value;
|
|
||||||
if (messages == null) {
|
if (messages == null) {
|
||||||
return avmessages.buildNotData();
|
return _messagesState.buildNotData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert protobuf messages to chat messages
|
// Convert protobuf messages to chat messages
|
||||||
|
Loading…
Reference in New Issue
Block a user