mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 03:25:52 +01:00
implement .size for all observable maps
as SortedMapList uses it, putting undefined in its list initially when missing, creating a crash in the TemplateView that renders it
This commit is contained in:
parent
dc05a163df
commit
b27f6a067f
@ -78,4 +78,8 @@ export class ApplyMap extends BaseObservableMap {
|
||||
[Symbol.iterator]() {
|
||||
return this._source[Symbol.iterator]();
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this._source.size;
|
||||
}
|
||||
}
|
||||
|
@ -41,4 +41,12 @@ export class BaseObservableMap extends BaseObservable {
|
||||
h.onRemove(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
get size() {
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
}
|
||||
|
@ -71,10 +71,11 @@ export class FilteredMap extends BaseObservableMap {
|
||||
}
|
||||
|
||||
onRemove(key, value) {
|
||||
if (this._filter && !this._included.get(key)) {
|
||||
return;
|
||||
const wasIncluded = !this._filter || this._included.get(key);
|
||||
this._included.delete(key);
|
||||
if (wasIncluded) {
|
||||
this.emitRemove(key, value);
|
||||
}
|
||||
this.emitRemove(key, value);
|
||||
}
|
||||
|
||||
onUpdate(key, value, params) {
|
||||
@ -117,6 +118,16 @@ export class FilteredMap extends BaseObservableMap {
|
||||
[Symbol.iterator]() {
|
||||
return new FilterIterator(this._source, this._included);
|
||||
}
|
||||
|
||||
get size() {
|
||||
let count = 0;
|
||||
this._included.forEach(included => {
|
||||
if (included) {
|
||||
count += 1;
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
class FilterIterator {
|
||||
|
Loading…
Reference in New Issue
Block a user