fix: add files and marked to sign page exports #226
@ -39,6 +39,7 @@ export const MainLayout = () => {
|
|||||||
const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState(`Loading App`)
|
const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState(`Loading App`)
|
||||||
const isLoggedIn = useAppSelector((state) => state.auth?.loggedIn)
|
const isLoggedIn = useAppSelector((state) => state.auth?.loggedIn)
|
||||||
const authState = useAppSelector((state) => state.auth)
|
const authState = useAppSelector((state) => state.auth)
|
||||||
|
const usersAppData = useAppSelector((state) => state.userAppData)
|
||||||
|
|
||||||
// Ref to track if `subscribeForSigits` has been called
|
// Ref to track if `subscribeForSigits` has been called
|
||||||
const hasSubscribed = useRef(false)
|
const hasSubscribed = useRef(false)
|
||||||
@ -123,6 +124,9 @@ export const MainLayout = () => {
|
|||||||
if (opts.type === 'login' || opts.type === 'signup') {
|
if (opts.type === 'login' || opts.type === 'signup') {
|
||||||
dispatch(updateNostrLoginAuthMethod(opts.method))
|
dispatch(updateNostrLoginAuthMethod(opts.method))
|
||||||
login()
|
login()
|
||||||
|
} else if (opts.type === 'logout') {
|
||||||
|
// Clear `subscribeForSigits` as called after the logout
|
||||||
|
hasSubscribed.current = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,12 +178,10 @@ export const MainLayout = () => {
|
|||||||
}, [dispatch])
|
}, [dispatch])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When authState change user logged in / or app reloaded
|
* Subscribe for the sigits
|
||||||
* we set robohash avatar in the global state based on user npub
|
|
||||||
* so that avatar will be consistent across the app when kind 0 is empty
|
|
||||||
*/
|
*/
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (authState && isLoggedIn) {
|
if (authState && isLoggedIn && usersAppData) {
|
||||||
const pubkey = authState.usersPubkey || authState.keyPair?.public
|
const pubkey = authState.usersPubkey || authState.keyPair?.public
|
||||||
|
|
||||||
if (pubkey && !hasSubscribed.current) {
|
if (pubkey && !hasSubscribed.current) {
|
||||||
@ -190,6 +192,17 @@ export const MainLayout = () => {
|
|||||||
// Mark `subscribeForSigits` as called
|
// Mark `subscribeForSigits` as called
|
||||||
hasSubscribed.current = true
|
hasSubscribed.current = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}, [authState, isLoggedIn, usersAppData])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When authState change user logged in / or app reloaded
|
||||||
|
* we set robohash avatar in the global state based on user npub
|
||||||
|
* so that avatar will be consistent across the app when kind 0 is empty
|
||||||
|
*/
|
||||||
|
useEffect(() => {
|
||||||
|
if (authState && isLoggedIn) {
|
||||||
|
const pubkey = authState.usersPubkey || authState.keyPair?.public
|
||||||
|
|
||||||
if (pubkey) {
|
if (pubkey) {
|
||||||
dispatch(setUserRobotImage(getRoboHashPicture(pubkey)))
|
dispatch(setUserRobotImage(getRoboHashPicture(pubkey)))
|
||||||
|
@ -875,7 +875,10 @@ export const subscribeForSigits = async (pubkey: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
const processReceivedEvent = async (event: Event, difficulty: number = 5) => {
|
||||||
const processedEvents = store.getState().userAppData?.processedGiftWraps || []
|
const processedEvents = store.getState().userAppData?.processedGiftWraps
|
||||||
|
|
||||||
|
// Abort processing if userAppData is undefined
|
||||||
|
if (!processedEvents) return
|
||||||
|
|
||||||
if (processedEvents.includes(event.id)) return
|
if (processedEvents.includes(event.id)) return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user