forked from mystiq/hydrogen-web
Propagate updates
This commit is contained in:
parent
7ef79c92f5
commit
3fe824dbd1
2 changed files with 26 additions and 5 deletions
|
@ -259,14 +259,30 @@ export class Timeline {
|
||||||
/**
|
/**
|
||||||
* Update entries based on newly received events.
|
* Update entries based on newly received events.
|
||||||
* eg: a newly received redacted event may mark an existing event in contextEntriesNotInTimeline as being redacted
|
* eg: a newly received redacted event may mark an existing event in contextEntriesNotInTimeline as being redacted
|
||||||
|
* This is only for the events that are not in the timeline but had to fetched from elsewhere to render reply previews.
|
||||||
*/
|
*/
|
||||||
_updateFetchedEntries(entries) {
|
_updateFetchedEntries(entries) {
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
const relatedEntry = this._getTrackedEntry(entry.relatedEventId);
|
const relatedEntry = this._contextEntriesNotInTimeline.get(entry.relatedEventId);
|
||||||
// todo: can this be called .addRelation instead?
|
if (!relatedEntry) {
|
||||||
if (relatedEntry?.addLocalRelation(entry)) {
|
continue;
|
||||||
relatedEntry.contextForEntries?.forEach(e => this._updateEntry(e));
|
|
||||||
}
|
}
|
||||||
|
// update dependents with this new entry indicating that this is an update to contextEntry
|
||||||
|
const newEntry = this._createEntryFromRelatedEntries(entry, relatedEntry);
|
||||||
|
if (newEntry) {
|
||||||
|
Timeline._entryUpdater(relatedEntry, newEntry);
|
||||||
|
relatedEntry.contextForEntries?.forEach(e => {
|
||||||
|
this._remoteEntries.findAndUpdate(te => te.id === e.id, () => { return { reply: newEntry }; });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_createEntryFromRelatedEntries(entry, relatedEntry) {
|
||||||
|
if (entry.isRedaction) {
|
||||||
|
const newEntry = relatedEntry.clone();
|
||||||
|
newEntry.setAsRedacted();
|
||||||
|
return newEntry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ export class EventEntry extends BaseEventEntry {
|
||||||
this._decryptionResult = null;
|
this._decryptionResult = null;
|
||||||
this._contextEntry = null;
|
this._contextEntry = null;
|
||||||
this._contextForEntries = null;
|
this._contextForEntries = null;
|
||||||
|
this._markedAsRedacted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
|
@ -55,6 +56,10 @@ export class EventEntry extends BaseEventEntry {
|
||||||
this._contextForEntries.push(entry);
|
this._contextForEntries.push(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setAsRedacted() {
|
||||||
|
this._markedAsRedacted = true;
|
||||||
|
}
|
||||||
|
|
||||||
get contextForEntries() {
|
get contextForEntries() {
|
||||||
return this._contextForEntries;
|
return this._contextForEntries;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +158,7 @@ export class EventEntry extends BaseEventEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
get isRedacted() {
|
get isRedacted() {
|
||||||
return super.isRedacted || isRedacted(this._eventEntry.event);
|
return this._markedAsRedacted || super.isRedacted || isRedacted(this._eventEntry.event);
|
||||||
}
|
}
|
||||||
|
|
||||||
get redactionReason() {
|
get redactionReason() {
|
||||||
|
|
Loading…
Reference in a new issue