mirror of
https://github.com/vector-im/element-web.git
synced 2026-03-05 05:21:15 +01:00
* perf(room list): clear room list item vm only when changing space Clearing all the item vms at every room list change is causing massive re-render of all the room list items. References to the vms are already removed when out of view (see RoomListViewMode.updateVisibleRooms) and handled by GC. * perf(room list): avoid to re-render filters at every room list update RoomListView re-renders on update but the filters (children) don't need to. Add a memo to avoid excessive-rerenders. * chore: add `keepIfSame` to do diff on vm objects * perf(room list): avoid to create new filter ids and keys when the room list is updated The filterKeys are passed in the virtuoso context so it should reduce internal computing The filter ids array has always the same value, there is no point to create a new instance. * test(room list): remove no longer relevant test * test(room list): add new test to ensure that room list item vms are preserved
23 lines
751 B
TypeScript
23 lines
751 B
TypeScript
/*
|
|
* Copyright 2026 Element Creations Ltd.
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
* Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { keepIfSame } from "../../../src/utils/keepIfSame";
|
|
|
|
describe("keepIfSame", () => {
|
|
it("returns the next value if the current and next values are not deeply equal", () => {
|
|
const current = { a: 1 };
|
|
const next = { a: 2 };
|
|
expect(keepIfSame(current, next)).toBe(next);
|
|
});
|
|
|
|
it("returns the current value if the current and next values are deeply equal", () => {
|
|
const current = { a: 1 };
|
|
const next = { a: 1 };
|
|
expect(keepIfSame(current, next)).toBe(current);
|
|
});
|
|
});
|