feat(messaging-ui): import a channel's roster from the settings panel
Phase C of channel-roster import. Adds the optional addMembers(threadId, userIds) adapter seam (+ BulkAddResult) and, in ConversationSettings, a '#' mode on the existing Add-people box that lists the channels you belong to — public AND private, since the source list is your own membership-scoped conversation list. Picking a channel STAGES the import (reads its roster, diffs against who is already here) and shows a confirm — 'Add 9 people from #design? (3 already here)' — so an administrative action never fires on a stray click. The result line reports added / already-a-member / failed. Absent addMembers => the affordance is hidden entirely and '#' is just a search string. Bumped to 0.1.8. SDK suite: 15 files / 78 tests green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { MessagingAdapter } from '../adapter';
|
||||
import type {
|
||||
Attachment,
|
||||
BulkAddResult,
|
||||
ChannelSummary,
|
||||
ChannelVisibility,
|
||||
Conversation,
|
||||
@@ -168,6 +169,22 @@ export class MockAdapter implements MessagingAdapter {
|
||||
if (t && !t.participants.includes(userId)) t.participants = [...t.participants, userId];
|
||||
}
|
||||
|
||||
/** Bulk add, mirroring the live door: already-members come back as `skipped`, never re-added. */
|
||||
async addMembers(threadId: string, userIds: string[]): Promise<BulkAddResult> {
|
||||
const t = this.threads.get(threadId);
|
||||
if (!t) return { added: [], skipped: [], failed: [...userIds] };
|
||||
const added: string[] = [];
|
||||
const skipped: string[] = [];
|
||||
for (const id of [...new Set(userIds)]) {
|
||||
if (t.participants.includes(id)) skipped.push(id);
|
||||
else {
|
||||
t.participants = [...t.participants, id];
|
||||
added.push(id);
|
||||
}
|
||||
}
|
||||
return { added, skipped, failed: [] };
|
||||
}
|
||||
|
||||
async removeMember(threadId: string, userId: string): Promise<void> {
|
||||
const t = this.threads.get(threadId);
|
||||
if (t) t.participants = t.participants.filter((p) => p !== userId);
|
||||
|
||||
Reference in New Issue
Block a user