Skip to content

Commit

Permalink
Merge pull request #19 from Chia-Network/fix/redownload-data-on-tab-c…
Browse files Browse the repository at this point in the history
…lick

fix: redownload data on tab click for units and projects
  • Loading branch information
MichaelTaylor3D authored Dec 4, 2023
2 parents 1ddcf5c + 8f6ab9c commit 715dd5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/pages/Projects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,24 @@ const Projects = withTheme(({ theme }) => {
const [isImportOfferModalVisible, setIsImportModalVisible] = useState(false);
const windowSize = useWindowSize();

const fetchProjects = () => {
const projectId = searchParams.get('projectId');
if (projectId) {
dispatch(getProjectData(projectId));
}
dispatch(getStagingData({ useMockedResponse: false }));
};

const handleTabChange = useCallback(
(event, newValue) => {
setTabValue(newValue);
fetchProjects();
},
[setTabValue],
);

useEffect(() => {
const projectId = searchParams.get('projectId');
if (projectId) {
dispatch(getProjectData(projectId));
}
fetchProjects();
return () => dispatch(clearProjectData());
}, [searchParams.get('projectId')]);

Expand Down
9 changes: 9 additions & 0 deletions src/pages/Units/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,18 @@ const Units = withTheme(({ theme }) => {
const [modalSizeAndPosition, setModalSizeAndPosition] = useState(null);
const windowSize = useWindowSize();

const fetchUnits = () => {
const unitId = searchParams.get('unitId');
if (unitId) {
dispatch(getUnitData(unitId));
}
dispatch(getStagingData({ useMockedResponse: false }));
};

const handleTabChange = useCallback(
(event, newValue) => {
setTabValue(newValue);
fetchUnits();
},
[setTabValue],
);
Expand Down

0 comments on commit 715dd5b

Please sign in to comment.