Refetch labelers on session resolution
This commit is contained in:
@@ -29,3 +29,11 @@ export function listenPostCreated(fn: () => void): UnlistenFn {
|
|||||||
emitter.on('post-created', fn)
|
emitter.on('post-created', fn)
|
||||||
return () => emitter.off('post-created', fn)
|
return () => emitter.off('post-created', fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function emitSessionResolved() {
|
||||||
|
emitter.emit('session-resolved')
|
||||||
|
}
|
||||||
|
export function listenOnSessionResolved(fn: () => void): UnlistenFn {
|
||||||
|
emitter.on('session-resolved', fn)
|
||||||
|
return () => emitter.off('session-resolved', fn)
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
|
|
||||||
import {usePreferencesQuery} from './index'
|
import {usePreferencesQuery} from './index'
|
||||||
import {useLabelersDetailedInfoQuery} from '../labeler'
|
import {useLabelersDetailedInfoQuery} from '../labeler'
|
||||||
|
import {listenOnSessionResolved} from '#/state/events'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More strict than our default settings for logged in users.
|
* More strict than our default settings for logged in users.
|
||||||
@@ -28,6 +29,13 @@ export function useMyLabelersQuery() {
|
|||||||
const labelers = useLabelersDetailedInfoQuery({dids})
|
const labelers = useLabelersDetailedInfoQuery({dids})
|
||||||
const isLoading = prefs.isLoading || labelers.isLoading
|
const isLoading = prefs.isLoading || labelers.isLoading
|
||||||
const error = prefs.error || labelers.error
|
const error = prefs.error || labelers.error
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
return listenOnSessionResolved(() => {
|
||||||
|
labelers.refetch()
|
||||||
|
})
|
||||||
|
}, [labelers])
|
||||||
|
|
||||||
return React.useMemo(() => {
|
return React.useMemo(() => {
|
||||||
return {
|
return {
|
||||||
isLoading,
|
isLoading,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {networkRetry} from '#/lib/async/retry'
|
|||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
import {PUBLIC_BSKY_AGENT} from '#/state/queries'
|
import {PUBLIC_BSKY_AGENT} from '#/state/queries'
|
||||||
import {emitSessionDropped} from '../events'
|
import {emitSessionDropped, emitSessionResolved} from '../events'
|
||||||
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
||||||
import {useCloseAllActiveElements} from '#/state/util'
|
import {useCloseAllActiveElements} from '#/state/util'
|
||||||
import {track} from '#/lib/analytics/analytics'
|
import {track} from '#/lib/analytics/analytics'
|
||||||
@@ -413,6 +413,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
`session: reuse of previous session returned a fresh account, upserting`,
|
`session: reuse of previous session returned a fresh account, upserting`,
|
||||||
)
|
)
|
||||||
upsertAccount(freshAccount)
|
upsertAccount(freshAccount)
|
||||||
|
emitSessionResolved()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
|||||||
Reference in New Issue
Block a user