Skip to content

Commit

Permalink
Wait for access token before getting active assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Christdej committed Nov 1, 2023
1 parent 29dd806 commit 83cece1
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ function InstallationPicker() {
Array.from(mappedOptions.keys()).includes(installationName)

useEffect(() => {
const plantPromise = showActivePlants ? BackendAPICaller.getActivePlants() : BackendAPICaller.getEchoPlantInfo()
plantPromise.then(async (response: EchoPlantInfo[]) => {
const mapping = mapInstallationCodeToName(response)
setAllPlantsMap(mapping)
})
if (BackendAPICaller.accessToken) {
const plantPromise = showActivePlants
? BackendAPICaller.getActivePlants()
: BackendAPICaller.getEchoPlantInfo()
plantPromise.then(async (response: EchoPlantInfo[]) => {
const mapping = mapInstallationCodeToName(response)
setAllPlantsMap(mapping)
})
}
}, [showActivePlants, updateListOfActivePlants])

return (
Expand Down

0 comments on commit 83cece1

Please sign in to comment.