mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 11:41:39 +00:00
client/web: move useNodeData out of App component
Only loading data once auth request has completed. Updates tailscale/corp#14335 Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
This commit is contained in:
parent
d530153d2f
commit
0753ad6cf8
@ -13,16 +13,35 @@ import DeviceDetailsView from "./views/device-details-view"
|
|||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const { data: auth, loading: loadingAuth, newSession } = useAuth()
|
const { data: auth, loading: loadingAuth, newSession } = useAuth()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className="min-w-sm max-w-lg mx-auto py-14 px-5">
|
||||||
|
{loadingAuth ? (
|
||||||
|
<div className="text-center py-14">Loading...</div> // TODO(sonia): add a loading view
|
||||||
|
) : (
|
||||||
|
<WebClient auth={auth} newSession={newSession} />
|
||||||
|
)}
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function WebClient({
|
||||||
|
auth,
|
||||||
|
newSession,
|
||||||
|
}: {
|
||||||
|
auth?: AuthResponse
|
||||||
|
newSession: () => Promise<void>
|
||||||
|
}) {
|
||||||
const { data, refreshData, updateNode } = useNodeData()
|
const { data, refreshData, updateNode } = useNodeData()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refreshData()
|
refreshData()
|
||||||
}, [auth, refreshData])
|
}, [auth, refreshData])
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return <div className="text-center py-14">Loading...</div> // TODO(sonia): add a loading view
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="min-w-sm max-w-lg mx-auto py-14 px-5">
|
|
||||||
{loadingAuth || !data ? (
|
|
||||||
<div className="text-center py-14">Loading...</div> // TODO(sonia): add a loading view
|
|
||||||
) : (
|
|
||||||
<>
|
<>
|
||||||
{/* TODO(sonia): get rid of the conditions here once full/readonly
|
{/* TODO(sonia): get rid of the conditions here once full/readonly
|
||||||
* views live on same components */}
|
* views live on same components */}
|
||||||
@ -52,8 +71,6 @@ export default function App() {
|
|||||||
</Route>
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
</>
|
</>
|
||||||
)}
|
|
||||||
</main>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user