Skip to content

Commit

Permalink
fix goBack precedence (ohcnetwork#6285)
Browse files Browse the repository at this point in the history
* fix go back precedence

* fixes ohcnetwork#6233
  • Loading branch information
rithviknishad authored Sep 14, 2023
1 parent cc6b570 commit 2956fa9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Common/hooks/useAppHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ export default function useAppHistory() {
const resetHistory = useContext(ResetHistoryContext);

const goBack = (fallbackUrl?: string) => {
if (fallbackUrl)
// use provided fallback url if provided.
return navigate(fallbackUrl);
if (history.length > 1)
// Otherwise, navigate to history present in the app navigation history stack.
return navigate(history[1]);

if (fallbackUrl)
// use provided fallback url if provided.
return navigate(fallbackUrl);
// Otherwise, fallback to browser's go back behaviour.
window.history.back();
};
Expand Down
4 changes: 3 additions & 1 deletion src/Components/Assets/AssetType/ONVIFCamera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {
const [refreshPresetsHash, setRefreshPresetsHash] = useState(
Number(new Date())
);
const [refreshHash, setRefreshHash] = useState(Number(new Date()));
const dispatch = useDispatch<any>();

useEffect(() => {
Expand Down Expand Up @@ -89,7 +90,7 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {
Notification.Success({
msg: "Asset Configured Successfully",
});
window.location.reload();
setRefreshHash(Number(new Date()));
} else {
Notification.Error({
msg: "Something went wrong..!",
Expand Down Expand Up @@ -200,6 +201,7 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {

{assetType === "ONVIF" ? (
<CameraConfigure
key={refreshHash}
asset={asset as AssetData}
bed={bed}
setBed={setBed}
Expand Down

0 comments on commit 2956fa9

Please sign in to comment.