FIX: new message brings a direct message channel to the top (#19332)
Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
parent
1d42cc94a2
commit
cc769ac916
|
@ -750,9 +750,13 @@ export default class Chat extends Service {
|
||||||
this.userChatChannelTrackingStateChanged();
|
this.userChatChannelTrackingStateChanged();
|
||||||
channel.set("last_message_sent_at", new Date());
|
channel.set("last_message_sent_at", new Date());
|
||||||
|
|
||||||
(this.directMessageChannels || [])
|
const directMessageChannel = (this.directMessageChannels || []).findBy(
|
||||||
.findBy("id", parseInt(channel.id, 10))
|
"id",
|
||||||
?.reSortDirectMessageChannels?.();
|
parseInt(channel.id, 10)
|
||||||
|
);
|
||||||
|
if (directMessageChannel) {
|
||||||
|
this.reSortDirectMessageChannels();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
channel.message_bus_last_ids.new_messages
|
channel.message_bus_last_ids.new_messages
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe "Receiving message", type: :system, js: true do
|
||||||
|
fab!(:current_user) { Fabricate(:admin) }
|
||||||
|
fab!(:user_2) { Fabricate(:user) }
|
||||||
|
fab!(:user_3) { Fabricate(:user) }
|
||||||
|
fab!(:direct_message_channel_1) do
|
||||||
|
Fabricate(:direct_message_channel, users: [current_user, user_2])
|
||||||
|
end
|
||||||
|
fab!(:direct_message_channel_2) do
|
||||||
|
Fabricate(:direct_message_channel, users: [current_user, user_2, user_3])
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
||||||
|
|
||||||
|
before do
|
||||||
|
chat_system_bootstrap(current_user, [direct_message_channel_1, direct_message_channel_2])
|
||||||
|
sign_in(current_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when core sidebar is enabled" do
|
||||||
|
before do
|
||||||
|
SiteSetting.enable_sidebar = true
|
||||||
|
SiteSetting.enable_experimental_sidebar_hamburger = true
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when receiving a direct message" do
|
||||||
|
it "reorders the direct messages sidebar section links ordering by last message received" do
|
||||||
|
visit("/")
|
||||||
|
|
||||||
|
expect(
|
||||||
|
page.find(
|
||||||
|
"#sidebar-section-content-chat-dms .sidebar-section-link-wrapper:nth-child(2) .sidebar-row",
|
||||||
|
),
|
||||||
|
).to have_content(direct_message_channel_2.name)
|
||||||
|
|
||||||
|
creator =
|
||||||
|
Chat::ChatMessageCreator.create(
|
||||||
|
chat_channel: direct_message_channel_2,
|
||||||
|
user: user_2,
|
||||||
|
content: "this is good",
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
page.find(
|
||||||
|
"#sidebar-section-content-chat-dms .sidebar-section-link-wrapper:nth-child(1) .sidebar-row",
|
||||||
|
),
|
||||||
|
).to have_content(direct_message_channel_2.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue