- threads: reply counts, ChatThreadPane with replies, live replies and thread mute - channel pins in ChatPinsPanel; a refused pin hides the action for the session - reactions, attachments with upload progress and bearer downloads, inline edits, the delete dialog (moderators also in channels) - link cards with the registerEmbedRenderer registry; linkify for escaped text - slash commands: the command picker over chatbots, dispatch with sender-only answers - slots conversation-actions (DMs only) and sidebar-footer - chat-tokens.css and chat-base.css, EN and PL copy, README
50 lines
2.0 KiB
Vue
50 lines
2.0 KiB
Vue
<script setup lang="ts">
|
|
// The full chat: a sidebar with the channels and the DMs, and the open
|
|
// conversation. On a narrow screen one of them shows at a time. Render it
|
|
// inside <ClientOnly> (it uses window and the DOM); it starts the chat
|
|
// store itself.
|
|
//
|
|
// Slots: sidebar-footer (below the channel list) and conversation-actions
|
|
// ({ conversation }, in the header of an open DM only).
|
|
const { t, locale, localeProperties } = useI18n()
|
|
const chat = useChat()
|
|
const picker = ref<{ open: () => void } | null>(null)
|
|
const panel = ref<{ focus: () => void } | null>(null)
|
|
|
|
const formatLocale = computed(() => (localeProperties.value as { language?: string } | undefined)?.language || locale.value)
|
|
|
|
onMounted(() => {
|
|
void chat.start(formatLocale.value)
|
|
})
|
|
|
|
const open = computed(() => chat.activeId !== null)
|
|
|
|
function opened() {
|
|
panel.value?.focus()
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="chat-page" :class="{ 'is-open': open, 'has-thread': !!chat.thread }">
|
|
<p v-if="chat.bootstrapState === 'error' && chat.member === undefined" class="chat-error" role="alert">
|
|
{{ t('chat.error.bootstrap') }}
|
|
<button class="chat-link-btn" type="button" @click="chat.start(formatLocale)">{{ t('chat.retry') }}</button>
|
|
</p>
|
|
<p v-else-if="chat.member === false" class="chat-muted">{{ t('chat.notMember') }}</p>
|
|
<template v-else>
|
|
<aside class="chat-sidebar">
|
|
<ChatChannelList @opened="opened">
|
|
<template #sidebar-footer><slot name="sidebar-footer" /></template>
|
|
</ChatChannelList>
|
|
<ChatDmList @compose="picker?.open()" @opened="opened" />
|
|
</aside>
|
|
<ChatPanel ref="panel" class="chat-main" @back="chat.close()">
|
|
<template #conversation-actions="slotProps"><slot name="conversation-actions" v-bind="slotProps" /></template>
|
|
</ChatPanel>
|
|
<ChatThreadPane v-if="chat.thread" :key="chat.thread.rootId" class="chat-side" />
|
|
<ChatMemberPicker ref="picker" @started="opened" />
|
|
</template>
|
|
<ChatNotices />
|
|
</div>
|
|
</template>
|