show unread indicator only for members
This commit is contained in:
@@ -56,9 +56,9 @@ class ChannelListPage extends StatelessWidget {
|
|||||||
body: ChannelsBloc(
|
body: ChannelsBloc(
|
||||||
child: ChannelListView(
|
child: ChannelListView(
|
||||||
filter: {
|
filter: {
|
||||||
'members': {
|
// 'members': {
|
||||||
'\$in': [StreamChat.of(context).user.id],
|
// '\$in': [StreamChat.of(context).user.id],
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
sort: [SortOption('last_message_at')],
|
sort: [SortOption('last_message_at')],
|
||||||
pagination: PaginationParams(
|
pagination: PaginationParams(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: example
|
name: example
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
|
|
||||||
version: 1.0.42+44
|
version: 1.0.43+45
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.2.2 <3.0.0"
|
sdk: ">=2.2.2 <3.0.0"
|
||||||
|
|||||||
@@ -70,9 +70,11 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
StreamChatTheme.of(context).channelPreviewTheme.title,
|
StreamChatTheme.of(context).channelPreviewTheme.title,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
UnreadIndicator(
|
if (channel.state.members.contains(
|
||||||
channel: channel,
|
(Member e) => e.userId == channel.client.state.user.id))
|
||||||
),
|
UnreadIndicator(
|
||||||
|
channel: channel,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
subtitle: Row(
|
subtitle: Row(
|
||||||
@@ -92,7 +94,7 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
.isAfter(channel
|
.isAfter(channel
|
||||||
.state.lastMessage.createdAt))
|
.state.lastMessage.createdAt))
|
||||||
.length ==
|
.length ==
|
||||||
channel.memberCount - 1,
|
(channel.memberCount ?? 0) - 1,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,7 +289,9 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
return messageWidget;
|
return messageWidget;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (widget.showScrollToBottom)
|
if (streamChannel.channel.state.members.contains((Member e) =>
|
||||||
|
e.userId == streamChannel.channel.client.state.user.id) &&
|
||||||
|
widget.showScrollToBottom)
|
||||||
StreamBuilder<int>(
|
StreamBuilder<int>(
|
||||||
stream: streamChannel.channel.state.unreadCountStream,
|
stream: streamChannel.channel.state.unreadCountStream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
@@ -374,8 +376,16 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
left: 10,
|
left: 10,
|
||||||
top: -10,
|
top: -10,
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
radius: 20,
|
child: Padding(
|
||||||
child: Text(unreadCount.toString()),
|
padding: const EdgeInsets.all(3.0),
|
||||||
|
child: Text(
|
||||||
|
unreadCount.toString(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -555,13 +565,14 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
|
|
||||||
final channel = StreamChannel.of(context).channel;
|
final channel = StreamChannel.of(context).channel;
|
||||||
final readList = channel.state?.read
|
final readList = channel.state?.read
|
||||||
?.where((element) => element.user.id != userId)
|
?.where((element) => element.user.id != userId)
|
||||||
?.where((read) =>
|
?.where((read) =>
|
||||||
(read.lastRead.isAfter(message.createdAt) ||
|
(read.lastRead.isAfter(message.createdAt) ||
|
||||||
read.lastRead.isAtSameMomentAs(message.createdAt)) &&
|
read.lastRead.isAtSameMomentAs(message.createdAt)) &&
|
||||||
(index == 0 ||
|
(index == 0 ||
|
||||||
read.lastRead.isBefore(messages[index - 1].createdAt)))
|
read.lastRead.isBefore(messages[index - 1].createdAt)))
|
||||||
?.toList();
|
?.toList() ??
|
||||||
|
[];
|
||||||
|
|
||||||
final allRead = readList.length >= (channel.memberCount ?? 0) - 1;
|
final allRead = readList.length >= (channel.memberCount ?? 0) - 1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user