diff --git a/src/misc/fileContext.tsx b/src/misc/fileContext.tsx index 48a70b29..5db51b62 100644 --- a/src/misc/fileContext.tsx +++ b/src/misc/fileContext.tsx @@ -181,6 +181,11 @@ export type FileContextType = { pvwsHost?: string, replace?: boolean ) => void; + updatePage: ( + location: string, + fileDesc?: FileDescription, + replace?: boolean + ) => void; removePage: ( location: string, fileDesc?: FileDescription, @@ -207,6 +212,7 @@ const initialState: FileContextType = { pageState: {}, tabState: {}, addPage: () => {}, + updatePage: () => {}, removePage: () => {}, addTab: () => {}, removeTab: () => {}, @@ -269,6 +275,23 @@ export const FileProvider: React.FC = ( replace: replace ?? false }); }, + updatePage: ( + location: string, + fileDesc?: FileDescription, + replace = false + ): void => { + if (!fileDesc) return; + + const currentPageState = historyLocation.state?.pageState ?? pageState; + + navigate(historyLocation.pathname, { + state: { + pageState: { ...currentPageState, [location]: fileDesc }, + tabState: historyLocation.state?.tabState ?? tabState + }, + replace + }); + }, removePage: ( location: string, fileDesc?: FileDescription,