mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 03:25:52 +01:00
Mark events that are loaded from storage as such
This commit is contained in:
parent
644f1af88c
commit
85ede8a753
@ -19,15 +19,16 @@ import {getPrevContentFromStateEvent, isRedacted} from "../../common";
|
||||
import {getRelationFromContent, getRelatedEventId} from "../relations.js";
|
||||
|
||||
export class EventEntry extends BaseEventEntry {
|
||||
constructor(eventEntry, fragmentIdComparer) {
|
||||
constructor(eventEntry, fragmentIdComparer, isLoadedFromStorage = false) {
|
||||
super(fragmentIdComparer);
|
||||
this._eventEntry = eventEntry;
|
||||
this._decryptionError = null;
|
||||
this._decryptionResult = null;
|
||||
this._isLoadedFromStorage = isLoadedFromStorage;
|
||||
}
|
||||
|
||||
clone() {
|
||||
const clone = new EventEntry(this._eventEntry, this._fragmentIdComparer);
|
||||
const clone = new EventEntry(this._eventEntry, this._fragmentIdComparer, this._isLoadedFromStorage);
|
||||
clone.updateFrom(this);
|
||||
return clone;
|
||||
}
|
||||
@ -89,6 +90,10 @@ export class EventEntry extends BaseEventEntry {
|
||||
return this._eventEntry.event.origin_server_ts;
|
||||
}
|
||||
|
||||
get isLoadedFromStorage() {
|
||||
return this._isLoadedFromStorage;
|
||||
}
|
||||
|
||||
get id() {
|
||||
return this._eventEntry.event.event_id;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ async function readRawTimelineEntriesWithTxn(roomId, eventKey, direction, amount
|
||||
} else {
|
||||
eventsWithinFragment = await timelineStore.eventsBefore(roomId, eventKey, amount);
|
||||
}
|
||||
let eventEntries = eventsWithinFragment.map(e => new EventEntry(e, fragmentIdComparer));
|
||||
let eventEntries = eventsWithinFragment.map(e => new EventEntry(e, fragmentIdComparer, true));
|
||||
entries = directionalConcat(entries, eventEntries, direction);
|
||||
// prepend or append eventsWithinFragment to entries, and wrap them in EventEntry
|
||||
|
||||
@ -140,7 +140,7 @@ export class TimelineReader {
|
||||
const txn = await this._storage.readTxn(stores); // todo: can we just use this.readTxnStores here? probably
|
||||
const storageEntry = await txn.timelineEvents.getByEventId(this._roomId, id);
|
||||
if (storageEntry) {
|
||||
const entry = new EventEntry(storageEntry, this._fragmentIdComparer);
|
||||
const entry = new EventEntry(storageEntry, this._fragmentIdComparer, true);
|
||||
if (this._decryptEntries) {
|
||||
const request = this._decryptEntries([entry], txn, log);
|
||||
await request.complete();
|
||||
|
Loading…
Reference in New Issue
Block a user