Skip to content

Commit 2fa2580

Browse files
committed
fix: remove prop/args for specific stack. not needed
1 parent 0276b38 commit 2fa2580

8 files changed

Lines changed: 17 additions & 102 deletions

File tree

app/components/UI/Predict/components/PredictBalance/PredictBalance.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ import { PREDICT_BALANCE_TEST_IDS } from './PredictBalance.testIds';
4848
interface PredictBalanceProps {
4949
onLayout?: (height: number) => void;
5050
onDepositWalletWithdrawPress?: () => void;
51-
navigationStack?: string;
5251
}
5352

5453
const PredictBalance: React.FC<PredictBalanceProps> = ({
5554
onLayout,
5655
onDepositWalletWithdrawPress,
57-
navigationStack,
5856
}) => {
5957
const tw = useTailwind();
6058
const privacyMode = useSelector(selectPrivacyMode);
@@ -65,8 +63,8 @@ const PredictBalance: React.FC<PredictBalanceProps> = ({
6563

6664
const queryClient = useQueryClient();
6765
const { data: balance = 0, isLoading } = usePredictBalance();
68-
const { deposit, isDepositPending } = usePredictDeposit({ navigationStack });
69-
const { withdraw } = usePredictWithdraw({ navigationStack });
66+
const { deposit, isDepositPending } = usePredictDeposit();
67+
const { withdraw } = usePredictWithdraw();
7068
const { executeGuardedAction } = usePredictActionGuard({
7169
navigation,
7270
});

app/components/UI/Predict/components/PredictWorldCupMainFeedBanner/PredictWorldCupMainFeedBanner.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ const PredictWorldCupMainFeedBanner: React.FC<
7676
);
7777

7878
const handlePress = useCallback(() => {
79-
navigation.navigate(Routes.PREDICT.WORLD_CUP);
79+
navigation.navigate(Routes.PREDICT.ROOT, {
80+
screen: Routes.PREDICT.WORLD_CUP,
81+
});
8082
}, [navigation]);
8183

8284
if (!imageSource) {

app/components/UI/Predict/hooks/usePredictDeposit.test.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { usePredictDeposit } from './usePredictDeposit';
33
import Engine from '../../../../core/Engine';
44
import Logger from '../../../../util/Logger';
55
import { ConfirmationLoader } from '../../../Views/confirmations/components/confirm/confirm-component';
6+
import Routes from '../../../../constants/navigation/Routes';
67

78
const mockGoBack = jest.fn();
89
const mockNavigateToConfirmation = jest.fn();
@@ -155,43 +156,10 @@ describe('usePredictDeposit', () => {
155156
// Assert
156157
expect(mockNavigateToConfirmation).toHaveBeenCalledWith({
157158
loader: ConfirmationLoader.CustomAmount,
158-
stack: undefined,
159+
stack: Routes.PREDICT.ROOT,
159160
});
160161
});
161162

162-
it('passes navigationStack to navigateToConfirmation when provided', async () => {
163-
// Arrange
164-
const { result } = renderHook(() =>
165-
usePredictDeposit({ navigationStack: 'PredictStack' }),
166-
);
167-
168-
// Act
169-
await act(async () => {
170-
await result.current.deposit();
171-
});
172-
173-
// Assert
174-
expect(mockNavigateToConfirmation).toHaveBeenCalledWith({
175-
loader: ConfirmationLoader.CustomAmount,
176-
stack: 'PredictStack',
177-
});
178-
});
179-
180-
it('omits stack from navigateToConfirmation when navigationStack is not provided', async () => {
181-
// Arrange
182-
const { result } = renderHook(() => usePredictDeposit());
183-
184-
// Act
185-
await act(async () => {
186-
await result.current.deposit();
187-
});
188-
189-
// Assert
190-
expect(mockNavigateToConfirmation).toHaveBeenCalledWith(
191-
expect.objectContaining({ stack: undefined }),
192-
);
193-
});
194-
195163
it('calls depositWithConfirmation when deposit is called', async () => {
196164
// Arrange
197165
const { result } = renderHook(() => usePredictDeposit());

app/components/UI/Predict/hooks/usePredictDeposit.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Logger from '../../../../util/Logger';
66
import { useAppThemeFromContext } from '../../../../util/theme';
77
import { ConfirmationLoader } from '../../../Views/confirmations/components/confirm/confirm-component';
88
import { useConfirmNavigation } from '../../../Views/confirmations/hooks/useConfirmNavigation';
9+
import Routes from '../../../../constants/navigation/Routes';
910
import { PREDICT_CONSTANTS } from '../constants/errors';
1011
import { selectPredictPendingDepositByAddress } from '../selectors/predictController';
1112
import {
@@ -22,13 +23,7 @@ interface PredictDepositAnalyticsParams {
2223
analyticsProperties?: PlaceOrderParams['analyticsProperties'];
2324
}
2425

25-
interface UsePredictDepositOptions {
26-
navigationStack?: string;
27-
}
28-
29-
export const usePredictDeposit = ({
30-
navigationStack,
31-
}: UsePredictDepositOptions = {}) => {
26+
export const usePredictDeposit = () => {
3227
const { navigateToConfirmation } = useConfirmNavigation();
3328
const theme = useAppThemeFromContext();
3429
const { toastRef } = useContext(ToastContext);
@@ -52,7 +47,7 @@ export const usePredictDeposit = ({
5247
try {
5348
navigateToConfirmation({
5449
loader: ConfirmationLoader.CustomAmount,
55-
stack: navigationStack,
50+
stack: Routes.PREDICT.ROOT,
5651
});
5752

5853
depositWithConfirmation({}).catch((err) => {
@@ -103,7 +98,6 @@ export const usePredictDeposit = ({
10398
}
10499
},
105100
[
106-
navigationStack,
107101
depositWithConfirmation,
108102
navigateToConfirmation,
109103
navigation,

app/components/UI/Predict/hooks/usePredictWithdraw.test.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { renderHook } from '@testing-library/react-native';
22
import { usePredictWithdraw } from './usePredictWithdraw';
33
import { ConfirmationLoader } from '../../../Views/confirmations/components/confirm/confirm-component';
4+
import Routes from '../../../../constants/navigation/Routes';
45

56
import { POLYMARKET_PROVIDER_ID } from '../providers/polymarket/constants';
67
// Create mock functions
@@ -206,37 +207,10 @@ describe('usePredictWithdraw', () => {
206207

207208
expect(mockNavigateToConfirmation).toHaveBeenCalledWith({
208209
loader: ConfirmationLoader.CustomAmount,
209-
stack: undefined,
210+
stack: Routes.PREDICT.ROOT,
210211
});
211212
});
212213

213-
it('passes navigationStack to navigateToConfirmation when provided', async () => {
214-
mockPrepareWithdraw.mockResolvedValue({ success: true });
215-
216-
const { result } = renderHook(() =>
217-
usePredictWithdraw({ navigationStack: 'PredictStack' }),
218-
);
219-
220-
await result.current.withdraw();
221-
222-
expect(mockNavigateToConfirmation).toHaveBeenCalledWith({
223-
loader: ConfirmationLoader.CustomAmount,
224-
stack: 'PredictStack',
225-
});
226-
});
227-
228-
it('omits stack from navigateToConfirmation when navigationStack is not provided', async () => {
229-
mockPrepareWithdraw.mockResolvedValue({ success: true });
230-
231-
const { result } = setupUsePredictWithdrawTest();
232-
233-
await result.current.withdraw();
234-
235-
expect(mockNavigateToConfirmation).toHaveBeenCalledWith(
236-
expect.objectContaining({ stack: undefined }),
237-
);
238-
});
239-
240214
it('calls prepareWithdraw with empty options object', async () => {
241215
mockPrepareWithdraw.mockResolvedValue({ success: true });
242216

app/components/UI/Predict/hooks/usePredictWithdraw.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@ import {
1111
} from '../../../../component-library/components/Toast';
1212
import { strings } from '../../../../../locales/i18n';
1313
import { selectPredictWithdrawTransaction } from '../selectors/predictController';
14+
import Routes from '../../../../constants/navigation/Routes';
1415

15-
interface UsePredictWithdrawOptions {
16-
navigationStack?: string;
17-
}
18-
19-
export const usePredictWithdraw = ({
20-
navigationStack,
21-
}: UsePredictWithdrawOptions = {}) => {
16+
export const usePredictWithdraw = () => {
2217
const { prepareWithdraw } = usePredictTrading();
2318
const { navigateToConfirmation } = useConfirmNavigation();
2419
const navigation = useNavigation();
@@ -30,7 +25,7 @@ export const usePredictWithdraw = ({
3025
try {
3126
navigateToConfirmation({
3227
loader: ConfirmationLoader.CustomAmount,
33-
stack: navigationStack,
28+
stack: Routes.PREDICT.ROOT,
3429
});
3530

3631
const response = await prepareWithdraw({});
@@ -58,13 +53,7 @@ export const usePredictWithdraw = ({
5853

5954
console.error('Failed to proceed with withdraw:', err);
6055
}
61-
}, [
62-
navigationStack,
63-
navigateToConfirmation,
64-
navigation,
65-
prepareWithdraw,
66-
toastRef,
67-
]);
56+
}, [navigateToConfirmation, navigation, prepareWithdraw, toastRef]);
6857

6958
return { withdraw, withdrawTransaction };
7059
};

app/components/UI/Predict/views/PredictFeed/PredictFeed.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ const AnimatedFlashList = Animated.createAnimatedComponent(
101101

102102
const PredictFeedHeader: React.FC<{
103103
onDepositWalletWithdrawPress?: () => void;
104-
navigationStack?: string;
105-
}> = ({ onDepositWalletWithdrawPress, navigationStack }) => (
104+
}> = ({ onDepositWalletWithdrawPress }) => (
106105
<Box twClassName="py-4">
107106
<PredictBalance
108107
onDepositWalletWithdrawPress={onDepositWalletWithdrawPress}
109-
navigationStack={navigationStack}
110108
/>
111109
</Box>
112110
);
@@ -153,7 +151,6 @@ interface AnimatedHeaderProps {
153151
onHeaderLayout: (event: LayoutChangeEvent) => void;
154152
onTabBarLayout: (event: LayoutChangeEvent) => void;
155153
onDepositWalletWithdrawPress?: () => void;
156-
navigationStack?: string;
157154
}
158155

159156
const AnimatedHeader: React.FC<AnimatedHeaderProps> = ({
@@ -167,7 +164,6 @@ const AnimatedHeader: React.FC<AnimatedHeaderProps> = ({
167164
onHeaderLayout,
168165
onTabBarLayout,
169166
onDepositWalletWithdrawPress,
170-
navigationStack,
171167
}) => {
172168
const tw = useTailwind();
173169
const { colors } = useTheme();
@@ -207,7 +203,6 @@ const AnimatedHeader: React.FC<AnimatedHeaderProps> = ({
207203
>
208204
<PredictFeedHeader
209205
onDepositWalletWithdrawPress={onDepositWalletWithdrawPress}
210-
navigationStack={navigationStack}
211206
/>
212207
{isFeaturedCarouselEnabled && (
213208
<Box twClassName="pb-3">
@@ -625,15 +620,13 @@ interface PredictFeedProps {
625620
onHeaderHiddenChange?: (hidden: boolean) => void;
626621
walletHeaderTranslateY?: SharedValue<number>;
627622
walletHeaderHeight?: number;
628-
navigationStack?: string;
629623
}
630624

631625
const PredictFeed: React.FC<PredictFeedProps> = ({
632626
hideHeader = false,
633627
onHeaderHiddenChange,
634628
walletHeaderTranslateY,
635629
walletHeaderHeight,
636-
navigationStack,
637630
}) => {
638631
const { tabs, activeIndex, setActiveIndex, initialTabKey } = usePredictTabs();
639632

@@ -780,7 +773,6 @@ const PredictFeed: React.FC<PredictFeedProps> = ({
780773
onHeaderLayout={onHeaderLayout}
781774
onTabBarLayout={onTabBarLayout}
782775
onDepositWalletWithdrawPress={handleDepositWalletWithdrawPress}
783-
navigationStack={navigationStack}
784776
/>
785777

786778
{layoutReady && (

app/components/Views/Homepage/components/HomepageDiscoveryTabs/HomepageDiscoveryTabs.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
getStreamManagerInstance,
3232
} from '../../../../UI/Perps/providers/PerpsStreamManager';
3333
import { PredictPreviewSheetProvider } from '../../../../UI/Predict/contexts';
34-
import Routes from '../../../../../constants/navigation/Routes';
3534
import { SectionRefreshHandle } from '../../types';
3635
import { IconName } from '../../../../../component-library/components/Icons/Icon/Icon.types';
3736
import { useStyles } from '../../../../../component-library/hooks';
@@ -392,7 +391,6 @@ const HomepageDiscoveryTabs = forwardRef<
392391
walletHeaderTranslateY={walletHeaderTranslateY}
393392
walletHeaderHeight={walletHeaderHeight}
394393
onHeaderHiddenChange={animateIcons}
395-
navigationStack={Routes.PREDICT.ROOT}
396394
/>
397395
</PredictPreviewSheetProvider>
398396
</DiscoveryTabView>

0 commit comments

Comments
 (0)