Removing message builder
This commit is contained in:
+30
-36
@@ -211,45 +211,39 @@ class StreamChannelListTile extends StatelessWidget {
|
|||||||
child: subtitle,
|
child: subtitle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BetterStreamBuilder<List<Message>>(
|
BetterStreamBuilder<List<Read>>(
|
||||||
stream: channelState.messagesStream,
|
stream: channelState.readStream,
|
||||||
initialData: channelState.messages,
|
initialData: channelState.read,
|
||||||
comparator: const ListEquality().equals,
|
builder: (context, reads) {
|
||||||
builder: (context, messages) {
|
final lastMessage = channelState.messages.lastWhereOrNull(
|
||||||
return BetterStreamBuilder<List<Read>>(
|
(m) => !m.shadowed && !m.isDeleted,
|
||||||
stream: channelState.readStream,
|
);
|
||||||
initialData: channelState.read,
|
|
||||||
builder: (context, reads) {
|
|
||||||
final lastMessage = messages.lastWhereOrNull(
|
|
||||||
(m) => !m.shadowed && !m.isDeleted,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (lastMessage == null ||
|
if (lastMessage == null ||
|
||||||
(lastMessage.user?.id != currentUser.id)) {
|
(lastMessage.user?.id != currentUser.id)) {
|
||||||
return const Offstage();
|
return const Offstage();
|
||||||
}
|
}
|
||||||
|
|
||||||
final isLastMessageRead = channelState.read
|
final isLastMessageRead = channelState.read
|
||||||
.where(
|
.where(
|
||||||
(readData) => readData.user.id != currentUser.id,
|
(readData) => readData.user.id != currentUser.id,
|
||||||
)
|
)
|
||||||
.any((readData) =>
|
.any((readData) =>
|
||||||
readData.lastRead
|
readData.lastRead.isAfter(lastMessage.createdAt) ||
|
||||||
.isAfter(lastMessage.createdAt) ||
|
readData.lastRead
|
||||||
readData.lastRead
|
.isAtSameMomentAs(lastMessage.createdAt));
|
||||||
.isAtSameMomentAs(lastMessage.createdAt));
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(right: 4),
|
padding: const EdgeInsets.only(right: 4),
|
||||||
child: sendingIndicatorBuilder?.call(
|
child: sendingIndicatorBuilder?.call(
|
||||||
context, lastMessage) ??
|
context,
|
||||||
StreamSendingIndicator(
|
lastMessage,
|
||||||
message: lastMessage,
|
) ??
|
||||||
size: channelPreviewTheme.indicatorIconSize,
|
StreamSendingIndicator(
|
||||||
isMessageRead: isLastMessageRead,
|
message: lastMessage,
|
||||||
),
|
size: channelPreviewTheme.indicatorIconSize,
|
||||||
);
|
isMessageRead: isLastMessageRead,
|
||||||
},
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user