forked from mystiq/hydrogen-web
Support redaction changes in remoteEntries
This commit is contained in:
parent
c690de9f7b
commit
ea89c272b9
2 changed files with 18 additions and 0 deletions
|
@ -209,6 +209,8 @@ export class Timeline {
|
|||
|
||||
// used in replaceEntries
|
||||
static _entryUpdater(existingEntry, entry) {
|
||||
// ensure dependents point to the new entry instead of existingEntry
|
||||
existingEntry.dependents?.forEach(event => event.setContextEntry(entry));
|
||||
entry.updateFrom(existingEntry);
|
||||
return entry;
|
||||
}
|
||||
|
@ -220,6 +222,8 @@ export class Timeline {
|
|||
for (const entry of entries) {
|
||||
try {
|
||||
this._remoteEntries.getAndUpdate(entry, Timeline._entryUpdater);
|
||||
// Since this entry changed, all dependent entries should be updated
|
||||
entry.dependents?.forEach(e => this._findAndUpdateRelatedEntry(null, e.id, () => true));
|
||||
} catch (err) {
|
||||
if (err.name === "CompareError") {
|
||||
// see FragmentIdComparer, if the replacing entry is on a fragment
|
||||
|
@ -251,6 +255,7 @@ export class Timeline {
|
|||
let contextEvent;
|
||||
// find in remote events
|
||||
contextEvent = this.getByEventId(id);
|
||||
contextEvent?.addDependent(entry);
|
||||
// find in storage
|
||||
if (!contextEvent) {
|
||||
contextEvent = await this._fetchEventFromStorage(id);
|
||||
|
|
|
@ -25,6 +25,7 @@ export class EventEntry extends BaseEventEntry {
|
|||
this._decryptionError = null;
|
||||
this._decryptionResult = null;
|
||||
this._contextEntry = null;
|
||||
this._dependents = null;
|
||||
}
|
||||
|
||||
clone() {
|
||||
|
@ -40,12 +41,24 @@ export class EventEntry extends BaseEventEntry {
|
|||
if (other._decryptionError && !this._decryptionError) {
|
||||
this._decryptionError = other._decryptionError;
|
||||
}
|
||||
this._dependents = other._dependents;
|
||||
}
|
||||
|
||||
setContextEntry(entry) {
|
||||
this._contextEntry = entry;
|
||||
}
|
||||
|
||||
addDependent(entry) {
|
||||
if (!this._dependents) {
|
||||
this._dependents = [];
|
||||
}
|
||||
this._dependents.push(entry);
|
||||
}
|
||||
|
||||
get dependents() {
|
||||
return this._dependents;
|
||||
}
|
||||
|
||||
get event() {
|
||||
return this._eventEntry.event;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue