mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
fix "this" still being used in readRawTimelineEntries ...
This commit is contained in:
parent
086bdafe9a
commit
17f84ab314
@ -57,13 +57,15 @@ export class Room extends EventEmitter {
|
|||||||
|
|
||||||
_readRetryDecryptCandidateEntries(sinceEventKey, txn) {
|
_readRetryDecryptCandidateEntries(sinceEventKey, txn) {
|
||||||
if (sinceEventKey) {
|
if (sinceEventKey) {
|
||||||
return readRawTimelineEntriesWithTxn(sinceEventKey, Direction.Forward, Number.MAX_SAFE_INTEGER, txn);
|
return readRawTimelineEntriesWithTxn(this._roomId, sinceEventKey,
|
||||||
|
Direction.Forward, Number.MAX_SAFE_INTEGER, this._fragmentIdComparer, txn);
|
||||||
} else {
|
} else {
|
||||||
// all messages for room ...
|
// all messages for room ...
|
||||||
// if you haven't decrypted any message in a room yet,
|
// if you haven't decrypted any message in a room yet,
|
||||||
// it's unlikely you will have tons of them.
|
// it's unlikely you will have tons of them.
|
||||||
// so this should be fine as a last resort
|
// so this should be fine as a last resort
|
||||||
return readRawTimelineEntriesWithTxn(this._syncWriter.lastMessageKey, Direction.Backward, Number.MAX_SAFE_INTEGER, txn);
|
return readRawTimelineEntriesWithTxn(this._roomId, this._syncWriter.lastMessageKey,
|
||||||
|
Direction.Backward, Number.MAX_SAFE_INTEGER, this._fragmentIdComparer, txn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class ReaderRequest {
|
|||||||
* Raw because it doesn't do decryption and in the future it should not read relations either.
|
* Raw because it doesn't do decryption and in the future it should not read relations either.
|
||||||
* It is just about reading entries and following fragment links
|
* It is just about reading entries and following fragment links
|
||||||
*/
|
*/
|
||||||
export async function readRawTimelineEntriesWithTxn(eventKey, direction, amount, r, txn) {
|
export async function readRawTimelineEntriesWithTxn(roomId, eventKey, direction, amount, fragmentIdComparer, txn) {
|
||||||
let entries = [];
|
let entries = [];
|
||||||
const timelineStore = txn.timelineEvents;
|
const timelineStore = txn.timelineEvents;
|
||||||
const fragmentStore = txn.timelineFragments;
|
const fragmentStore = txn.timelineFragments;
|
||||||
@ -50,29 +50,29 @@ export async function readRawTimelineEntriesWithTxn(eventKey, direction, amount,
|
|||||||
let eventsWithinFragment;
|
let eventsWithinFragment;
|
||||||
if (direction.isForward) {
|
if (direction.isForward) {
|
||||||
// TODO: should we pass amount - entries.length here?
|
// TODO: should we pass amount - entries.length here?
|
||||||
eventsWithinFragment = await timelineStore.eventsAfter(this._roomId, eventKey, amount);
|
eventsWithinFragment = await timelineStore.eventsAfter(roomId, eventKey, amount);
|
||||||
} else {
|
} else {
|
||||||
eventsWithinFragment = await timelineStore.eventsBefore(this._roomId, eventKey, amount);
|
eventsWithinFragment = await timelineStore.eventsBefore(roomId, eventKey, amount);
|
||||||
}
|
}
|
||||||
let eventEntries = eventsWithinFragment.map(e => new EventEntry(e, this._fragmentIdComparer));
|
let eventEntries = eventsWithinFragment.map(e => new EventEntry(e, fragmentIdComparer));
|
||||||
entries = directionalConcat(entries, eventEntries, direction);
|
entries = directionalConcat(entries, eventEntries, direction);
|
||||||
// prepend or append eventsWithinFragment to entries, and wrap them in EventEntry
|
// prepend or append eventsWithinFragment to entries, and wrap them in EventEntry
|
||||||
|
|
||||||
if (entries.length < amount) {
|
if (entries.length < amount) {
|
||||||
const fragment = await fragmentStore.get(this._roomId, eventKey.fragmentId);
|
const fragment = await fragmentStore.get(roomId, eventKey.fragmentId);
|
||||||
// TODO: why does the first fragment not need to be added? (the next *is* added below)
|
// TODO: why does the first fragment not need to be added? (the next *is* added below)
|
||||||
// it looks like this would be fine when loading in the sync island
|
// it looks like this would be fine when loading in the sync island
|
||||||
// (as the live fragment should be added already) but not for permalinks when we support them
|
// (as the live fragment should be added already) but not for permalinks when we support them
|
||||||
//
|
//
|
||||||
// this._fragmentIdComparer.addFragment(fragment);
|
// fragmentIdComparer.addFragment(fragment);
|
||||||
let fragmentEntry = new FragmentBoundaryEntry(fragment, direction.isBackward, this._fragmentIdComparer);
|
let fragmentEntry = new FragmentBoundaryEntry(fragment, direction.isBackward, fragmentIdComparer);
|
||||||
// append or prepend fragmentEntry, reuse func from GapWriter?
|
// append or prepend fragmentEntry, reuse func from GapWriter?
|
||||||
directionalAppend(entries, fragmentEntry, direction);
|
directionalAppend(entries, fragmentEntry, direction);
|
||||||
// only continue loading if the fragment boundary can't be backfilled
|
// only continue loading if the fragment boundary can't be backfilled
|
||||||
if (!fragmentEntry.token && fragmentEntry.hasLinkedFragment) {
|
if (!fragmentEntry.token && fragmentEntry.hasLinkedFragment) {
|
||||||
const nextFragment = await fragmentStore.get(this._roomId, fragmentEntry.linkedFragmentId);
|
const nextFragment = await fragmentStore.get(roomId, fragmentEntry.linkedFragmentId);
|
||||||
this._fragmentIdComparer.add(nextFragment);
|
fragmentIdComparer.add(nextFragment);
|
||||||
const nextFragmentEntry = new FragmentBoundaryEntry(nextFragment, direction.isForward, this._fragmentIdComparer);
|
const nextFragmentEntry = new FragmentBoundaryEntry(nextFragment, direction.isForward, fragmentIdComparer);
|
||||||
directionalAppend(entries, nextFragmentEntry, direction);
|
directionalAppend(entries, nextFragmentEntry, direction);
|
||||||
eventKey = nextFragmentEntry.asEventKey();
|
eventKey = nextFragmentEntry.asEventKey();
|
||||||
} else {
|
} else {
|
||||||
@ -133,7 +133,7 @@ export class TimelineReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _readFrom(eventKey, direction, amount, r, txn) {
|
async _readFrom(eventKey, direction, amount, r, txn) {
|
||||||
const entries = readRawTimelineEntriesWithTxn(eventKey, direction, amount, r, txn);
|
const entries = await readRawTimelineEntriesWithTxn(this._roomId, eventKey, direction, amount, this._fragmentIdComparer, txn);
|
||||||
if (this._decryptEntries) {
|
if (this._decryptEntries) {
|
||||||
r.decryptRequest = this._decryptEntries(entries, txn);
|
r.decryptRequest = this._decryptEntries(entries, txn);
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user