Skip to content

Commit

Permalink
fix: clean code, add note re ordinals modal
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-watters committed Oct 13, 2023
1 parent dd39577 commit efb3843
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/app/features/settings-dropdown/settings-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export function SettingsDropdown() {
</MenuItem>
</>
)}
{/* // more importantly I broke tests again for direct access to receive I think */}
<MenuItem
data-testid={SettingsSelectors.ToggleTheme}
onClick={wrappedCloseCallback(() => {
Expand Down
4 changes: 1 addition & 3 deletions src/app/pages/fund/fund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ export function FundPage({ children }: FundPageProps) {
return (
<>
<FundLayout address={currentAccount.address} />
<>
<ModalBackgroundWrapper>{children}</ModalBackgroundWrapper>
</>
<ModalBackgroundWrapper>{children}</ModalBackgroundWrapper>
</>
);
}
10 changes: 3 additions & 7 deletions src/app/pages/receive/receive-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export function ReceiveModal({ type = 'full' }: ReceiveModalProps) {
onCopyAddress={() => copyToClipboard(onCopyBtc)}
onClickQrCode={() =>
navigate(`${RouteUrls.Home}${RouteUrls.ReceiveBtc}`, {
// see if i need ...location.state
state: { backgroundLocation, ...location.state },
state: { backgroundLocation },
})
}
title="Bitcoin"
Expand Down Expand Up @@ -125,7 +124,7 @@ export function ReceiveModal({ type = 'full' }: ReceiveModalProps) {
icon={<BtcStampsIcon />}
onClickQrCode={() =>
navigate(`${RouteUrls.Home}${RouteUrls.ReceiveBtcStamp}`, {
state: { backgroundLocation, ...location.state },
state: { backgroundLocation },
})
}
onCopyAddress={() =>
Expand All @@ -139,17 +138,14 @@ export function ReceiveModal({ type = 'full' }: ReceiveModalProps) {
onCopyAddress={() => copyToClipboard(onCopyStx, 'select_nft_to_add_new_collectible')}
onClickQrCode={() =>
navigate(`${RouteUrls.Home}${RouteUrls.ReceiveStx}`, {
state: { backgroundLocation, ...location.state },
state: { backgroundLocation },
})
}
title="Stacks NFT"
/>
</ReceiveItemList>
</Box>
</BaseDrawer>

{/* Outlet here for nested token routes */}
<Outlet />
</>
);
}
4 changes: 2 additions & 2 deletions src/app/pages/receive/receive-ordinal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ export function ReceiveOrdinalModal() {
useBackgroundLocationRedirect();
const analytics = useAnalytics();
const { state } = useLocation();
const { onCopy } = useClipboard(state?.btcAddressTaproot);
const { onCopy } = useClipboard(state.btcAddressTaproot);

function copyToClipboard() {
void analytics.track('copy_address_to_add_new_inscription');
toast.success('Copied to clipboard!');
onCopy();
}

// #4028 FIXME - this doesn't open in new tab as it loses btcAddressTaproot amd crashes btcStamp and Stx are OK?
return (
<ReceiveTokensLayout
address={state.btcAddressTaproot}
Expand Down
7 changes: 5 additions & 2 deletions src/app/routes/hooks/use-background-location-redirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { RouteUrls } from '@shared/route-urls';

import { useLocationState } from '@app/common/hooks/use-location-state';

// If routes are accessed directly / opened in new tabs `backgroundLocation` is lost
// this hook re-directs the users to home then overlays the modal so the BG is the home route
/**
* If routes are accessed directly / opened in new tabs `backgroundLocation` is lost
* this hook re-directs the users to home then overlays the modal so the BG is the home route
*/

export function useBackgroundLocationRedirect(baseUrl = RouteUrls.Home) {
const { pathname, state } = useLocation();
const navigate = useNavigate();
Expand Down
5 changes: 0 additions & 5 deletions src/app/routes/receive-routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ export const receiveRoutes = (
<Route path={RouteUrls.ReceiveStx} element={<ReceiveStxModal />} />
<Route path={RouteUrls.ReceiveBtc} element={<ReceiveBtcModal />} />
<Route path={RouteUrls.ReceiveBtcStamp} element={<ReceiveBtcModal type="btc-stamp" />} />
{/* Needed to show receive ordinal in Receive flow */}

<Route path={RouteUrls.ReceiveCollectibleOrdinal} element={<ReceiveOrdinalModal />} />

{/* Needed to show receive ordinal in Add flow */}
<Route path={RouteUrls.ReceiveCollectible} element={<ReceiveModal type="collectible" />} />
<Route path={RouteUrls.ReceiveCollectibleOrdinal} element={<ReceiveOrdinalModal />} />
</Route>
Expand Down

0 comments on commit efb3843

Please sign in to comment.