Skip to content

New room list: fix public room icon visibility when filter change #29737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/components/viewmodels/avatars/RoomAvatarViewModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type User,
UserEvent,
} from "matrix-js-sdk/src/matrix";
import { useState } from "react";
import { useEffect, useState } from "react";

import { useTypedEventEmitter } from "../../../hooks/useEventEmitter";
import DMRoomMap from "../../../utils/DMRoomMap";
Expand Down Expand Up @@ -82,6 +82,11 @@ function useIsPublic(room: Room): boolean {
setIsPublic(isRoomPublic(_room));
});

// Reset the value when the room changes
useEffect(() => {
setIsPublic(isRoomPublic(room));
}, [room]);

return isPublic;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ describe("RoomAvatarViewModel", () => {
expect(vm.current.hasDecoration).toBe(true);
});

it("should recompute isPublic when room changed", async () => {
const { result: vm, rerender } = renderHook((props) => useRoomAvatarViewModel(props), { initialProps: room });
expect(vm.current.isPublic).toBe(false);

const publicRoom = mkStubRoom("roomId2", "roomName2", matrixClient);
jest.spyOn(publicRoom, "getJoinRule").mockReturnValue(JoinRule.Public);
rerender(publicRoom);

await waitFor(() => expect(vm.current.isPublic).toBe(true));
});

describe("presence", () => {
let user: User;

Expand Down
Loading