forked from mystiq/hydrogen-web
remove need for transferLocalEchoState, just add local relations again
This commit is contained in:
parent
13a4a0169c
commit
addddf1f26
4 changed files with 16 additions and 25 deletions
|
@ -133,24 +133,27 @@ export class Timeline {
|
|||
}
|
||||
|
||||
replaceEntries(entries) {
|
||||
this._addLocalRelationsToNewRemoteEntries(entries);
|
||||
for (const entry of entries) {
|
||||
this._remoteEntries.update(entry, null, previousEntry => {
|
||||
entry.transferLocalEchoState(previousEntry);
|
||||
});
|
||||
this._remoteEntries.update(entry);
|
||||
}
|
||||
}
|
||||
|
||||
_addLocalRelationsToNewRemoteEntries(entries) {
|
||||
// find any local relations to this new remote event
|
||||
for (const pee of this._localEntries) {
|
||||
// this will work because we set relatedEventId when removing remote echos
|
||||
if (pee.relatedEventId) {
|
||||
const relationTarget = entries.find(e => e.id === pee.relatedEventId);
|
||||
// no need to emit here as this entry is about to be added
|
||||
relationTarget?.addLocalRelation(pee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @package */
|
||||
addOrReplaceEntries(newEntries) {
|
||||
// find any local relations to this new remote event
|
||||
for (const pee of this._localEntries) {
|
||||
// this will work because we set relatedEventId when removing remote echos
|
||||
if (pee.relatedEventId) {
|
||||
const relationTarget = newEntries.find(e => e.id === pee.relatedEventId);
|
||||
// no need to emit here as this entry is about to be added
|
||||
relationTarget?.addLocalRelation(pee);
|
||||
}
|
||||
}
|
||||
this._addLocalRelationsToNewRemoteEntries(newEntries);
|
||||
this._remoteEntries.setManySorted(newEntries);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,13 +31,6 @@ export class BaseEventEntry extends BaseEntry {
|
|||
return this.isRedacting;
|
||||
}
|
||||
|
||||
// when replacing an entry, local echo state can be transfered here
|
||||
transferLocalEchoState(oldEntry) {
|
||||
if (oldEntry._pendingRedactions) {
|
||||
this._pendingRedactions = oldEntry._pendingRedactions;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
aggregates local relation.
|
||||
@return [string] returns the name of the field that has changed, if any
|
||||
|
|
|
@ -134,7 +134,6 @@ export class FragmentBoundaryEntry extends BaseEntry {
|
|||
return new FragmentBoundaryEntry(neighbour, !this._isFragmentStart, this._fragmentIdComparer);
|
||||
}
|
||||
|
||||
transferLocalEchoState() {}
|
||||
addLocalRelation() {}
|
||||
removeLocalRelation() {}
|
||||
}
|
||||
|
|
|
@ -46,13 +46,9 @@ export class SortedArray extends BaseObservableList {
|
|||
return findAndUpdateInArray(predicate, this._items, this, updater);
|
||||
}
|
||||
|
||||
update(item, updateParams = null, previousCallback = null) {
|
||||
update(item, updateParams = null) {
|
||||
const idx = this.indexOf(item);
|
||||
if (idx !== -1) {
|
||||
if (previousCallback) {
|
||||
const oldItem = this._items[idx];
|
||||
previousCallback(oldItem);
|
||||
}
|
||||
this._items[idx] = item;
|
||||
this.emitUpdate(idx, item, updateParams);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue