Clear visible chat mentions in BGS and show date separators

This commit is contained in:
coyotte508 2026-09-13 22:41:01 +02:00
commit 6385032ca7
5 changed files with 34 additions and 7 deletions

View file

@ -16,7 +16,7 @@
"preview": "vite preview"
},
"dependencies": {
"@boardgamers/protocol": "0.2.0",
"@boardgamers/protocol": "0.2.1",
"outpost-engine": "workspace:*"
},
"devDependencies": {

View file

@ -1,9 +1,11 @@
<script lang="ts">
import { chatDateSeparators } from "@boardgamers/protocol/chat";
import type { ViewerStore } from "./store.svelte";
import type { ChatMessage } from "@boardgamers/protocol/chat";
import { bindChatComposer, bindChatViewport, type ChatSuggestions } from "@boardgamers/protocol/chat/dom";
let { store }: { store: ViewerStore } = $props();
const chat = $derived(store.chatState);
const dates = $derived(chatDateSeparators(chat.messages));
const messages = $derived(chat.messages);
let composer: HTMLInputElement | undefined = $state();
let feed: HTMLDivElement | undefined = $state();
@ -55,6 +57,8 @@
{#each messages as message, index (message._id ?? index)}
{@const color = store.chatAuthorColor(message)}
{@const time = timeOf(message)}
{@const day = dates[index]}
{#if day}<div class="chat-day"><time datetime={day.dateTime}>{day.label}</time></div>{/if}
<div class="entry" class:system={message.type === "system"} data-message-id={message._id}>
{#if time}<span class="time">{time}</span>{/if}
{#if message.author}
@ -116,6 +120,24 @@
{/if}
<style>
.chat-day {
display: flex;
align-items: center;
gap: 8px;
margin: 12px 0 8px;
font-size: 11px;
color: var(--text-dim);
}
.chat-day::before,
.chat-day::after {
content: "";
flex: 1;
border-top: 1px solid var(--line);
}
.chat-day time {
color: inherit;
font-size: inherit;
}
.chat {
display: flex;
flex-direction: column;

10
pnpm-lock.yaml generated
View file

@ -40,8 +40,8 @@ importers:
packages/viewer:
dependencies:
'@boardgamers/protocol':
specifier: 0.2.0
version: 0.2.0
specifier: 0.2.1
version: 0.2.1
outpost-engine:
specifier: workspace:*
version: link:../engine
@ -67,8 +67,8 @@ importers:
packages:
'@boardgamers/protocol@0.2.0':
resolution: {integrity: sha512-6vUH+vjERARwHmUeOX+Gg1AgvV3+glPJjnh73E3ZlJGrYv6bXFe53Z6Xs+Pvv4i3zvdVHRBnxjEfQ7GDAE3mVg==}
'@boardgamers/protocol@0.2.1':
resolution: {integrity: sha512-e114ohTXaZ1cHdzJs9kj+MkT1ciHGtcaqFherLVMFNrgvxLUGq8kZ8cCxsObXI4n0MGjzPU+Y/j+DAKD0yHoxw==}
'@jridgewell/gen-mapping@0.3.13':
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
@ -772,7 +772,7 @@ packages:
snapshots:
'@boardgamers/protocol@0.2.0':
'@boardgamers/protocol@0.2.1':
dependencies:
zod: 4.6.2

View file

@ -1,4 +1,4 @@
packages:
- "packages/*"
minimumReleaseAgeExclude:
- "@boardgamers/protocol@0.2.0"
- "@boardgamers/protocol@0.2.1"

View file

@ -50,6 +50,7 @@ try {
Array.from({ length: 35 }, (_, i) => ({
_id: (i + 1).toString(16).padStart(24, "0"),
text: `History ${i}`,
createdAt: new Date(2026, 8, i < 30 ? 12 : 13, 12).toISOString(),
type: "text",
author: "Other",
playerIndex: 2,
@ -71,6 +72,10 @@ try {
await page.waitForTimeout(650);
assert.equal(await page.evaluate(() => events.filter((e) => e.name === "chat:read").length), 0);
}
assert.deepEqual(await page.locator(".chat-day time").evaluateAll((dates) => dates.map((date) => date.dateTime)), [
"2026-09-12",
"2026-09-13",
]);
const feed = page.getByRole("region", { name: "Chat messages" });
await feed.scrollIntoViewIfNeeded();
await page.waitForFunction(() => events.some((e) => e.name === "chat:read" && e.data.messageId.endsWith("23")));