-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c27d617
commit fa1f0b6
Showing
8 changed files
with
26 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
import { useEffect } from 'react'; | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
|
||
import { RouteUrls } from '@shared/route-urls'; | ||
|
||
// import { RouteUrls } from '@shared/route-urls'; | ||
import { useLocationState } from '@app/common/hooks/use-location-state'; | ||
|
||
// PETE this is the last thing | ||
// - test opening in new tabs | ||
// - find what fails and where then apply Kyrans advice | ||
// - I think it works everywhere but Home tabs | ||
|
||
/* | ||
when modals are opened in a new tab they lose the location.state.backgroundLocation | ||
this hook sets the backgroundLocation to be RouteUrls.Home to improve UX | ||
*/ | ||
|
||
// This seems to do nothing and things already work in new tabs? | ||
// test more | ||
export function useBackgroundLocationRedirect() { | ||
const { pathname, state } = useLocation(); | ||
const navigate = useNavigate(); | ||
const backgroundLocation = useLocationState('backgroundLocation'); | ||
|
||
// console.log('backgroundLocation', backgroundLocation); | ||
// debugger; | ||
useEffect(() => { | ||
void (async () => { | ||
switch (true) { | ||
// FIXME ReceiveCollectibleOrdinal loses state?.btcAddressTaproot in a new tab | ||
// this can be improved to try and fetch btcAddressTaproot | ||
// case pathname === RouteUrls.ReceiveCollectibleOrdinal && !state?.btcAddressTaproot: | ||
// return navigate(RouteUrls.Home); | ||
|
||
// case backgroundLocation === undefined: | ||
// return navigate(pathname, { | ||
// state: { backgroundLocation: { pathname: RouteUrls.Home } }, | ||
// }); | ||
default: | ||
return false; | ||
} | ||
// if (backgroundLocation === undefined) { | ||
// return navigate(pathname, { | ||
// state: { backgroundLocation: { pathname: RouteUrls.Home }, ...state }, | ||
// }); | ||
// } | ||
return false; | ||
})(); | ||
}, [backgroundLocation, navigate, pathname, state]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters