@@ -9,7 +9,10 @@ import {
99 SetComponentFileRequest ,
1010 useSetComponentFile ,
1111} from '@/features/instance/operations/mutations/setComponentFile' ;
12- import { getComponentFileQueryOptions } from '@/features/instance/operations/queries/getComponentFile' ;
12+ import {
13+ getComponentFileQueryKey ,
14+ getComponentFileQueryOptions ,
15+ } from '@/features/instance/operations/queries/getComponentFile' ;
1316import {
1417 APIDirectoryEntry ,
1518 APIFileEntry ,
@@ -114,6 +117,11 @@ export function EditorViewProvider({ children }: PropsWithChildren) {
114117 const pathToLoad = openedEntry && ( isDirectory ( openedEntry ) ? openedEntry . overviewEntry ?. path : openedEntry . path ) || '' ;
115118 const projectToLoad = openedEntry && ( isDirectory ( openedEntry ) ? openedEntry . overviewEntry ?. project : openedEntry . project ) || '' ;
116119 const loadedOverviewEntry = openedEntry && ( isDirectory ( openedEntry ) ? ! ! openedEntry . overviewEntry ?. path : false ) || false ;
120+ const fileQueryKey = getComponentFileQueryKey ( {
121+ file : pathToLoad ?. split ( '/' ) . slice ( 1 ) . join ( '/' ) ,
122+ project : projectToLoad ,
123+ ...instanceParams ,
124+ } ) ;
117125 const { data : getComponentFileQueryData } = useQuery (
118126 getComponentFileQueryOptions (
119127 {
@@ -148,16 +156,17 @@ export function EditorViewProvider({ children }: PropsWithChildren) {
148156 saveComponentFile ( data , {
149157 onSuccess : ( ) => {
150158 if ( openedEntry ?. path === filePath && data . payload !== undefined ) {
151- setOpenedEntryContents ( data . payload || undefined ) ;
152159 setUpdatedEntryContents ( undefined ) ;
160+ setOpenedEntryContents ( data . payload || undefined ) ;
161+ queryClient . setQueryData ( fileQueryKey , { ...getComponentFileQueryData , message : data . payload } ) ;
153162 }
154163 } ,
155164 onError : ( error ) => {
156165 console . error ( 'Error saving file:' , error ) ;
157166 } ,
158167 } ) ;
159168 } ,
160- [ saveComponentFile , setUpdatedEntryContents , openedEntry ] ,
169+ [ saveComponentFile , setUpdatedEntryContents , setOpenedEntryContents , openedEntry ] ,
161170 ) ;
162171
163172 const restrictPackageModification = useMemo ( ( ) => {
0 commit comments