Remove iteratorToArray
parent
73a8e77d32
commit
bc2fbefb5c
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
import { RoomListStore2 } from "./RoomListStore2";
|
||||
import TagOrderStore from "../TagOrderStore";
|
||||
import { CommunityFilterCondition } from "./filters/CommunityFilterCondition";
|
||||
import { arrayDiff, arrayHasDiff, iteratorToArray } from "../../utils/arrays";
|
||||
import { arrayDiff, arrayHasDiff } from "../../utils/arrays";
|
||||
|
||||
/**
|
||||
* Watches for changes in tags/groups to manage filters on the provided RoomListStore
|
||||
|
@ -31,7 +31,7 @@ export class TagWatcher {
|
|||
}
|
||||
|
||||
private onTagsUpdated = () => {
|
||||
const lastTags = iteratorToArray(this.filters.keys());
|
||||
const lastTags = Array.from(this.filters.keys());
|
||||
const newTags = TagOrderStore.getSelectedTags();
|
||||
|
||||
if (arrayHasDiff(lastTags, newTags)) {
|
||||
|
|
|
@ -22,7 +22,6 @@ import { ITagMap, ITagSortingMap } from "../models";
|
|||
import DMRoomMap from "../../../../utils/DMRoomMap";
|
||||
import { FILTER_CHANGED, IFilterCondition } from "../../filters/IFilterCondition";
|
||||
import { EventEmitter } from "events";
|
||||
import { iteratorToArray } from "../../../../utils/arrays";
|
||||
|
||||
// TODO: Add locking support to avoid concurrent writes?
|
||||
|
||||
|
@ -102,7 +101,7 @@ export abstract class Algorithm extends EventEmitter {
|
|||
|
||||
console.warn("Recalculating filtered room list");
|
||||
const allowedByFilters = new Set<Room>();
|
||||
const filters = iteratorToArray(this.allowedByFilter.keys());
|
||||
const filters = Array.from(this.allowedByFilter.keys());
|
||||
const newMap: ITagMap = {};
|
||||
for (const tagId of Object.keys(this.cachedRooms)) {
|
||||
// Cheaply clone the rooms so we can more easily do operations on the list.
|
||||
|
|
|
@ -45,17 +45,3 @@ export function arrayDiff<T>(a: T[], b: T[]): { added: T[], removed: T[] } {
|
|||
removed: a.filter(i => !b.includes(i)),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an iterator to an array. Not recommended to be called with infinite
|
||||
* generator types.
|
||||
* @param i The iterator to convert.
|
||||
* @returns The array from the iterator.
|
||||
*/
|
||||
export function iteratorToArray<T>(i: Iterable<T>): T[] {
|
||||
const a: T[] = [];
|
||||
for (const e of i) {
|
||||
a.push(e);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue