Skip to content

Commit

Permalink
Merge pull request #33 from pluralsh/retain-app-across-sessions
Browse files Browse the repository at this point in the history
retain application across sessions
  • Loading branch information
ycryptx authored Feb 25, 2022
2 parents eca255c + 5b620a9 commit 34e9880
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion assets/src/components/Installations.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export function InstallationsProvider({children}) {
const [{func: onChange}, setOnChange] = useState({func: () => null})
const {data, subscribeToMore} = useQuery(APPLICATIONS_Q, {pollInterval: 120_000})
const wrapped = useCallback((application) => {
sessionStorage.setItem('currentApplication', application.name)
setCurrentApplication(application)
application && onChange(application)
}, [onChange, setCurrentApplication])
Expand All @@ -235,7 +236,8 @@ export function InstallationsProvider({children}) {
</Box>
)
}
const current = currentApplication && data && data.applications.find(({name}) => name === currentApplication.name)
const lastSessionApplication = data && data.applications.find(({name}) => name === sessionStorage.getItem('currentApplication'))
const current = lastSessionApplication ? lastSessionApplication : currentApplication && data && data.applications.find(({name}) => name === currentApplication.name)

return (
<InstallationContext.Provider
Expand Down

0 comments on commit 34e9880

Please sign in to comment.