fix(journal): decouple broker from session
The broker connection now persists across session changes. Joining or switching a session swaps subscriptions instead of reconnecting, and a lobby lets sessions be listed and created before joining one. Fixes session switching being a no-op (the store only updated local state) and session creation being unreachable before connecting. Also removes the dead ConnectionBar and the no-op hydrateFromServer/setSessionId store calls.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* JournalHeader — status dot, player name, session dropdown, disconnect & close
|
||||
* JournalHeader — status dot, player name, session dropdown, leave & close
|
||||
*/
|
||||
import { Component, Show } from "solid-js";
|
||||
import { useJournalStream, disconnectStream } from "../stores/journalStream";
|
||||
import { useJournalStream, leaveSession } from "../stores/journalStream";
|
||||
import { SessionDropdown } from "./SessionDropdown";
|
||||
|
||||
interface JournalHeaderProps {
|
||||
@@ -13,7 +13,7 @@ interface JournalHeaderProps {
|
||||
export const JournalHeader: Component<JournalHeaderProps> = (props) => {
|
||||
const stream = useJournalStream();
|
||||
|
||||
const handleDisconnect = () => disconnectStream();
|
||||
const handleLeave = () => leaveSession();
|
||||
|
||||
return (
|
||||
<div class="flex items-center justify-between px-3 py-2 border-b border-gray-200 shrink-0">
|
||||
@@ -32,7 +32,9 @@ export const JournalHeader: Component<JournalHeaderProps> = (props) => {
|
||||
<Show
|
||||
when={stream.connected && stream.sessionId}
|
||||
fallback={
|
||||
<h2 class="text-sm font-semibold text-gray-700 truncate">未连接</h2>
|
||||
<h2 class="text-sm font-semibold text-gray-700 truncate">
|
||||
{stream.connected ? "选择会话" : "未连接"}
|
||||
</h2>
|
||||
}
|
||||
>
|
||||
<div class="min-w-0">
|
||||
@@ -58,13 +60,13 @@ export const JournalHeader: Component<JournalHeaderProps> = (props) => {
|
||||
</Show>
|
||||
</div>
|
||||
<div class="flex items-center gap-1 shrink-0">
|
||||
<Show when={stream.connected}>
|
||||
<Show when={stream.sessionId}>
|
||||
<button
|
||||
onClick={handleDisconnect}
|
||||
class="text-xs text-gray-400 hover:text-red-500 px-1"
|
||||
title="断开连接"
|
||||
onClick={handleLeave}
|
||||
class="text-xs text-gray-400 hover:text-blue-500 px-1"
|
||||
title="返回会话列表"
|
||||
>
|
||||
⏻
|
||||
←
|
||||
</button>
|
||||
</Show>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user