Skip to content

Commit

Permalink
fix(header): Automatically clear blueprint cache
Browse files Browse the repository at this point in the history
  • Loading branch information
soofstad committed May 27, 2024
1 parent 47ac6ff commit bb9c0b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions packages/dm-core-plugins/src/header/HeaderPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,13 @@ export default (props: IUIPlugin): React.ReactElement => {
onClick={() => {
dmssAPI
.refreshLookup({ application: name })
.then(() =>
toast.warning(
`RecipeLookup for app '${name}' changed. Close open tabs to clear cache.`,
{ autoClose: false }
)
)
.then(() => {
Object.keys(window.sessionStorage).forEach((key) => {
if (key.startsWith('BLUEPRINT::'))
window.sessionStorage.removeItem(key)
})
toast.success(`RecipeLookup for app '${name}' updated`)
})
.catch((error: any) => {
console.error(error)
toast.error(`Failed to refresh application '${name}'`)
Expand Down
2 changes: 1 addition & 1 deletion packages/dm-core/src/ApplicationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const DMApplicationProvider = (props: {

// @ts-ignore
dmssAPI.blueprintGet = async (requestParameters, options) => {
const cacheKey = `${requestParameters.typeRef}${requestParameters.context}`
const cacheKey = `BLUEPRINT::${requestParameters.typeRef}${requestParameters.context}`
const cachedValue = window.sessionStorage.getItem(cacheKey)
if (!cachedValue) {
return dmssAPIOriginal
Expand Down

0 comments on commit bb9c0b1

Please sign in to comment.