Skip to content

Commit

Permalink
fix(toolbar): Don't try to load hedgehog config without auth (#25323)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Twixes and github-actions[bot] authored Oct 3, 2024
1 parent 1769b26 commit 8c4b061
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frontend/src/lib/components/HedgehogBuddy/hedgehogBuddyLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ export const hedgehogBuddyLogic = kea<hedgehogBuddyLogicType>([
{
loadRemoteConfig: async () => {
const endpoint = '/api/users/@me/hedgehog_config'
if (toolbarConfigLogic?.findMounted()?.values.temporaryToken) {
const mountedToolbarConfigLogic = toolbarConfigLogic.findMounted()
if (mountedToolbarConfigLogic) {
// If toolbarConfigLogic is mounted, we're inside the Toolbar
if (!mountedToolbarConfigLogic.values.isAuthenticated) {
return null
}
return await (await toolbarFetch(endpoint, 'GET')).json()
}
return await api.get<Partial<HedgehogConfig>>(endpoint)
Expand All @@ -65,7 +70,12 @@ export const hedgehogBuddyLogic = kea<hedgehogBuddyLogicType>([
const localConfig = values.localConfig
let newConfig: Partial<HedgehogConfig>

if (toolbarConfigLogic?.findMounted()?.values.temporaryToken) {
const mountedToolbarConfigLogic = toolbarConfigLogic.findMounted()
if (mountedToolbarConfigLogic) {
// If toolbarConfigLogic is mounted, we're inside the Toolbar
if (!mountedToolbarConfigLogic.values.isAuthenticated) {
return null
}
newConfig = await (await toolbarFetch(endpoint, 'PATCH', config)).json()
} else {
newConfig = await api.update(endpoint, config)
Expand Down

0 comments on commit 8c4b061

Please sign in to comment.