Skip to content

Commit

Permalink
Fix: reported bugs (#281)
Browse files Browse the repository at this point in the history
* Remove unused icons

* Enable error logs

* Copy public key

* Remove argent mobile adapter

* Enable error logs

* Fix modal scroll
  • Loading branch information
ugur-eren authored Jul 24, 2024
1 parent e471854 commit 63b9ef2
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 109 deletions.
6 changes: 3 additions & 3 deletions JoyboyCommunity/src/app/StarknetProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@starknet-wc/react';
import {Platform} from 'react-native';

import {NETWORK_NAME, WALLET_CONNECT_ID} from '../constants/env';
import {NETWORK_NAME} from '../constants/env';
import {RpcProviderProvider} from '../context/RpcProvider';
import {WalletQRModal} from '../modules/WalletQRModal';
import {providers} from '../services/provider';
Expand All @@ -38,14 +38,14 @@ export const StarknetReactProvider: React.FC<React.PropsWithChildren> = ({childr
chains={[chain]}
provider={providers}
connectors={[
argentMobileConnector({
/* argentMobileConnector({
chain: NETWORK_NAME,
wcProjectId: WALLET_CONNECT_ID,
dappName: 'Joyboy',
description: 'Joyboy Starknet dApp',
url: 'https://joyboy.community',
provider,
}),
}), */

...(Platform.OS === 'web' ? injected : []),
]}
Expand Down
7 changes: 4 additions & 3 deletions JoyboyCommunity/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {SafeAreaView} from 'react-native-safe-area-context';

import {JoyboyIcon} from '../../assets/icons';
import {useStyles, useTheme} from '../../hooks';
import {IconButton} from '../IconButton';
import {Text} from '../Text';
import stylesheet from './styles';

Expand Down Expand Up @@ -39,11 +38,13 @@ export const Header: React.FC<HeaderProps> = ({showLogo = true, left, right, tit
</View>
)}

{right ?? (
{right}

{/* {right ?? (
<View style={styles.buttons}>
<IconButton icon="BellIcon" size={20} />
</View>
)}
)} */}
</View>
</SafeAreaView>
);
Expand Down
4 changes: 1 addition & 3 deletions JoyboyCommunity/src/modules/Post/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export const Post: React.FC<PostProps> = ({asComment, event}) => {
return {uri: imageTag[1], width: dimensions[0], height: dimensions[1]};
}, [event?.tags]);

// Animated style for the icon
const animatedIconStyle = useAnimatedStyle(() => ({
transform: [{scale: scale.value}],
}));
Expand All @@ -90,7 +89,6 @@ export const Post: React.FC<PostProps> = ({asComment, event}) => {
navigation.navigate('PostDetail', {postId: event?.id, post: event});
};

/** @TODO comment in Nostr */
const toggleLike = async () => {
if (!event?.id) return;

Expand Down Expand Up @@ -226,7 +224,7 @@ export const Post: React.FC<PostProps> = ({asComment, event}) => {
<IconButton icon="MoreHorizontalIcon" size={20} onPress={() => setMenuOpen(true)} />
}
>
<Menu.Item label="Share" icon="ShareIcon" />
{/* <Menu.Item label="Share" icon="ShareIcon" /> */}
<Menu.Item
label={profile?.username ? `Tip @${profile.username}` : 'Tip'}
icon="CoinIcon"
Expand Down
181 changes: 89 additions & 92 deletions JoyboyCommunity/src/modules/TipModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {NDKEvent} from '@nostr-dev-kit/ndk';
import {useAccount} from '@starknet-react/core';
import {forwardRef, useState} from 'react';
import {View} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import {CallData, uint256} from 'starknet';

import {Avatar, Button, Input, Modalize, Picker, Text} from '../../components';
Expand Down Expand Up @@ -115,111 +114,109 @@ export const TipModal = forwardRef<Modalize, TipModalProps>(
};

return (
<Modalize title="Tip" ref={ref} modalStyle={styles.modal}>
<SafeAreaView edges={['bottom', 'left', 'right']}>
<View style={styles.card}>
<View style={styles.cardHeader}>
<View style={styles.cardContent}>
<Avatar size={48} source={require('../../assets/joyboy-logo.png')} />

<View style={styles.cardInfo}>
<Text
fontSize={15}
color="text"
weight="bold"
numberOfLines={1}
ellipsizeMode="middle"
>
{profile?.displayName ?? profile?.name ?? event?.pubkey}
</Text>
<Modalize title="Tip" ref={ref} disableScrollIfPossible={false} modalStyle={styles.modal}>
<View style={styles.card}>
<View style={styles.cardHeader}>
<View style={styles.cardContent}>
<Avatar size={48} source={require('../../assets/joyboy-logo.png')} />

<View style={styles.cardInfo}>
<Text
fontSize={15}
color="text"
weight="bold"
numberOfLines={1}
ellipsizeMode="middle"
>
{profile?.displayName ?? profile?.name ?? event?.pubkey}
</Text>

{profile?.nip05 && (
<Text fontSize={11} color="textLight" weight="regular">
@{profile?.nip05}
</Text>
)}
</View>
{profile?.nip05 && (
<Text fontSize={11} color="textLight" weight="regular">
@{profile?.nip05}
</Text>
)}
</View>
</View>

<Text
fontSize={13}
weight="medium"
color="text"
numberOfLines={1}
ellipsizeMode="tail"
style={styles.cardContentText}
>
{event?.content}
</Text>
</View>

<View style={styles.pickerContainer}>
<View>
<Picker
label="Please select a token"
selectedValue={token}
onValueChange={(itemValue) => setToken(itemValue as TokenSymbol)}
>
{Object.values(TOKENS).map((tkn) => (
<Picker.Item
key={tkn[CHAIN_ID].symbol}
label={tkn[CHAIN_ID].name}
value={tkn[CHAIN_ID].symbol}
/>
))}
</Picker>
</View>

<Input value={amount} onChangeText={setAmount} placeholder="Amount" />
<Text
fontSize={13}
weight="medium"
color="text"
numberOfLines={1}
ellipsizeMode="tail"
style={styles.cardContentText}
>
{event?.content}
</Text>
</View>

<View style={styles.pickerContainer}>
<View>
<Picker
label="Please select a token"
selectedValue={token}
onValueChange={(itemValue) => setToken(itemValue as TokenSymbol)}
>
{Object.values(TOKENS).map((tkn) => (
<Picker.Item
key={tkn[CHAIN_ID].symbol}
label={tkn[CHAIN_ID].name}
value={tkn[CHAIN_ID].symbol}
/>
))}
</Picker>
</View>

<View style={styles.sending}>
<View style={styles.sendingText}>
<Text color="textSecondary" fontSize={16} weight="medium">
Sending
</Text>
<Input value={amount} onChangeText={setAmount} placeholder="Amount" />
</View>

{amount.length > 0 && token.length > 0 ? (
<Text color="primary" fontSize={16} weight="bold">
{amount} {token}
</Text>
) : (
<Text color="primary" fontSize={16} weight="bold">
...
</Text>
)}
</View>
<View style={styles.sending}>
<View style={styles.sendingText}>
<Text color="textSecondary" fontSize={16} weight="medium">
Sending
</Text>

<View style={styles.recipient}>
<Text fontSize={16} weight="regular">
to
{amount.length > 0 && token.length > 0 ? (
<Text color="primary" fontSize={16} weight="bold">
{amount} {token}
</Text>
<Text numberOfLines={1} ellipsizeMode="middle" fontSize={16} weight="medium">
{(profile?.nip05 && `@${profile.nip05}`) ??
profile?.displayName ??
profile?.name ??
event?.pubkey}
) : (
<Text color="primary" fontSize={16} weight="bold">
...
</Text>
</View>
)}
</View>

<View style={styles.submitButton}>
<Button variant="secondary" disabled={!isActive} onPress={onTipPress}>
Tip
</Button>
<View style={styles.recipient}>
<Text fontSize={16} weight="regular">
to
</Text>
<Text numberOfLines={1} ellipsizeMode="middle" fontSize={16} weight="medium">
{(profile?.nip05 && `@${profile.nip05}`) ??
profile?.displayName ??
profile?.name ??
event?.pubkey}
</Text>
</View>

<Text
weight="semiBold"
color="inputPlaceholder"
fontSize={13}
align="center"
style={styles.comment}
>
Tip friends and support creators with your favorite tokens.
</Text>
</SafeAreaView>
</View>

<View style={styles.submitButton}>
<Button variant="secondary" disabled={!isActive} onPress={onTipPress}>
Tip
</Button>
</View>

<Text
weight="semiBold"
color="inputPlaceholder"
fontSize={13}
align="center"
style={styles.comment}
>
Tip friends and support creators with your favorite tokens.
</Text>
</Modalize>
);
},
Expand Down
2 changes: 1 addition & 1 deletion JoyboyCommunity/src/screens/PostDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const PostDetail: React.FC<PostDetailScreenProps> = ({navigation, route})
<Header
showLogo={false}
left={<IconButton icon="ChevronLeftIcon" size={24} onPress={navigation.goBack} />}
right={<IconButton icon="MoreHorizontalIcon" size={24} />}
/* right={<IconButton icon="MoreHorizontalIcon" size={24} />} */
title="Conversation"
/>

Expand Down
23 changes: 17 additions & 6 deletions JoyboyCommunity/src/screens/Profile/Info/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useNavigation} from '@react-navigation/native';
import {useQueryClient} from '@tanstack/react-query';
import * as Clipboard from 'expo-clipboard';
import {useState} from 'react';
import {Pressable, View} from 'react-native';

Expand Down Expand Up @@ -58,6 +59,11 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
);
};

const handleCopyPublicKey = async () => {
await Clipboard.setStringAsync(userPublicKey);
showToast({type: 'info', title: 'Public key copied to the clipboard'});
};

return (
<View>
<ProfileHead
Expand All @@ -76,7 +82,7 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
Edit profile
</Button>

<Menu
{/* <Menu
open={menuOpen}
onClose={() => setMenuOpen(false)}
handle={
Expand All @@ -93,7 +99,7 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
icon="ShareIcon"
/>
<Menu.Item label="About" icon="InfoIconCircular" />
</Menu>
</Menu> */}
</>
) : (
<>
Expand All @@ -108,7 +114,7 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
{isConnected ? 'UnFollow' : 'Follow'}
</Button>

<IconButton icon="DoubleMessageIcon" size={20} style={styles.iconButton} />
{/* <IconButton icon="DoubleMessageIcon" size={20} style={styles.iconButton} /> */}

<Menu
open={menuOpen}
Expand All @@ -130,12 +136,12 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
setMenuOpen(false);
}}
/>
<Menu.Item
{/* <Menu.Item
label={profile?.username ? `Share @${profile.username}` : 'Share'}
icon="ShareIcon"
/>
<Menu.Item label="About" icon="InfoIconCircular" />
<Menu.Item label="Report user" icon="FlagIcon" />
<Menu.Item label="Report user" icon="FlagIcon" /> */}
</Menu>
</>
)
Expand Down Expand Up @@ -164,7 +170,12 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
{userPublicKey}
</Text>

<IconButton size={16} icon="CopyIconStack" color="primary" />
<IconButton
size={16}
icon="CopyIconStack"
color="primary"
onPress={handleCopyPublicKey}
/>
</Pressable>
</View>

Expand Down
2 changes: 2 additions & 0 deletions website/src/app/api/deposit/claim/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export async function POST(request: NextRequest) {
return NextResponse.json({transaction_hash}, {status: HTTPStatus.OK});
}
} catch (error) {
console.error(error);

return NextResponse.json(
{code: ErrorCode.TRANSACTION_ERROR, error},
{status: HTTPStatus.InternalServerError},
Expand Down
2 changes: 2 additions & 0 deletions website/src/app/api/deposit/estimate-claim/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ export async function POST(request: NextRequest) {
);
}
} catch (error) {
console.error(error);

return NextResponse.json(
{code: ErrorCode.ESTIMATION_ERROR, error},
{status: HTTPStatus.InternalServerError},
Expand Down
3 changes: 2 additions & 1 deletion website/src/app/api/file/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export async function POST(request: NextRequest) {
{status: HTTPStatus.OK},
);
} catch (error) {
console.log(error);
console.error(error);

return NextResponse.json(
{code: ErrorCode.TRANSACTION_ERROR, error},
{status: HTTPStatus.InternalServerError},
Expand Down

0 comments on commit 63b9ef2

Please sign in to comment.