Skip to content
Draft
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
13 changes: 11 additions & 2 deletions desktop/src/features/channels/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,20 @@ export function useAddChannelMembersMutation(channelId: string | null) {
});
}
},
onSettled: async (_data, _err, variables) => {
onSettled: async (data, _err, variables) => {
// Invalidate the effective channel (the one actually mutated) not the
// live hook-closure channel, which may have changed mid-send.
const effectiveChannelId = variables?.channelId ?? channelId;
await invalidateChannelState(queryClient, effectiveChannelId);
await Promise.all([
invalidateChannelState(queryClient, effectiveChannelId),
...(variables?.role === "bot" && data?.added.length
? [
queryClient.invalidateQueries({
queryKey: ["relay-agents"],
}),
]
: []),
]);
},
});
}
Expand Down
8 changes: 8 additions & 0 deletions desktop/src/testing/e2eBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7399,6 +7399,14 @@ async function handleAddChannelMembers(
joined_at: new Date().toISOString(),
display_name: mockDisplayNames.get(pubkey) ?? null,
});

const relayAgent = mockRelayAgents.find(
(agent) => normalizePubkey(agent.pubkey) === normalizePubkey(pubkey),
);
if (relayAgent && !relayAgent.channel_ids.includes(targetChannel.id)) {
relayAgent.channel_ids.push(targetChannel.id);
relayAgent.channels.push(targetChannel.name);
}
}

syncMockChannel(targetChannel);
Expand Down
16 changes: 16 additions & 0 deletions desktop/tests/e2e/channels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3894,6 +3894,22 @@ test("members sidebar can invite relay-authorized agents", async ({ page }) => {
await expect(
page.getByTestId(`channel-user-search-result-${DM_RELAY_AGENT_PUBKEY}`),
).toBeVisible();

await page
.getByTestId(`channel-user-search-result-${DM_RELAY_AGENT_PUBKEY}`)
.click();
await expect
.poll(async () =>
commandCount(await readCommandLog(page), "add_channel_members"),
)
.toBeGreaterThan(0);

await page.keyboard.press("Escape");
const input = page.getByTestId("message-input");
await input.fill("@quinn");
await expect(
page.getByTestId("mention-autocomplete").getByText("quinn"),
).toBeVisible();
});

test("members sidebar hides relay agents that are not authorized", async ({
Expand Down