feat(ui,docs): the open tab lives in the conversation url, admin screenshots in the readme
This commit is contained in:
1 parent
421248b0ad
commit
60782d6276
6 files changed
+35
-2
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { goto } from "$app/navigation";
|
||||
import { goto, replaceState } from "$app/navigation";
|
||||
import { base } from "$app/paths";
|
||||
import { page } from "$app/state";
|
||||
import ConversationView from "$lib/panel/conversation-view.svelte";
|
||||
@@ -7,6 +7,22 @@
|
||||
|
||||
const id = $derived(page.params.id ?? "");
|
||||
const href = (target: string) => `${base}/conversations/${target}`;
|
||||
|
||||
// ``?view=context`` opens that tab and stays in the address bar, so a
|
||||
// reload (or a restart) lands where the reader was. Thread is the default
|
||||
// and keeps the URL clean.
|
||||
const initialView = $derived(page.url.searchParams.get("view") ?? "chat");
|
||||
function remember(view: string) {
|
||||
const url = new URL(page.url);
|
||||
if (view === "chat") {
|
||||
url.searchParams.delete("view");
|
||||
} else {
|
||||
url.searchParams.set("view", view);
|
||||
}
|
||||
if (url.href !== page.url.href) {
|
||||
replaceState(url, page.state);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Conversation · Beaver</title></svelte:head>
|
||||
@@ -17,7 +33,9 @@
|
||||
client={session.client}
|
||||
{href}
|
||||
{id}
|
||||
{initialView}
|
||||
onOpen={(target) => goto(href(target))}
|
||||
onViewChange={remember}
|
||||
/>
|
||||
{/key}
|
||||
{/if}
|
||||
Reference in new issue
Block a user