FIX: correctly save scroll position in channel (#25345)
Due to an incorrect test the previous service was incorrectly implementing the map, and was most importantly not deleting the state when reaching bottom.
This commit is contained in:
parent
ccb5fa1a5a
commit
aee7197c43
|
@ -497,7 +497,7 @@ export default class ChatChannel extends Component {
|
|||
|
||||
if (state.atBottom) {
|
||||
this.fetchMoreMessages({ direction: FUTURE });
|
||||
this.chatChannelScrollPositions.remove(this.args.channel.id);
|
||||
this.chatChannelScrollPositions.delete(this.args.channel.id);
|
||||
} else {
|
||||
this.chatChannelScrollPositions.set(
|
||||
this.args.channel.id,
|
||||
|
|
|
@ -5,13 +5,17 @@ import { TrackedMap } from "@ember-compat/tracked-built-ins";
|
|||
export default class ChatChannelScrollPositions extends Service {
|
||||
@tracked positions = new TrackedMap();
|
||||
|
||||
add(channelId, position) {
|
||||
this.positions.set(channelId, position);
|
||||
get(id) {
|
||||
return this.positions.get(id);
|
||||
}
|
||||
|
||||
remove(channelId) {
|
||||
if (this.positions.has(channelId)) {
|
||||
this.positions.delete(channelId);
|
||||
set(id, position) {
|
||||
this.positions.set(id, position);
|
||||
}
|
||||
|
||||
delete(id) {
|
||||
if (this.positions.has(id)) {
|
||||
this.positions.delete(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -375,7 +375,13 @@ RSpec.describe "Chat channel", type: :system do
|
|||
sidebar_page.open_channel(channel_2)
|
||||
sidebar_page.open_channel(channel_1)
|
||||
|
||||
expect(channel_page.messages).to have_message(id: channel_1.chat_messages[2].id)
|
||||
expect(channel_page.messages).to have_no_message(id: channel_1.chat_messages[49].id)
|
||||
|
||||
find(".chat-scroll-to-bottom__button.visible").click
|
||||
sidebar_page.open_channel(channel_2)
|
||||
sidebar_page.open_channel(channel_1)
|
||||
|
||||
expect(channel_page.messages).to have_message(id: channel_1.chat_messages[49].id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue