Skip to content

Commit

Permalink
fix: Load until the profile is loaded (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio authored Jan 12, 2024
1 parent 45d3a6c commit c3853d8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/components/start/Start.container.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { connect } from 'react-redux'
import { isConnected, isConnecting, getData as getWallet } from 'decentraland-dapps/dist/modules/wallet/selectors'
import { getProfileOfAddress } from 'decentraland-dapps/dist/modules/profile/selectors'
import { LOAD_PROFILE_REQUEST } from 'decentraland-dapps/dist/modules/profile/actions'
import { getProfileOfAddress, getLoading, getError } from 'decentraland-dapps/dist/modules/profile/selectors'
import { StoreType } from '../../state/redux'
import { Props } from './Start.types'
import Start from './Start'

const mapStateToProps = (state: StoreType): Props => {
const wallet = getWallet(state)

return {
wallet,
isConnecting: isConnecting(state),
isConnected: isConnected(state),
isLoadingProfile: getLoading(state).some((a) => a.type === LOAD_PROFILE_REQUEST),
profile: (wallet?.address && getProfileOfAddress(state, wallet?.address)) || null
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/start/Start.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const useLocalStorageListener = (key: string) => {
}

export default function Start(props: Props) {
const { isConnected, isConnecting, wallet, profile } = props
const { isConnected, isConnecting, wallet, profile, isLoadingProfile } = props
const [initialized, setInitialized] = useState(false)
const [isLoadingExplorer, setIsLoadingExplorer] = useState(false)
const [isLoadingAvatar, setIsLoadingAvatar] = useState(true)
Expand Down Expand Up @@ -94,7 +94,7 @@ export default function Start(props: Props) {
return null
}

if (isConnecting && !initialized) {
if (!initialized || isLoadingProfile || isConnecting) {
return (
<div className="explorer-website-start">
<Loader active size="massive" />
Expand Down
5 changes: 3 additions & 2 deletions src/components/start/Start.types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Profile } from "@dcl/schemas"
import { Wallet } from "decentraland-dapps/dist/modules/wallet/types"
import { Profile } from '@dcl/schemas'
import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types'

export type Props = {
wallet: Wallet | null
isConnected: boolean
isConnecting: boolean
isLoadingProfile: boolean
profile: Profile | null
}

0 comments on commit c3853d8

Please sign in to comment.