Skip to content

Commit

Permalink
Fixed caching of source xml
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jul 7, 2022
1 parent 5d5dc4d commit 0cd83bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions ui/src/app/metadata/hoc/MetadataXmlLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function MetadataXmlLoader({ children }) {
const [xml, setXml] = React.useState();

async function loadMetadataXml(id) {
const data = await get(`/${id}`)
const data = await get(`/${id}`);
if (response.ok) {
setXml(data);
}
Expand All @@ -22,12 +22,16 @@ export function MetadataXmlLoader({ children }) {
/*eslint-disable react-hooks/exhaustive-deps*/
React.useEffect(() => {
if (type === 'source') {
loadMetadataXml(id)
reload()
}
}, [id]);

function reload() {
loadMetadataXml(id);
}

return (
<MetadataXmlContext.Provider value={xml}>
<MetadataXmlContext.Provider value={{reload, xml}}>
{children}
</MetadataXmlContext.Provider>
);
Expand Down
7 changes: 6 additions & 1 deletion ui/src/app/metadata/view/MetadataXml.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ import { MetadataViewToggle } from '../component/MetadataViewToggle';
import { downloadAsXml } from '../../core/utility/download_as_xml';

export function MetadataXml () {
const xml = React.useContext(MetadataXmlContext);
const { xml, reload } = React.useContext(MetadataXmlContext);
const entity = React.useContext(MetadataObjectContext);
const { type } = useParams();

const download = () => downloadAsXml(entity.name ? entity.name : entity.serviceProviderName, xml);

/*eslint-disable react-hooks/exhaustive-deps*/
React.useEffect(() => {
reload();
}, []);

return (
<>
<h2 className="mb-4">
Expand Down

0 comments on commit 0cd83bc

Please sign in to comment.