Fix huge usage bandwidth and performance issue of pinned message banner. (#37)

* Return only the first 100 pinned messages

* Execute pinned message 10 by 10
This commit is contained in:
Florian Duros 2024-09-13 09:47:22 +02:00 committed by GitHub
parent 5740bdbd38
commit 6b384fe9c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 100 additions and 11 deletions

View file

@ -196,6 +196,21 @@ describe("<PinnedMessagesCard />", () => {
expect(asFragment()).toMatchSnapshot();
});
it("should not show more than 100 messages", async () => {
const events = Array.from({ length: 120 }, (_, i) =>
mkMessage({
event: true,
room: "!room:example.org",
user: "@alice:example.org",
msg: `The message ${i}`,
ts: i,
}),
);
await initPinnedMessagesCard(events, []);
expect(screen.queryAllByRole("listitem")).toHaveLength(100);
});
it("should updates when messages are pinned", async () => {
// Start with nothing pinned
const { addLocalPinEvent, addNonLocalPinEvent } = await initPinnedMessagesCard([], []);