Skip to content

Commit

Permalink
Applying Code Review
Browse files Browse the repository at this point in the history
  • Loading branch information
lauchaves authored and lauchaves committed Jul 25, 2024
1 parent 2f850a3 commit f6d1115
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
26 changes: 25 additions & 1 deletion JoyboyCommunity/src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import '@walletconnect/react-native-compat';

import {starknetChainId, useNetwork} from '@starknet-react/core';
import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import {useCallback, useEffect, useState} from 'react';
import {View} from 'react-native';

import {CHAIN_ID} from '../constants/env';
import {useTips} from '../hooks';
import {useToast} from '../hooks/modals';
import {useDialog, useToast} from '../hooks/modals';
import {Router} from './Router';

SplashScreen.preventAutoHideAsync();
Expand All @@ -18,6 +20,28 @@ export default function App() {
const tips = useTips();
const {showToast} = useToast();

const {showDialog, hideDialog} = useDialog();

const {chain} = useNetwork();

useEffect(() => {
debugger;

Check failure on line 28 in JoyboyCommunity/src/app/App.tsx

View workflow job for this annotation

GitHub Actions / check-app

Unexpected 'debugger' statement
const chainId = chain.id ? starknetChainId(chain.id) : undefined;

if (chainId) {
if (chainId !== CHAIN_ID) {
showDialog({
title: 'Wrong Network',
description:
'Joyboy currently only supports the Starknet Sepolia network. Please switch to the Sepolia network to continue.',
buttons: [],
});
} else {
hideDialog();
}
}
}, [chain.id]);

Check warning on line 43 in JoyboyCommunity/src/app/App.tsx

View workflow job for this annotation

GitHub Actions / check-app

React Hook useEffect has missing dependencies: 'hideDialog' and 'showDialog'. Either include them or remove the dependency array

useEffect(() => {
(async () => {
try {
Expand Down
25 changes: 2 additions & 23 deletions JoyboyCommunity/src/modules/TipModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {NDKEvent} from '@nostr-dev-kit/ndk';
import {mainnet, sepolia} from '@starknet-react/chains';
import {useAccount} from '@starknet-react/core';
import {forwardRef, useEffect, useState} from 'react';
import {forwardRef, useState} from 'react';
import {View} from 'react-native';
import {CallData, uint256} from 'starknet';

import {Avatar, Button, Input, Modalize, Picker, Text} from '../../components';
import {ESCROW_ADDRESSES} from '../../constants/contracts';
import {CHAIN_ID, NETWORK_NAME} from '../../constants/env';
import {CHAIN_ID} from '../../constants/env';
import {DEFAULT_TIMELOCK, Entrypoint} from '../../constants/misc';
import {TOKENS, TokenSymbol} from '../../constants/tokens';
import {useProfile, useStyles, useWaitConnection} from '../../hooks';
Expand Down Expand Up @@ -46,26 +45,6 @@ export const TipModal = forwardRef<Modalize, TipModalProps>(

const {showDialog, hideDialog} = useDialog();

useEffect(() => {
const handleChainIdChange = () => {
const chainId = account.chainId;
const currentChainId = NETWORK_NAME === 'SN_MAIN' ? mainnet.id : sepolia.id;

if (chainId === currentChainId) {
hideDialog();
} else if (chainId) {
showDialog({
title: 'Wrong Network',
description:
'Joyboy currently only supports the Starknet Sepolia network. Please switch to the Sepolia network to continue.',
buttons: [],
});
}
};

handleChainIdChange();
}, [account.chainId, hideDialog, showDialog]);

const isActive = !!amount && !!token;

const onTipPress = async () => {
Expand Down

0 comments on commit f6d1115

Please sign in to comment.