feat: federated space layout sync — home-authoritative with fallback

Federated users now have their sidebar layout synced from their true
home instance instead of each browsing instance maintaining a separate
disconnected layout. Layout saves route to the true home API with
automatic fallback to the browsing instance if unreachable.
This commit is contained in:
Jannis Braun
2026-03-12 17:23:10 +01:00
parent 06b56472f9
commit acbcf4d4e8
2 changed files with 62 additions and 5 deletions
+6 -1
View File
@@ -698,7 +698,12 @@ function handleEvent(origin: string, event: ServerEvent): void {
}
case 'space_layout_updated': {
if (!isHome) break;
// Accept layout updates from browsing instance OR true home
const layoutUser = useAuthStore.getState().user;
const isLayoutTrueHome = !!layoutUser?.homeInstance && origin !== '' && (() => {
try { return new URL(origin).host === layoutUser.homeInstance; } catch { return false; }
})();
if (!isHome && !isLayoutTrueHome) break;
const { setSpaceLayout } = useSpaceStore.getState();
setSpaceLayout(event.layout);
useSpaceStore.setState({ folders: event.folders });