mirror of
https://github.com/discourse/discourse.git
synced 2026-08-19 01:14:56 -05:00
FIX: Do not count thread messages for channel unreads (#21126)
We currently don't have a nice UI to show unread messages for the thread, and it will take some time to create one. For now, this commit makes it so new messages inside a thread do not count towards a chat channel's unread counts, and new messages sent in a thread do not update a user's `last_read_message_id` for a channel. In addition, this PR refactors the `Chat::ChannelFetcher` to use the `Chat::ChannelUnreadsQuery` query class for consistency, and made said class able to return zeroed-out records for channels the user is not a member of. Finally, a small bug is fixed here where if a user's `last_read_message_id` for a channel was a thread's OM ID, then the thread OM would not show in the main channel stream for them until another reply to the channel was posted.
This commit is contained in:
@@ -59,14 +59,18 @@ describe Chat::ChannelFetcher do
|
||||
|
||||
it "returns the correct count" do
|
||||
unread_counts = described_class.unread_counts([category_channel], user1)
|
||||
expect(unread_counts[category_channel.id]).to eq(2)
|
||||
expect(
|
||||
unread_counts.find { |uc| uc.channel_id == category_channel.id }.unread_count,
|
||||
).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context "with no unread messages" do
|
||||
it "returns the correct count" do
|
||||
unread_counts = described_class.unread_counts([category_channel], user1)
|
||||
expect(unread_counts[category_channel.id]).to eq(0)
|
||||
expect(
|
||||
unread_counts.find { |uc| uc.channel_id == category_channel.id }.unread_count,
|
||||
).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,7 +83,9 @@ describe Chat::ChannelFetcher do
|
||||
|
||||
it "returns the correct count" do
|
||||
unread_counts = described_class.unread_counts([category_channel], user1)
|
||||
expect(unread_counts[category_channel.id]).to eq(0)
|
||||
expect(
|
||||
unread_counts.find { |uc| uc.channel_id == category_channel.id }.unread_count,
|
||||
).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -92,7 +98,9 @@ describe Chat::ChannelFetcher do
|
||||
|
||||
it "returns the correct count" do
|
||||
unread_counts = described_class.unread_counts([category_channel], user1)
|
||||
expect(unread_counts[category_channel.id]).to eq(0)
|
||||
expect(
|
||||
unread_counts.find { |uc| uc.channel_id == category_channel.id }.unread_count,
|
||||
).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user