feat(web): list the room's people and let the owner remove them
ci / checks (push) Successful in 54s
ci / test (push) Successful in 58s
ci / chart (push) Successful in 5s
ci / web (push) Successful in 21s
ci / docker (push) Successful in 11s
ci / publish-edge-image (push) Successful in 10s
ci / publish-edge-chart (push) Successful in 3s

The invite dialog was reachable only from the invite button, and who was
in the room showed only as avatars in the top bar. Selecting an avatar,
the member count, or the People button now opens one dialog: a
scrollable member list with the invite link below it.

The owner removes a member from the row after a confirmation, and the
top bar drops them without reloading the room. The server already
refuses to remove the owner. Invite link creation is unchanged.
This commit is contained in:
vhaudiquet committed 2026-12-01 10:34:46 +01:00
1 parent 7d98b04d63
commit 880f4e2d87
5 files changed
+289 -94

No files matched your search

+74 -1
View File
@@ -1077,10 +1077,37 @@ button {
gap: var(--sp-1); gap: var(--sp-1);
} }
.presence-avatars .avatar + .avatar { .presence-avatars .avatar-btn + .avatar-btn {
margin-left: calc(var(--sp-1) * -1); margin-left: calc(var(--sp-1) * -1);
} }
.avatar-btn {
display: inline-flex;
padding: 0;
border: 0;
border-radius: var(--r-avatar);
background: transparent;
line-height: 0;
cursor: pointer;
}
.avatar-btn:hover .avatar {
box-shadow: 0 0 0 2px var(--accent-soft);
}
.more-people {
padding: 0 var(--sp-1);
border: 0;
background: transparent;
color: var(--muted);
font-size: var(--fs-small);
line-height: var(--lh-body);
}
.more-people:hover {
color: var(--text);
}
.room-body { .room-body {
flex: 1; flex: 1;
min-height: 0; min-height: 0;
@@ -2306,6 +2333,52 @@ body.files-resizing-y * {
border-top: 1px solid var(--border); border-top: 1px solid var(--border);
} }
.people-section {
margin-bottom: var(--sp-6);
}
.people-list {
display: flex;
flex-direction: column;
max-height: 300px;
overflow-y: auto;
scrollbar-width: thin;
margin: 0;
/* Keep the scrollbar off the buttons at the right edge. */
padding: 0 var(--sp-3) 0 0;
list-style: none;
}
.person-row {
display: flex;
align-items: center;
gap: var(--sp-2);
min-height: 38px;
padding: var(--sp-1) 0;
}
.person-row + .person-row {
border-top: 1px solid var(--border);
}
.person-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: var(--fs-ui);
}
.person-role {
color: var(--faint);
font-size: var(--fs-small);
}
.person-confirm {
flex: 1;
}
.composer-error { .composer-error {
max-width: 760px; max-width: 760px;
margin: var(--sp-1) auto 0; margin: var(--sp-1) auto 0;
-80
View File
@@ -1,80 +0,0 @@
<script setup lang="ts">
import { computed, nextTick, onMounted, ref } from 'vue'
import { Check, Copy } from 'lucide-vue-next'
import type { Invite } from '~/types'
import { apiErrorMessage } from '~/utils/errors'
import { formatDate } from '~/utils/format'
import BaseDialog from '~/components/BaseDialog.vue'
const props = defineProps<{ roomId: string; roomName: string }>()
const emit = defineEmits<{ close: [] }>()
const api = useApi()
const invite = ref<Invite | null>(null)
const loading = ref(true)
const error = ref('')
const copied = ref(false)
const linkInput = ref<HTMLInputElement | null>(null)
const inviteUrl = computed(() => invite.value?.url ?? '')
async function create() {
loading.value = true
error.value = ''
try {
invite.value = await api.post<Invite>(`/rooms/${props.roomId}/invites`)
await nextTick()
linkInput.value?.focus()
linkInput.value?.select()
} catch (err) {
error.value = apiErrorMessage(err)
} finally {
loading.value = false
}
}
async function copy() {
if (!inviteUrl.value) return
try {
await navigator.clipboard.writeText(inviteUrl.value)
copied.value = true
window.setTimeout(() => {
copied.value = false
}, 1800)
} catch {
error.value = 'The clipboard is not available. Select the link and copy it by hand.'
}
}
onMounted(create)
</script>
<template>
<BaseDialog title="Invite people" @close="emit('close')">
<p v-if="loading" class="meta">Creating the link.</p>
<p v-else-if="error && !invite" class="form-error" role="alert">{{ error }}</p>
<div v-if="invite" class="form">
<div class="field">
<label class="field-label" for="invite-url">Invite link</label>
<div class="key-line">
<input id="invite-url" ref="linkInput" class="input mono" :value="inviteUrl" readonly autofocus>
<button type="button" class="btn" aria-label="Copy invite link" title="Copy invite link" @click="copy">
<component :is="copied ? Check : Copy" :size="14" aria-hidden="true" />
{{ copied ? 'Copied' : 'Copy' }}
</button>
</div>
</div>
<p class="form-note">
Anyone with this link can join {{ roomName }}. It works once and expires {{ formatDate(invite.expires_at) }}.
</p>
<p v-if="error" class="form-error" role="alert">{{ error }}</p>
</div>
<div class="dialog-actions">
<button type="button" class="btn" @click="emit('close')">Done</button>
</div>
</BaseDialog>
</template>
+175
View File
@@ -0,0 +1,175 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { Check, Copy, X } from 'lucide-vue-next'
import type { Invite, Member, RoomDetailResponse } from '~/types'
import { apiErrorMessage } from '~/utils/errors'
import { formatDate } from '~/utils/format'
import BaseDialog from '~/components/BaseDialog.vue'
const props = defineProps<{ roomId: string; roomName: string }>()
const emit = defineEmits<{ close: []; removed: [memberId: string] }>()
const api = useApi()
const people = ref<Member[]>([])
const me = ref<RoomDetailResponse['me'] | null>(null)
const peopleLoading = ref(true)
const peopleError = ref('')
const invite = ref<Invite | null>(null)
const inviteLoading = ref(true)
const inviteError = ref('')
const copied = ref(false)
const confirming = ref('')
const removing = ref('')
const removeError = ref('')
const inviteUrl = computed(() => invite.value?.url ?? '')
const isOwner = computed(() => me.value?.role === 'owner')
function avatarUrl(member: Member): string | null {
if (!member.avatar_updated_at) return null
return `/api/avatars/${member.account_id}?v=${member.avatar_updated_at}`
}
async function loadPeople() {
peopleLoading.value = true
peopleError.value = ''
try {
const detail = await api.get<RoomDetailResponse>(`/rooms/${props.roomId}`)
people.value = detail.members
me.value = detail.me
} catch (err) {
peopleError.value = apiErrorMessage(err)
} finally {
peopleLoading.value = false
}
}
async function create() {
inviteLoading.value = true
inviteError.value = ''
try {
invite.value = await api.post<Invite>(`/rooms/${props.roomId}/invites`)
} catch (err) {
inviteError.value = apiErrorMessage(err)
} finally {
inviteLoading.value = false
}
}
async function copy() {
if (!inviteUrl.value) return
try {
await navigator.clipboard.writeText(inviteUrl.value)
copied.value = true
window.setTimeout(() => {
copied.value = false
}, 1800)
} catch {
inviteError.value = 'The clipboard is not available. Select the link and copy it by hand.'
}
}
async function remove(member: Member) {
removing.value = member.id
removeError.value = ''
try {
await api.del(`/rooms/${props.roomId}/members/${member.id}`)
people.value = people.value.filter((person) => person.id !== member.id)
confirming.value = ''
emit('removed', member.id)
} catch (err) {
removeError.value = apiErrorMessage(err)
} finally {
removing.value = ''
}
}
onMounted(() => {
void loadPeople()
void create()
})
</script>
<template>
<BaseDialog title="People" @close="emit('close')">
<div class="people-section">
<p v-if="peopleLoading" class="meta">Loading people.</p>
<p v-else-if="peopleError" class="form-error" role="alert">{{ peopleError }}</p>
<ul v-else class="people-list">
<li v-for="person in people" :key="person.id" class="person-row">
<template v-if="confirming === person.id">
<div class="confirm-line person-confirm">
<span>Remove {{ person.display_name }} from the room?</span>
<button
type="button"
class="btn btn-sm btn-quiet"
:disabled="removing === person.id"
@click="confirming = ''"
>
Cancel
</button>
<button
type="button"
class="btn btn-sm btn-danger"
:disabled="removing === person.id"
@click="remove(person)"
>
{{ removing === person.id ? 'Removing' : 'Remove' }}
</button>
</div>
</template>
<template v-else>
<AppAvatar
:name="person.display_name"
:color="person.color"
:src="avatarUrl(person)"
:offline="!person.online"
size="sm"
/>
<span class="person-name">{{ person.display_name }}</span>
<span v-if="person.role === 'owner'" class="person-role">Owner</span>
<button
v-else-if="isOwner"
type="button"
class="icon-btn"
:aria-label="`Remove ${person.display_name} from the room`"
:title="`Remove ${person.display_name} from the room`"
@click="confirming = person.id"
>
<X :size="14" aria-hidden="true" />
</button>
</template>
</li>
</ul>
<p v-if="removeError" class="form-error" role="alert">{{ removeError }}</p>
</div>
<div class="form invite-section">
<div class="field">
<label class="field-label" for="invite-url">Invite link</label>
<p v-if="inviteLoading" class="meta">Creating the link.</p>
<p v-else-if="inviteError && !invite" class="form-error" role="alert">{{ inviteError }}</p>
<div v-if="invite" class="key-line">
<input id="invite-url" class="input mono" :value="inviteUrl" readonly>
<button type="button" class="btn" aria-label="Copy invite link" title="Copy invite link" @click="copy">
<component :is="copied ? Check : Copy" :size="14" aria-hidden="true" />
{{ copied ? 'Copied' : 'Copy' }}
</button>
</div>
</div>
<p v-if="invite" class="form-note">
Anyone with this link can join {{ roomName }}. It works once and expires {{ formatDate(invite.expires_at) }}.
</p>
<p v-if="inviteError && invite" class="form-error" role="alert">{{ inviteError }}</p>
</div>
<div class="dialog-actions">
<button type="button" class="btn" @click="emit('close')">Done</button>
</div>
</BaseDialog>
</template>
+25 -8
View File
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed } from 'vue'
import { PanelRight, PanelRightClose, Settings, UserPlus } from 'lucide-vue-next' import { PanelRight, PanelRightClose, Settings, Users } from 'lucide-vue-next'
import type { Member } from '~/types' import type { Member } from '~/types'
const props = defineProps<{ const props = defineProps<{
@@ -11,7 +11,7 @@ const props = defineProps<{
paneOpen: boolean paneOpen: boolean
}>() }>()
const emit = defineEmits<{ invite: []; togglePane: []; settings: [] }>() const emit = defineEmits<{ people: []; togglePane: []; settings: [] }>()
const online = computed(() => new Set(props.onlineIds)) const online = computed(() => new Set(props.onlineIds))
@@ -32,26 +32,43 @@ const extraTitle = computed(() => extra.value.map((member) => member.display_nam
<div class="presence"> <div class="presence">
<div class="presence-avatars" aria-label="Room members"> <div class="presence-avatars" aria-label="Room members">
<AppAvatar <button
v-for="member in visible" v-for="member in visible"
:key="member.id" :key="member.id"
type="button"
class="avatar-btn"
:aria-label="`Show people, ${member.display_name}`"
@click="emit('people')"
>
<AppAvatar
:name="member.display_name" :name="member.display_name"
:color="member.color" :color="member.color"
:src="avatarUrl(member)" :src="avatarUrl(member)"
:offline="!online.has(member.id)" :offline="!online.has(member.id)"
size="sm" size="sm"
aria-hidden="true"
/> />
<span v-if="extra.length > 0" class="small muted" :title="extraTitle">+{{ extra.length }}</span> </button>
<button
v-if="extra.length > 0"
type="button"
class="more-people"
:title="extraTitle"
:aria-label="`Show all ${members.length} people`"
@click="emit('people')"
>
+{{ extra.length }}
</button>
</div> </div>
<button <button
type="button" type="button"
class="icon-btn" class="icon-btn"
aria-label="Invite people" aria-label="People"
title="Invite people" title="People"
@click="emit('invite')" @click="emit('people')"
> >
<UserPlus :size="16" aria-hidden="true" /> <Users :size="16" aria-hidden="true" />
</button> </button>
<button <button
+15 -5
View File
@@ -58,7 +58,7 @@ const onlineIds = ref<string[]>([])
const typingActive = ref(false) const typingActive = ref(false)
const paneOpen = ref(typeof window === 'undefined' ? true : !window.matchMedia('(max-width: 1099px)').matches) const paneOpen = ref(typeof window === 'undefined' ? true : !window.matchMedia('(max-width: 1099px)').matches)
const inviteOpen = ref(false) const peopleOpen = ref(false)
const settingsOpen = ref(false) const settingsOpen = ref(false)
const PANE_WIDTH_KEY = 'together.pane-width' const PANE_WIDTH_KEY = 'together.pane-width'
@@ -726,6 +726,15 @@ async function onSettingsUpdated(room: Room) {
await rooms.refresh() await rooms.refresh()
} }
function onMemberRemoved(memberId: string) {
if (!detail.value) return
detail.value = {
...detail.value,
members: detail.value.members.filter((member) => member.id !== memberId),
}
onlineIds.value = onlineIds.value.filter((id) => id !== memberId)
}
async function onArchived() { async function onArchived() {
await rooms.refresh() await rooms.refresh()
await navigateTo('/rooms', { replace: true }) await navigateTo('/rooms', { replace: true })
@@ -797,7 +806,7 @@ onBeforeUnmount(() => {
:online-ids="onlineIds" :online-ids="onlineIds"
:is-owner="isOwner" :is-owner="isOwner"
:pane-open="paneOpen" :pane-open="paneOpen"
@invite="inviteOpen = true" @people="peopleOpen = true"
@settings="settingsOpen = true" @settings="settingsOpen = true"
@toggle-pane="paneOpen = !paneOpen" @toggle-pane="paneOpen = !paneOpen"
/> />
@@ -899,11 +908,12 @@ onBeforeUnmount(() => {
/> />
</div> </div>
<InviteDialog <PeopleDialog
v-if="inviteOpen" v-if="peopleOpen"
:room-id="detail.room.id" :room-id="detail.room.id"
:room-name="detail.room.name" :room-name="detail.room.name"
@close="inviteOpen = false" @close="peopleOpen = false"
@removed="onMemberRemoved"
/> />
<RoomSettingsDialog <RoomSettingsDialog