Return result with entries with 0 keys (#3025)

* Return result with entries with 0 keys

* Cleanup
This commit is contained in:
Jaco Greeff
2021-01-06 10:42:53 +01:00
committed by GitHub
parent cec4c69374
commit 99463a3f1d
+12 -10
View File
@@ -518,13 +518,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
return this._retrieveMapKeys(entry, at, arg).pipe(
switchMap((keys) =>
combineLatest(
arrayChunk(keys, PAGE_SIZE).map((keys) => query(keys))
).pipe(
map((valsArr) =>
arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value])
keys.length
? combineLatest(arrayChunk(keys, PAGE_SIZE).map(query)).pipe(
map((valsArr) =>
arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value])
)
)
)
: of([])
)
);
}
@@ -532,11 +532,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
private _retrieveMapEntriesPaged (entry: StorageEntry, opts: PaginationOptions): Observable<[StorageKey, Codec][]> {
return this._retrieveMapKeysPaged(entry, opts).pipe(
switchMap((keys) =>
this._rpcCore.state.queryStorageAt(keys).pipe(
map((valsArr) =>
valsArr.map((value, index): [StorageKey, Codec] => [keys[index], value])
keys.length
? this._rpcCore.state.queryStorageAt(keys).pipe(
map((valsArr) =>
valsArr.map((value, index): [StorageKey, Codec] => [keys[index], value])
)
)
)
: of([])
)
);
}