mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-10 21:55:19 +00:00
Let the shell say where home is, and drop the router from the call
The call reached for react-router in five places to send the user
"home": on leaving without a lobby, from the lobby's recents link, from
the post-call screen, from the error page's return button and from the
header logo. Home is the standalone app's home page; the call has no
idea where that is, and a component has no such place at all — its host
decides what follows a call. Yet the component had to mount a
MemoryRouter just so those hooks would not throw.
`useLeaveToHome` is the way home as the shell supplies it: the app
provides `navigate("/")` from inside its router, the component provides
nothing, and everything that used to link to "/" now either calls it or,
when there is none, offers no way out. The logo becomes a plain logo,
the recents and "not now" links disappear, the error page's button does
too. `ClientProvider`'s logout goes the same way. The component no
longer renders a router.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
f5a94ce702
commit
b7285064fd
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Copyright 2026 Element Creations Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { createContext, use } from "react";
|
||||
|
||||
/**
|
||||
* How the user leaves the call for wherever they came from: the standalone
|
||||
* app's home page, with its list of recent calls.
|
||||
*
|
||||
* The call itself has no idea where that is, or whether there is such a place
|
||||
* at all. Standalone there is, and the shell navigates to it; as a component
|
||||
* there is not — the host decides what happens after a call — so nothing is
|
||||
* supplied, and the call offers no way out of its own. This is what lets the
|
||||
* call be rendered without a router.
|
||||
*/
|
||||
const LeaveToHomeContext = createContext<(() => void) | null>(null);
|
||||
|
||||
export const LeaveToHomeProvider = LeaveToHomeContext.Provider;
|
||||
|
||||
/**
|
||||
* The way out of the call, or null when there is nowhere to go and the call
|
||||
* should not offer one.
|
||||
*/
|
||||
export const useLeaveToHome = (): (() => void) | null =>
|
||||
use(LeaveToHomeContext);
|
||||
Reference in New Issue
Block a user