mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 19:01:08 +02:00
fix(workbench): handle ?app= deep-links reactively while page is mounted
The onMount handler only fires once, so clicking a /?app=settings link from the companion chat (or any in-app link) while already on the workbench page did nothing. Add a reactive $effect that watches $page.url.searchParams for 'app' changes and opens/scrolls to the target panel on every navigation, not just on initial mount. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e60965ee19
commit
fa31fa0caf
1 changed files with 19 additions and 0 deletions
|
|
@ -82,6 +82,25 @@
|
|||
history.replaceState({}, '', clean);
|
||||
}
|
||||
});
|
||||
// Reactive deep-link: handles `/?app=…` navigations that happen
|
||||
// while the page is already mounted (e.g. clicking a link inside
|
||||
// the companion chat). onMount only fires once; this $effect
|
||||
// re-runs whenever the URL search params change.
|
||||
$effect(() => {
|
||||
const target = $page.url.searchParams.get('app');
|
||||
if (!target || !getApp(target)) return;
|
||||
// Use queueMicrotask so we don't mutate state during the effect's first run
|
||||
queueMicrotask(async () => {
|
||||
const already = workbenchScenesStore.openApps.find((a) => a.appId === target);
|
||||
if (!already) await workbenchScenesStore.addApp(target);
|
||||
await tick();
|
||||
scrollToPage(target);
|
||||
const clean = new URL($page.url);
|
||||
clean.searchParams.delete('app');
|
||||
history.replaceState({}, '', clean);
|
||||
});
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
workbenchScenesStore.dispose();
|
||||
bottomBarStore.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue