Skip to content

Commit b414bae

Browse files
committed
[Issue 3062] [fix] Extension - Unable to back screen in case open General settings to Marketing campaign #9
1 parent 19bc553 commit b414bae

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

packages/extension-koni-ui/src/Popup/Home/Nfts/NftCollectionDetail.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const subHeaderRightButton = <Icon
3333
/>;
3434

3535
function Component ({ className = '' }: Props): React.ReactElement<Props> {
36-
const location = useLocation();
37-
const { collectionInfo, nftList } = location.state as INftCollectionDetail;
36+
const state = useLocation().state as INftCollectionDetail;
37+
const { collectionInfo, nftList } = state;
3838

3939
const { t } = useTranslation();
4040
const navigate = useNavigate();
@@ -67,8 +67,8 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
6767
}, []);
6868

6969
const handleOnClickNft = useCallback((state: INftItemDetail) => {
70-
navigate('/home/nfts/item-detail', { state });
71-
}, [navigate]);
70+
navigate('/home/nfts/item-detail', { state: { ...state, nftList } });
71+
}, [navigate, nftList]);
7272

7373
const renderNft = useCallback((nftItem: NftItem) => {
7474
const routingParams = { collectionInfo, nftItem } as INftItemDetail;

packages/extension-koni-ui/src/Popup/Home/Nfts/NftItemDetail.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ const modalCloseButton = <Icon
3838
type='phosphor'
3939
weight={'light'}
4040
/>;
41+
const collectionNFTUrl = '/home/nfts/collection-detail';
4142

4243
function Component ({ className = '' }: Props): React.ReactElement<Props> {
43-
const location = useLocation();
44-
const { collectionInfo, nftItem } = location.state as INftItemDetail;
44+
const state = useLocation().state as INftItemDetail;
45+
const { collectionInfo, nftItem } = state;
4546

4647
const { t } = useTranslation();
4748
const notify = useNotification();
@@ -183,6 +184,10 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
183184
}
184185
}, [nftItem.externalUrl]);
185186

187+
const goBackToNFTCollection = useCallback(() => {
188+
goBack(collectionNFTUrl, state);
189+
}, [goBack, state]);
190+
186191
const show3DModel = SHOW_3D_MODELS_CHAIN.includes(nftItem.chain);
187192

188193
return (
@@ -191,7 +196,7 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
191196
resolve={dataContext.awaitStores(['nft', 'accountState', 'chainStore'])}
192197
>
193198
<Layout.Base
194-
onBack={goBack}
199+
onBack={goBackToNFTCollection}
195200
showBackButton={true}
196201
showSubHeader={true}
197202
subHeaderBackground={'transparent'}

packages/extension-koni-ui/src/Popup/Settings/Tokens/TokenDetail.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,18 @@ function Component ({ className = '' }: Props): React.ReactElement<Props> {
179179
});
180180
}, [goBack, priceId, showNotification, t, tokenInfo]);
181181

182+
const goBackToSettingList = useCallback(() => {
183+
goBack();
184+
}, [goBack]);
185+
182186
const leftFooterButtonProps = useCallback(() => {
183187
return _isCustomAsset(tokenInfo.slug)
184188
? {
185-
onClick: goBack,
189+
onClick: goBackToSettingList,
186190
children: t('Cancel')
187191
}
188192
: undefined;
189-
}, [goBack, tokenInfo.slug, t]);
193+
}, [goBackToSettingList, tokenInfo.slug, t]);
190194

191195
const rightFooterButtonProps = useCallback(() => {
192196
return _isCustomAsset(tokenInfo.slug)

packages/extension-koni-ui/src/hooks/router/useDefaultNavigate.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export default function useDefaultNavigate () {
2121
);
2222

2323
const goBack = useCallback(
24-
() => {
25-
navigate(RouteState.prevDifferentPathNum);
24+
(urlToBack?: string, state?: unknown) => {
25+
typeof urlToBack === 'string' ? navigate(urlToBack, { state }) : navigate(RouteState.prevDifferentPathNum);
2626
},
2727
[navigate]
2828
);

0 commit comments

Comments
 (0)