discourse/plugins/chat/assets/javascripts/discourse/services/chat-channel-scroll-positions.js
Joffrey JAFFEUX aee7197c43
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.
2024-01-19 22:49:14 +01:00

22 lines
465 B
JavaScript

import { tracked } from "@glimmer/tracking";
import Service from "@ember/service";
import { TrackedMap } from "@ember-compat/tracked-built-ins";
export default class ChatChannelScrollPositions extends Service {
@tracked positions = new TrackedMap();
get(id) {
return this.positions.get(id);
}
set(id, position) {
this.positions.set(id, position);
}
delete(id) {
if (this.positions.has(id)) {
this.positions.delete(id);
}
}
}