1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00

Clear selected app ID from overview store when unmounting, and avoid sending up 'null' and 'undefined' string app ID headers

This commit is contained in:
Andrew Kingston 2023-04-25 08:35:25 +01:00
parent 14545729ac
commit 22d81fd858
2 changed files with 8 additions and 5 deletions

View file

@ -10,11 +10,10 @@ import { auth, overview } from "./stores/portal"
export const API = createAPIClient({ export const API = createAPIClient({
attachHeaders: headers => { attachHeaders: headers => {
// Attach app ID header from store // Attach app ID header from store
let appId = get(store).appId let appId = get(store).appId || get(overview).selectedAppId
if (!appId) { if (appId) {
appId = get(overview).selectedAppId headers["x-budibase-app-id"] = appId
} }
headers["x-budibase-app-id"] = appId
// Add csrf token if authenticated // Add csrf token if authenticated
const user = get(auth).user const user = get(auth).user

View file

@ -33,7 +33,7 @@
import * as routify from "@roxi/routify" import * as routify from "@roxi/routify"
import { onDestroy } from "svelte" import { onDestroy } from "svelte"
// Keep URL and state in sync for selected screen ID // Keep URL and state in sync for selected app ID
const stopSyncing = syncURLToState({ const stopSyncing = syncURLToState({
urlParam: "appId", urlParam: "appId",
stateKey: "selectedAppId", stateKey: "selectedAppId",
@ -111,6 +111,10 @@
onDestroy(() => { onDestroy(() => {
stopSyncing() stopSyncing()
store.actions.reset() store.actions.reset()
overview.update(state => ({
...state,
selectedAppId: null,
}))
}) })
</script> </script>