PWI: Profile (#1982)

* PWI: Profile

* Show replies conditionally

* Dismiss modals on auth action
This commit is contained in:
dan 2023-11-23 00:30:49 +00:00 committed by GitHub
parent edf3114e47
commit 4272d291a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 129 additions and 105 deletions

View file

@ -9,6 +9,7 @@ import {PUBLIC_BSKY_AGENT} from '#/state/queries'
import {IS_PROD} from '#/lib/constants'
import {emitSessionLoaded, emitSessionDropped} from '../events'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import {useCloseAllActiveElements} from '#/state/util'
let __globalAgent: BskyAgent = PUBLIC_BSKY_AGENT
@ -520,15 +521,17 @@ export function useSessionApi() {
export function useRequireAuth() {
const {hasSession} = useSession()
const {setShowLoggedOut} = useLoggedOutViewControls()
const closeAll = useCloseAllActiveElements()
return React.useCallback(
(fn: () => void) => {
if (hasSession) {
fn()
} else {
closeAll()
setShowLoggedOut(true)
}
},
[hasSession, setShowLoggedOut],
[hasSession, setShowLoggedOut, closeAll],
)
}