mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Support redaction changes in remoteEntries
This commit is contained in:
parent
c690de9f7b
commit
ea89c272b9
@ -209,6 +209,8 @@ export class Timeline {
|
|||||||
|
|
||||||
// used in replaceEntries
|
// used in replaceEntries
|
||||||
static _entryUpdater(existingEntry, entry) {
|
static _entryUpdater(existingEntry, entry) {
|
||||||
|
// ensure dependents point to the new entry instead of existingEntry
|
||||||
|
existingEntry.dependents?.forEach(event => event.setContextEntry(entry));
|
||||||
entry.updateFrom(existingEntry);
|
entry.updateFrom(existingEntry);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
@ -220,6 +222,8 @@ export class Timeline {
|
|||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
try {
|
try {
|
||||||
this._remoteEntries.getAndUpdate(entry, Timeline._entryUpdater);
|
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) {
|
} catch (err) {
|
||||||
if (err.name === "CompareError") {
|
if (err.name === "CompareError") {
|
||||||
// see FragmentIdComparer, if the replacing entry is on a fragment
|
// see FragmentIdComparer, if the replacing entry is on a fragment
|
||||||
@ -251,6 +255,7 @@ export class Timeline {
|
|||||||
let contextEvent;
|
let contextEvent;
|
||||||
// find in remote events
|
// find in remote events
|
||||||
contextEvent = this.getByEventId(id);
|
contextEvent = this.getByEventId(id);
|
||||||
|
contextEvent?.addDependent(entry);
|
||||||
// find in storage
|
// find in storage
|
||||||
if (!contextEvent) {
|
if (!contextEvent) {
|
||||||
contextEvent = await this._fetchEventFromStorage(id);
|
contextEvent = await this._fetchEventFromStorage(id);
|
||||||
|
@ -25,6 +25,7 @@ export class EventEntry extends BaseEventEntry {
|
|||||||
this._decryptionError = null;
|
this._decryptionError = null;
|
||||||
this._decryptionResult = null;
|
this._decryptionResult = null;
|
||||||
this._contextEntry = null;
|
this._contextEntry = null;
|
||||||
|
this._dependents = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
@ -40,12 +41,24 @@ export class EventEntry extends BaseEventEntry {
|
|||||||
if (other._decryptionError && !this._decryptionError) {
|
if (other._decryptionError && !this._decryptionError) {
|
||||||
this._decryptionError = other._decryptionError;
|
this._decryptionError = other._decryptionError;
|
||||||
}
|
}
|
||||||
|
this._dependents = other._dependents;
|
||||||
}
|
}
|
||||||
|
|
||||||
setContextEntry(entry) {
|
setContextEntry(entry) {
|
||||||
this._contextEntry = entry;
|
this._contextEntry = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDependent(entry) {
|
||||||
|
if (!this._dependents) {
|
||||||
|
this._dependents = [];
|
||||||
|
}
|
||||||
|
this._dependents.push(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
get dependents() {
|
||||||
|
return this._dependents;
|
||||||
|
}
|
||||||
|
|
||||||
get event() {
|
get event() {
|
||||||
return this._eventEntry.event;
|
return this._eventEntry.event;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user