Add scrollback #22
1 changed files with 7 additions and 4 deletions
|
@ -33,9 +33,9 @@ function eventSearch(list, event, min = 0, max = NO_MAX) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// recurse (below)
|
// recurse (below)
|
||||||
if (list[mid].data.origin_server_ts > event.data.origin_server_ts) return eventSearch(list, event, min, mid-1)
|
if (list[mid].data.origin_server_ts > event.data.origin_server_ts) return eventSearch(list, event, min, mid - 1)
|
||||||
// recurse (above)
|
// recurse (above)
|
||||||
else return eventSearch(list, event, mid+1, max)
|
else return eventSearch(list, event, mid + 1, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
class Event extends ElemJS {
|
class Event extends ElemJS {
|
||||||
|
@ -213,7 +213,7 @@ class ReactiveTimeline extends ElemJS {
|
||||||
if (!search.success) {
|
if (!search.success) {
|
||||||
if (search.i >= 1) {
|
if (search.i >= 1) {
|
||||||
// add at end
|
// add at end
|
||||||
this.tryAddGroups(event, [search.i-1, search.i])
|
this.tryAddGroups(event, [search.i - 1, search.i])
|
||||||
} else {
|
} else {
|
||||||
// add at start
|
// add at start
|
||||||
this.tryAddGroups(event, [0, -1])
|
this.tryAddGroups(event, [0, -1])
|
||||||
|
@ -373,7 +373,6 @@ class Timeline extends Subscribable {
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadScrollback() {
|
async loadScrollback() {
|
||||||
this.broadcast("beforeScrollbackLoad")
|
|
||||||
debug = true
|
debug = true
|
||||||
if (!this.from) throw new Error("Can't load scrollback, no from token")
|
if (!this.from) throw new Error("Can't load scrollback, no from token")
|
||||||
const url = new URL(`${lsm.get("domain")}/_matrix/client/r0/rooms/${this.id}/messages`)
|
const url = new URL(`${lsm.get("domain")}/_matrix/client/r0/rooms/${this.id}/messages`)
|
||||||
|
@ -385,7 +384,11 @@ class Timeline extends Subscribable {
|
||||||
lazy_load_members: true
|
lazy_load_members: true
|
||||||
}
|
}
|
||||||
url.searchParams.set("filter", JSON.stringify(filter))
|
url.searchParams.set("filter", JSON.stringify(filter))
|
||||||
|
|
||||||
const root = await fetch(url.toString()).then(res => res.json())
|
const root = await fetch(url.toString()).then(res => res.json())
|
||||||
|
|
||||||
|
this.broadcast("beforeScrollbackLoad")
|
||||||
|
|
||||||
this.from = root.end
|
this.from = root.end
|
||||||
//console.log(this.updateEvents, root.chunk)
|
//console.log(this.updateEvents, root.chunk)
|
||||||
if (root.state) this.updateStateEvents(root.state)
|
if (root.state) this.updateStateEvents(root.state)
|
||||||
|
|
Loading…
Reference in a new issue