removed user from loading paramter (it's in global state now)
This commit is contained in:
parent
e9ae50a618
commit
4c51513cfe
1 changed files with 6 additions and 7 deletions
|
|
@ -34,7 +34,7 @@ export default function UserWrapper() {
|
||||||
const userAPI = useUserAPI();
|
const userAPI = useUserAPI();
|
||||||
const useAuth = useAuth0();
|
const useAuth = useAuth0();
|
||||||
const hasFetched = useRef(false);
|
const hasFetched = useRef(false);
|
||||||
const [user, setUser] = useState<pond.User | undefined>(undefined)
|
// const [user, setUser] = useState<pond.User | undefined>(undefined)
|
||||||
const [message, setMessage] = useState("Loading user profile...")
|
const [message, setMessage] = useState("Loading user profile...")
|
||||||
const [global, setGlobal] = useState<undefined | GlobalState>(undefined)
|
const [global, setGlobal] = useState<undefined | GlobalState>(undefined)
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ export default function UserWrapper() {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
userAPI.getUserWithTeam(user_id).then(resp => {
|
userAPI.getUserWithTeam(user_id).then(resp => {
|
||||||
console.log(resp.data.team)
|
console.log(resp.data.team)
|
||||||
if (resp.data.user) setUser(resp.data.user)
|
// if (resp.data.user) setUser(resp.data.user)
|
||||||
setGlobal({
|
setGlobal({
|
||||||
user: resp.data.user ? User.create(resp.data.user) : User.create(),
|
user: resp.data.user ? User.create(resp.data.user) : User.create(),
|
||||||
team: resp.data.team ? Team.create(resp.data.team) : Team.create(),
|
team: resp.data.team ? Team.create(resp.data.team) : Team.create(),
|
||||||
|
|
@ -62,17 +62,16 @@ export default function UserWrapper() {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
hasFetched.current = true;
|
hasFetched.current = true;
|
||||||
})
|
})
|
||||||
}, [setGlobal, setUser])
|
}, [setGlobal])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (loading) return;
|
if (loading) return;
|
||||||
loadUser()
|
loadUser()
|
||||||
}, [loading])
|
}, [loading])
|
||||||
|
|
||||||
console.log(user)
|
|
||||||
console.log(loading)
|
console.log(loading)
|
||||||
console.log(global)
|
console.log(global)
|
||||||
if (!user || loading || !global) return (
|
if (loading || !global) return (
|
||||||
<LoadingScreen
|
<LoadingScreen
|
||||||
message={message}
|
message={message}
|
||||||
/>
|
/>
|
||||||
|
|
@ -95,7 +94,7 @@ export default function UserWrapper() {
|
||||||
count is {count}
|
count is {count}
|
||||||
</button>
|
</button>
|
||||||
<p>
|
<p>
|
||||||
Hello, {user.settings?.name}!
|
Hello, {global.user.settings?.name}!
|
||||||
</p>
|
</p>
|
||||||
</div><p className="read-the-docs">
|
</div><p className="read-the-docs">
|
||||||
Coming soon
|
Coming soon
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue