FEATURE: Sort thread list by unread threads first (#22272)

* FEATURE: Sort thread list by unread threads first

This commit changes the thread list to show the threads that
have unread messages at the top of the list sorted by the
last reply date + time, then all other threads sorted by
last reply date + time.

This also fixes some issues by removing the last_reply
relationship on the thread, which did not work for complex
querying scenarios because its order would be discarded.

* FIX: Various fixes for thread list loading

* Use the channel.threadsManager and find the channel first rather
  than use activeChannel in the threads manager, otherwise we may
  be looking at differenct channels.
* Look at threadsManager directly instead of storing result for threads
  list otherwise it can get out of sync because of replace: true in
  other places we are loading threads into the store.
* Fix sorting for thread.last_reply, needed a resort.
This commit is contained in:
Martin Brennan
2023-06-28 13:14:01 +10:00
committed by GitHub
parent 78bc42be2e
commit 1526d1f97d
15 changed files with 243 additions and 84 deletions

View File

@ -20,10 +20,10 @@ describe "Thread tracking state | drawer", type: :system do
end
context "when the user has unread messages for a thread" do
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel, thread: thread) }
fab!(:message_2) do
fab!(:message_1) do
Fabricate(:chat_message, chat_channel: channel, thread: thread, user: current_user)
end
fab!(:message_2) { Fabricate(:chat_message, chat_channel: channel, thread: thread) }
it "shows the count of threads with unread messages on the thread list button" do
visit("/")
@ -53,7 +53,7 @@ describe "Thread tracking state | drawer", type: :system do
end
it "shows unread indicators for the header icon and the list when a new unread arrives" do
message_1.trash!
thread.membership_for(current_user).update!(last_read_message_id: message_2.id)
visit("/")
chat_page.open_from_header
drawer_page.open_channel(channel)