Skip to content

Commit

Permalink
merge main and solve typescript errors and conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tommasini committed Sep 20, 2023
2 parents a0f8284 + 90224b7 commit 82b1663
Show file tree
Hide file tree
Showing 93 changed files with 7,589 additions and 2,134 deletions.
6 changes: 0 additions & 6 deletions app/actions/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ export function setGasEducationCarouselSeen() {
};
}

export function setNftDetectionDismissed() {
return {
type: 'SET_NFT_DETECTION_DISMISSED',
};
}

export function logIn() {
return {
type: LOGIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import {
TEST_REMOTE_IMAGE_SOURCE,
} from './AvatarToken.constants';

jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
useSelector: jest.fn(),
}));

describe('AvatarToken', () => {
/* eslint-disable-next-line */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { useStyles } from '../../../../../hooks';
import { AvatarTokenProps } from './AvatarToken.types';
import stylesheet from './AvatarToken.styles';
import { TOKEN_AVATAR_IMAGE_ID } from './AvatarToken.constants';
import { useSelector } from 'react-redux';
import { selectIsIpfsGatewayEnabled } from '../../../../../../selectors/preferencesController';
import { isIPFSUri } from '../../../../../../util/general';

const AvatarToken = ({
size,
Expand All @@ -28,6 +31,7 @@ const AvatarToken = ({
isHaloEnabled,
showFallback,
});
const isIpfsGatewayEnabled = useSelector(selectIsIpfsGatewayEnabled);

const textVariant =
size === AvatarSize.Sm || size === AvatarSize.Xs
Expand All @@ -37,9 +41,13 @@ const AvatarToken = ({

const onError = () => setShowFallback(true);

const isIpfsDisabledAndUriIsIpfs = imageSource
? !isIpfsGatewayEnabled && isIPFSUri(imageSource)
: false;

const tokenImage = () => (
<AvatarBase size={size} style={styles.base}>
{showFallback ? (
{showFallback || isIpfsDisabledAndUriIsIpfs ? (
<Text style={styles.label} variant={textVariant}>
{tokenNameFirstLetter}
</Text>
Expand All @@ -55,7 +63,7 @@ const AvatarToken = ({
</AvatarBase>
);

return !isHaloEnabled || showFallback ? (
return !isHaloEnabled || showFallback || isIpfsDisabledAndUriIsIpfs ? (
tokenImage()
) : (
<ImageBackground
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ const BannerBase: React.FC<BannerBaseProps> = ({
typeof title === 'string' ? (
<Text variant={DEFAULT_BANNERBASE_TITLE_TEXTVARIANT}>{title}</Text>
) : (
{ title }
title
);
const renderDescription = () =>
typeof description === 'string' ? (
<Text variant={DEFAULT_BANNERBASE_DESCRIPTION_TEXTVARIANT}>
{description}
</Text>
) : (
{ description }
description
);

return (
Expand Down
7 changes: 7 additions & 0 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ import { PPOMView } from '../../../lib/ppom/PPOMView';
import NavigationService from '../../../core/NavigationService';
import LockScreen from '../../Views/LockScreen';
import AsyncStorage from '../../../store/async-storage-wrapper';
import ShowNftSheet from '../../Views/ShowNFTSheet/ShowNFTSheet';
import ShowDisplayNftMediaSheet from '../../Views/ShowDisplayMediaNFTSheet/ShowDisplayNFTMediaSheet';

const clearStackNavigatorOptions = {
headerShown: false,
Expand Down Expand Up @@ -526,6 +528,11 @@ const App = ({ userLoggedIn }) => {
name={Routes.SHEET.ETH_SIGN_FRICTION}
component={EthSignFriction}
/>
<Stack.Screen name={Routes.SHEET.SHOW_NFT} component={ShowNftSheet} />
<Stack.Screen
name={Routes.SHEET.SHOW_NFT_DISPLAY_MEDIA}
component={ShowDisplayNftMediaSheet}
/>
</Stack.Navigator>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ exports[`ActionView should render correctly 1`] = `
},
]
}
disabled={false}
disabledContainerStyle={
Object {
"opacity": 0.6,
Expand Down
11 changes: 8 additions & 3 deletions app/components/UI/ActionView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default function ActionView({
showConfirmButton,
confirmed,
confirmDisabled,
loading = false,
keyboardShouldPersistTaps = 'never',
style = undefined,
}) {
Expand Down Expand Up @@ -91,12 +92,12 @@ export default function ActionView({
type={confirmButtonMode}
onPress={onConfirmPress}
containerStyle={[styles.button, styles.confirm]}
disabled={confirmed || confirmDisabled}
disabled={confirmed || confirmDisabled || loading}
>
{confirmed ? (
{confirmed || loading ? (
<ActivityIndicator
size="small"
color={colors.primary.inverse}
color={colors.primary.default}
/>
) : (
confirmText
Expand Down Expand Up @@ -174,6 +175,10 @@ ActionView.propTypes = {
* Whether confirm button is shown
*/
showConfirmButton: PropTypes.bool,
/**
* Loading after confirm
*/
loading: PropTypes.bool,
/**
* Determines if the keyboard should stay visible after a tap
*/
Expand Down
17 changes: 13 additions & 4 deletions app/components/UI/AddCustomCollectible/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const AddCustomCollectible = ({
const [inputWidth, setInputWidth] = useState<string | undefined>(
Device.isAndroid() ? '99%' : undefined,
);
const [loading, setLoading] = useState(false);
const assetTokenIdInput = React.createRef() as any;
const { colors, themeAppearance } = useTheme();
const styles = createStyles(colors);
Expand Down Expand Up @@ -175,8 +176,15 @@ const AddCustomCollectible = ({
};

const addNft = async (): Promise<void> => {
if (!(await validateCustomCollectible())) return;
if (!(await validateCollectibleOwnership())) return;
setLoading(true);
if (!(await validateCustomCollectible())) {
setLoading(false);
return;
}
if (!(await validateCollectibleOwnership())) {
setLoading(false);
return;
}

const { NftController } = Engine.context as any;
NftController.addNft(address, tokenId);
Expand All @@ -185,7 +193,7 @@ const AddCustomCollectible = ({
MetaMetricsEvents.COLLECTIBLE_ADDED,
getAnalyticsParams(),
);

setLoading(false);
navigation.goBack();
};

Expand Down Expand Up @@ -217,7 +225,8 @@ const AddCustomCollectible = ({
confirmText={strings('add_asset.collectibles.add_collectible')}
onCancelPress={cancelAddCollectible}
onConfirmPress={addNft}
confirmDisabled={!address && !tokenId}
confirmDisabled={!address || !tokenId}
loading={loading}
>
<View>
<View style={styles.rowWrapper}>
Expand Down
3 changes: 2 additions & 1 deletion app/components/UI/CollectibleContractElement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function CollectibleContractElement({
<CollectibleMedia
style={styles.collectibleIcon}
collectible={{ ...collectible, name }}
onPressColectible={onPress}
/>
</View>
</TouchableOpacity>
Expand Down Expand Up @@ -238,7 +239,7 @@ function CollectibleContractElement({
{collectiblesGrid.map((row, i) => (
<View key={i} style={styles.collectiblesRowContainer}>
{row.map((collectible, index) =>
renderCollectible(collectible, index),
renderCollectible({ ...collectible, logo: asset.logo }, index),
)}
</View>
))}
Expand Down
Loading

0 comments on commit 82b1663

Please sign in to comment.