mirror of
https://github.com/discourse/discourse.git
synced 2024-12-22 20:03:54 +08:00
2d567cee26
Prior to this commit we were loading a large number of thread messages without any pagination. This commit attempts to fix this and also improves the following points: - code sharing between channels and threads: Attempts to reuse/share the code use in channels for threads. To make it possible part of this code has been extracted in dedicated helpers or has been improved to reduce the duplication needed. Examples of extracted helpers: - `stackingContextFix`: the ios hack for rendering bug when momentum scrolling is interrupted - `scrollListToMessage`, `scrollListToTop`, `scrollListToBottom`: a series of helper to correctly scroll to a specific position in the list of messages - better general performance of listing messages: One of the main changes which has been made is to remove the computation of visible message during scroll, it will only happen when needed (update last read for example). This constant recomputation of `message.visible` on intersection observer event while scrolling was consuming a lot of CPU time.
65 lines
1.7 KiB
Ruby
65 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Chat | Select message | thread", type: :system do
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
fab!(:channel_1) { Fabricate(:chat_channel, threading_enabled: true) }
|
|
fab!(:thread_1) { Fabricate(:chat_thread, channel: channel_1) }
|
|
fab!(:original_message) { Fabricate(:chat_message, chat_channel: channel_1) }
|
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
|
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
|
|
|
before do
|
|
chat_system_bootstrap
|
|
channel_1.add(current_user)
|
|
sign_in(current_user)
|
|
end
|
|
|
|
fab!(:thread_message_1) do
|
|
Fabricate(
|
|
:chat_message,
|
|
thread_id: thread_1.id,
|
|
chat_channel: channel_1,
|
|
in_reply_to: original_message,
|
|
)
|
|
end
|
|
fab!(:thread_message_2) do
|
|
Fabricate(
|
|
:chat_message,
|
|
thread_id: thread_1.id,
|
|
chat_channel: channel_1,
|
|
in_reply_to: original_message,
|
|
)
|
|
end
|
|
fab!(:thread_message_3) do
|
|
Fabricate(
|
|
:chat_message,
|
|
thread_id: thread_1.id,
|
|
chat_channel: channel_1,
|
|
in_reply_to: original_message,
|
|
)
|
|
end
|
|
|
|
it "can select multiple messages" do
|
|
chat_page.visit_thread(thread_1)
|
|
|
|
thread_page.messages.select(thread_message_1)
|
|
thread_page.messages.select(thread_message_2)
|
|
|
|
expect(thread_page).to have_selected_messages(thread_message_1, thread_message_2)
|
|
end
|
|
|
|
it "can shift + click to select messages between the first and last" do
|
|
chat_page.visit_thread(thread_1)
|
|
thread_page.messages.select(thread_message_1)
|
|
thread_page.messages.shift_select(thread_message_3)
|
|
|
|
expect(thread_page).to have_selected_messages(
|
|
thread_message_1,
|
|
thread_message_2,
|
|
thread_message_3,
|
|
)
|
|
end
|
|
end
|