diff --git a/src/stores/room-list/TagWatcher.ts b/src/stores/room-list/TagWatcher.ts index 6c5fdf80a4..1fb5223e00 100644 --- a/src/stores/room-list/TagWatcher.ts +++ b/src/stores/room-list/TagWatcher.ts @@ -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)) { diff --git a/src/stores/room-list/algorithms/list-ordering/Algorithm.ts b/src/stores/room-list/algorithms/list-ordering/Algorithm.ts index 5cabc1e08c..3921bb6221 100644 --- a/src/stores/room-list/algorithms/list-ordering/Algorithm.ts +++ b/src/stores/room-list/algorithms/list-ordering/Algorithm.ts @@ -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(); - 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. diff --git a/src/utils/arrays.ts b/src/utils/arrays.ts index 7ea11397e6..3a84990b56 100644 --- a/src/utils/arrays.ts +++ b/src/utils/arrays.ts @@ -45,17 +45,3 @@ export function arrayDiff(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(i: Iterable): T[] { - const a: T[] = []; - for (const e of i) { - a.push(e); - } - return a; -}