fix(desktop): hide member invites from non-members

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-authored-by: Jitter <2b2e6415e748c35180847a37aadae06a11e30dddc76b784e7fd9354c4eb42e7a@buzz.block.builderlab.xyz>
This commit is contained in:
Matt Toohey
2026-08-26 12:58:54 +10:00
parent 1c9ac0022c
commit 305eca541b
2 changed files with 23 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
import * as React from "react";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { UserRoundPlus, X } from "lucide-react";
import { Search, UserRoundPlus, X } from "lucide-react";
import {
invalidateChannelState,
useAddChannelMembersMutation,
@@ -238,11 +238,14 @@ export function MembersSidebar({
() => new Set(rawMembers.map((member) => normalizePubkey(member.pubkey))),
[rawMembers],
);
const canAddMembers = canAddChannelMembers({
channelType: channel?.channelType,
visibility: channel?.visibility,
selfRole: selfMember?.role,
});
const canAddMembers =
channel?.isMember === true &&
canAddChannelMembers({
channelType: channel?.channelType,
visibility: channel?.visibility,
selfRole: selfMember?.role,
});
const MemberSearchIcon = canAddMembers ? UserRoundPlus : Search;
// Distinguish "you can't add here" from "nothing to add" so a non-member
// viewing a private channel gets the reason instead of a silently missing affordance.
const showPrivateAddDeniedNotice =
@@ -715,7 +718,7 @@ export function MembersSidebar({
className={MODAL_SEARCH_SHELL_CLASS}
htmlFor="channel-management-search-users"
>
<UserRoundPlus className="h-4 w-4 shrink-0 text-muted-foreground/55 transition-colors duration-150 ease-out group-hover/search:text-muted-foreground group-focus-within/search:text-foreground" />
<MemberSearchIcon className="h-4 w-4 shrink-0 text-muted-foreground/55 transition-colors duration-150 ease-out group-hover/search:text-muted-foreground group-focus-within/search:text-foreground" />
<input
autoCapitalize="none"
autoCorrect="off"

View File

@@ -488,6 +488,19 @@ test("non-member open channel header shows its member count and roster", async (
"sidebar-member-bb22a5299220cad76ffd46190ccbeede8ab5dc260faa28b6e5a2cb31b9aff260",
),
).toBeVisible();
const memberSearch = members.getByTestId("channel-management-search-users");
await expect(memberSearch).toHaveAttribute(
"placeholder",
"Search people and agents",
);
await memberSearch.fill("char");
await expect(
members.getByText("Not in this channel", { exact: true }),
).toHaveCount(0);
await expect(
members.locator('[data-testid^="channel-user-search-result-"]'),
).toHaveCount(0);
});
test("joining a channel from browser adds it to the sidebar", async ({