Skip to content

Commit

Permalink
Merge pull request #543 from Psychedelic/fix-types
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
ignaciosantise authored Nov 23, 2022
2 parents faab6f7 + 2253b8f commit 322ddba
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 25 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ android {
applicationId "co.psychedelic.plug"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 26
versionCode 27
versionName "0.4.0"
resValue "string", "build_config_package", "co.psychedelic.plug"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
Expand Down
15 changes: 15 additions & 0 deletions patches/react-native+0.70.3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
index 6a343d8..474b2ec 100644
--- a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
+++ b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js
@@ -111,6 +111,10 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
this._initialFrameHeight = this._frame.height;
}

+ if (this.props.onLayout) {
+ event.persist();
+ }
+
if (wasFrameNull) {
await this._updateBottomIfNecessary();
}
7 changes: 3 additions & 4 deletions src/components/common/Toast/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { View } from 'react-native';
import { Pressable, View } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useToast } from 'react-native-toast-notifications';
Expand All @@ -12,7 +12,6 @@ import InfoIcon from '@/icons/svg/InfoIcon.svg';
import SuccessIcon from '@/icons/svg/SuccessIcon.svg';

import Text from '../Text';
import Touchable from '../Touchable';
import styles from './styles';

export enum ToastTypes {
Expand Down Expand Up @@ -61,9 +60,9 @@ function Toast({ title, message, type, id }: ToastProps) {
{title}
</Text>
</View>
<Touchable onPress={handleClose}>
<Pressable onPress={handleClose}>
<Close fill={Colors.White.Primary} height={20} />
</Touchable>
</Pressable>
</View>
{message && (
<Text type="caption" style={styles.message}>
Expand Down
8 changes: 8 additions & 0 deletions src/constants/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ export const ACTIVITY_TYPES = {
PLUG: 'PLUG',
BURN: 'BURN',
MINT: 'MINT',
TRANSFERFROM: 'TRANSFERFROM',
DIRECT_BUY: 'DIRECTBUY',
MAKE_LISTING: 'MAKELISTING',
CANCEL_LISTING: 'CANCELLISTING',
MAKE_OFFER: 'MAKEOFFER',
ACCEPT_OFFER: 'ACCEPTOFFER',
CANCEL_OFFER: 'CANCELOFFER',
DENY_OFFER: 'DENYOFFER',
};

export const ACTIVITY_STATUS = {
Expand Down
18 changes: 10 additions & 8 deletions src/redux/slices/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export const addCustomToken = createAsyncThunk<
logo,
});

const assets = [
const assets: Asset[] = [
...user.assets,
formatAsset(registeredToken, icp.icpPrice),
];
Expand Down Expand Up @@ -465,17 +465,19 @@ export const addCustomCollection = createAsyncThunk<
const state = getState();
const instance = KeyRing.getInstance();
try {
const registeredCollection = recursiveParseBigint(
await instance?.registerNFT(nft)
const isAlreadyAdded = !!state.user.collections.find(
collection => collection.canisterId === nft.canisterId
);

const totalCollections = [
...state.user.collections,
registeredCollection,
] as Collection[];
if (isAlreadyAdded) {
onFailure('The NFT is already registered');
return state.user.collections;
}

const nfts = await instance.getNFTs({ refresh: true });

onSuccess();
return totalCollections;
return (nfts || []).map(item => recursiveParseBigint(item));
} catch (e: any) {
onFailure(e.message);
console.log('Error while adding custom collection:', e);
Expand Down
5 changes: 4 additions & 1 deletion src/screens/tabs/Profile/modals/Accounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ function Accounts({ modalRef }: Props) {
};

const renderAccountItem = (account: Wallet, index: number) => {
const isSelectedAccount = currentWallet?.principal === account.principal;
const isSelectedAccount =
currentWallet?.principal === account.principal &&
currentWallet?.type === account.type;

const handleOpenAccountOptions = () => openAccountOptions(account);

const selectedAccountProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/screens/tabs/Profile/modals/ActivityDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import useCustomToast from '@/hooks/useCustomToast';
import { Contact, Transaction } from '@/interfaces/redux';
import { useAppSelector } from '@/redux/hooks';
import ActivityItem from '@/screens/tabs/components/ActivityItem';
import { getTransactionDetailType } from '@/screens/tabs/components/utils';
import { isOwnAddress, validateICNSName } from '@/utils/ids';
import shortAddress from '@/utils/shortAddress';
import { capitalize } from '@/utils/strings';

import styles from './styles';

Expand Down Expand Up @@ -55,7 +55,7 @@ function ActivityDetail({ modalRef, activity, onClosed }: Props) {
? [
{
title: t('activity.details.trxType'),
value: capitalize(activity.type?.toLocaleLowerCase()),
value: getTransactionDetailType(activity.type),
},
{
title: t('activity.details.from'),
Expand Down
2 changes: 1 addition & 1 deletion src/screens/tabs/Profile/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const getPemImportError = (error: string) => {
case 'invalid-key':
return t('createImportAccount.invalidKey');
case 'added-account':
return t('createImportAccount.addedAccount');
return t('createImportAccount.alreadyImported');
default:
return t('createImportAccount.importError');
}
Expand Down
28 changes: 21 additions & 7 deletions src/screens/tabs/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const getTypeIcon = type => {
case ACTIVITY_TYPES.BURN:
return ACTIVITY_IMAGES.BURN;
case ACTIVITY_TYPES.SEND:
case ACTIVITY_TYPES.TRANSFERFROM:
return ACTIVITY_IMAGES.SEND;
case ACTIVITY_TYPES.MINT:
return ACTIVITY_IMAGES.MINT;
Expand All @@ -39,22 +40,35 @@ export const getTypeIcon = type => {
}
};

export const getTransactionDetailType = type => {
switch (type) {
case ACTIVITY_TYPES.RECEIVE:
case ACTIVITY_TYPES.SEND:
case ACTIVITY_TYPES.TRANSFERFROM:
return t('transactionTypes.transfer');
default:
return `${capitalize(type?.toLowerCase())}`;
}
};

export const getTitle = (type, symbol) => {
switch (type) {
case 'DIRECTBUY':
case ACTIVITY_TYPES.DIRECT_BUY:
return t('transactionTypes.buyNTF');
case 'MAKELISTING':
case ACTIVITY_TYPES.MAKE_LISTING:
return t('transactionTypes.listNFT');
case 'CANCELLISTING':
case ACTIVITY_TYPES.CANCEL_LISTING:
return t('transactionTypes.cancelListingNFT');
case 'MAKEOFFER':
case ACTIVITY_TYPES.MAKE_OFFER:
return t('transactionTypes.makeOfferNFT');
case 'ACCEPTOFFER':
case ACTIVITY_TYPES.ACCEPT_OFFER:
return t('transactionTypes.acceptOfferNFT');
case 'CANCELOFFER':
case ACTIVITY_TYPES.CANCEL_OFFER:
return t('transactionTypes.cancelOfferNFT');
case 'DENYOFFER':
case ACTIVITY_TYPES.DENY_OFFER:
return t('transactionTypes.denyOfferNFT');
case ACTIVITY_TYPES.TRANSFERFROM:
return `${t('transactionTypes.send')} ${symbol ?? ''}`;
default:
if (type.includes('Liquidity')) {
return type;
Expand Down
4 changes: 3 additions & 1 deletion src/translations/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const translations = {
acceptOfferNFT: 'Accept Offer',
cancelOfferNFT: 'Cancel Offer',
denyOfferNFT: 'Deny Offer',
transfer: 'Transfer',
send: 'Send',
},
reviewSend: {
to: 'To',
Expand Down Expand Up @@ -344,7 +346,7 @@ const translations = {
importPem: 'PEM File',
create: 'Create',
invalidKey: 'Invalid key. Please, try again.',
addedAccount: 'Account already added.',
alreadyImported: 'This account is already imported',
importError:
'There was an error while importing the account. Please try again.',
},
Expand Down

0 comments on commit 322ddba

Please sign in to comment.