forked from mystiq/hydrogen-web
findAndUpdate uses predicate, just add callback to update method
This commit is contained in:
parent
6a5d856093
commit
fa37e8fedb
2 changed files with 6 additions and 2 deletions
|
@ -122,7 +122,7 @@ export class Timeline {
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
// this will use the comparator and thus
|
// this will use the comparator and thus
|
||||||
// check for equality using the compare method in BaseEntry
|
// check for equality using the compare method in BaseEntry
|
||||||
this._remoteEntries.findAndUpdate(entry, (previousEntry, entry) => {
|
this._remoteEntries.update(entry, null, previousEntry => {
|
||||||
entry.transferLocalEchoState(previousEntry);
|
entry.transferLocalEchoState(previousEntry);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,13 @@ export class SortedArray extends BaseObservableList {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
update(item, updateParams = null) {
|
update(item, updateParams = null, previousCallback = null) {
|
||||||
const idx = this.indexOf(item);
|
const idx = this.indexOf(item);
|
||||||
if (idx !== -1) {
|
if (idx !== -1) {
|
||||||
|
if (previousCallback) {
|
||||||
|
const oldItem = this._items[idx];
|
||||||
|
previousCallback(oldItem);
|
||||||
|
}
|
||||||
this._items[idx] = item;
|
this._items[idx] = item;
|
||||||
this.emitUpdate(idx, item, updateParams);
|
this.emitUpdate(idx, item, updateParams);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue