Skip to content

Commit 54ecec5

Browse files
committed
fix a few thing
1 parent 884da3e commit 54ecec5

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/webpage/channel.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ class Channel extends SnowFlake {
5858
set lastreadmessageid(id: string | undefined) {
5959
const cur = this.lastreadmessageidint;
6060
this.lastreadmessageidint = id;
61-
const m = this.messages.get(this.idToPrev.get(cur as string) as string);
61+
const m = this.messages.get(this.idToNext.get(cur as string) as string);
6262
if (m) {
63+
console.log(m);
6364
m.generateMessage();
6465
}
65-
const m2 = this.messages.get(this.idToPrev.get(id as string) as string);
66+
const m2 = this.messages.get(this.idToNext.get(id as string) as string);
6667
if (m2) {
6768
m2.generateMessage();
6869
}
@@ -1268,6 +1269,7 @@ class Channel extends SnowFlake {
12681269
if (next) {
12691270
next.generateMessage();
12701271
}
1272+
this.infinite.toBottom();
12711273
}
12721274
static lastDragDiv = document.createElement("div");
12731275
coatDropDiv(div: HTMLDivElement, container: HTMLElement | false = false) {

src/webpage/infiniteScroller.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class InfiniteScroller {
128128
const nh = elm.target.getBoundingClientRect().height;
129129
const height = heights.get(elm.target);
130130
if (height && nh) {
131-
root.scrollTop -= height - nh;
131+
if (!this.atBottom()) root.scrollTop -= height - nh;
132132
}
133133
heights.set(elm.target, nh);
134134
}
@@ -233,12 +233,15 @@ class InfiniteScroller {
233233
if (this.backElm.get(last) || !this.backElm.has(last)) return false;
234234
return this.scrollBottom < 4;
235235
}
236+
toBottom() {
237+
if (this.div) this.div.scrollTop = this.div.scrollHeight;
238+
}
236239

237240
snapBottom(): () => void {
238241
if (this.div && this.atBottom()) {
239242
const trigger = this.scrollBottom < 4;
240243
return () => {
241-
if (this.div && trigger) this.div.scrollTop = this.div.scrollHeight;
244+
if (this.div && trigger) this.toBottom;
242245
};
243246
} else {
244247
return () => {};

0 commit comments

Comments
 (0)