Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions e2e/slashtags.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ d('Profile and Contacts', () => {
await element(by.id('ProfileAddLink')).tap();

await element(by.id('LinkLabelInput')).typeText('LINK-LABEL');
await sleep(300); // wait for keyboard
await element(by.id('LinkValueInput')).typeText('link-value');
await sleep(300); // wait for keyboard
await element(by.id('SaveLink')).tap();
await waitFor(element(by.id('SaveLink'))).not.toBeVisible();
await expect(element(by.text('LINK-LABEL'))).toExist();
Expand Down Expand Up @@ -137,6 +139,13 @@ d('Profile and Contacts', () => {
.withTimeout(30000);
await expect(element(by.text(satoshi.name))).toExist();
await expect(element(by.text(satoshi.bio))).toExist();

// Android: keyboard is not dismissed after adding contact in e2e
if (device.getPlatform() === 'android') {
await element(by.id('NameInput')).tapReturnKey();
await sleep(300); // wait for keyboard to hide
}

await element(by.id('SaveContactButton')).tap();
await expect(element(by.text('WEBSITE'))).toExist();
await expect(element(by.text(satoshi.website))).toExist();
Expand All @@ -152,6 +161,14 @@ d('Profile and Contacts', () => {
.withTimeout(30000);
await expect(element(by.text(hal.name1))).toExist();
await element(by.id('NameInput')).replaceText(hal.name2);
await sleep(300); // wait for keyboard to hide

// Android: keyboard is not dismissed after adding contact in e2e
if (device.getPlatform() === 'android') {
await element(by.id('NameInput')).tapReturnKey();
await sleep(300); // wait for keyboard to hide
}

await element(by.id('SaveContactButton')).tap();
await expect(element(by.text(hal.name2.toUpperCase()))).toExist();
await element(by.id('NavigationClose')).tap();
Expand Down
13 changes: 6 additions & 7 deletions src/components/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import type { RootNavigationProp } from '../navigation/types';
import { useSheetRef } from '../sheets/SheetRefsProvider';
import { resetSendTransaction } from '../store/actions/wallet';
import { spendingOnboardingSelector } from '../store/reselect/aggregations';
import { showSheet } from '../store/utils/ui';
import { ScanIcon } from '../styles/icons';
import ButtonBlur from './buttons/ButtonBlur';

Expand All @@ -34,13 +33,13 @@ const TabBar = (): ReactElement => {

const onReceivePress = (): void => {
const currentRoute = rootNavigation.getCurrentRoute();
const screen =
// if we are on the spending screen and the user has not yet received funds
currentRoute === 'ActivitySpending' && isSpendingOnboarding
? 'ReceiveAmount'
: 'ReceiveQR';

// if we are on the spending screen and the user has not yet received funds
if (currentRoute === 'ActivitySpending' && isSpendingOnboarding) {
showSheet('receive', { screen: 'ReceiveAmount' });
} else {
receiveSheetRef.current?.present();
}
receiveSheetRef.current?.present({ screen });
};

const onSendPress = (): void => {
Expand Down
28 changes: 5 additions & 23 deletions src/components/Widgets.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { useFocusEffect } from '@react-navigation/native';
import { useNavigation } from '@react-navigation/native';
import React, {
ReactElement,
memo,
useCallback,
useMemo,
useState,
} from 'react';
import React, { ReactElement, memo, useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { StyleSheet } from 'react-native';
import DraggableFlatList, {
Expand Down Expand Up @@ -52,18 +46,6 @@ const Widgets = (): ReactElement => {

useFocusEffect(useCallback(() => setEditing(false), []));

const sortedWidgets = useMemo(() => {
const savedWidgets = Object.keys(widgets);

const sorted = savedWidgets.sort((a, b) => {
const indexA = sortOrder.indexOf(a);
const indexB = sortOrder.indexOf(b);
return indexA - indexB;
});

return sorted;
}, [widgets, sortOrder]);

const onDragEnd = useCallback(
({ data }) => {
const order = data.map((id): string => id);
Expand All @@ -83,7 +65,7 @@ const Widgets = (): ReactElement => {
({ item: id, drag }: RenderItemParams<string>): ReactElement => {
const initiateDrag = (): void => {
// only allow dragging if there are more than 1 widget
if (sortedWidgets.length > 1 && editing) {
if (sortOrder.length > 1 && editing) {
drag();
}
};
Expand Down Expand Up @@ -168,14 +150,14 @@ const Widgets = (): ReactElement => {
/>
);
},
[editing, widgets, sortedWidgets.length],
[editing, widgets, sortOrder.length],
);

return (
<View style={styles.root}>
<View style={styles.title} testID="WidgetsTitle">
<Caption13Up color="secondary">{t('widgets')}</Caption13Up>
{sortedWidgets.length > 0 && (
{sortOrder.length > 0 && (
<TouchableOpacity
hitSlop={{ top: 15, right: 15, bottom: 15, left: 15 }}
testID="WidgetsEdit"
Expand All @@ -190,7 +172,7 @@ const Widgets = (): ReactElement => {
</View>

<DraggableFlatList
data={sortedWidgets}
data={sortOrder}
keyExtractor={(id): string => id}
renderItem={(params): ReactElement => (
<ScaleDecorator>{renderItem(params)}</ScaleDecorator>
Expand Down
3 changes: 2 additions & 1 deletion src/components/widgets/edit/FactsItems.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { TFactsWidgetOptions } from '../../../store/types/widgets';
import { BodySSB, Title } from '../../../styles/text';
Expand All @@ -6,7 +7,7 @@ import { EWidgetItemType, TWidgetItem } from './types';

export const getFactsItems = (options: TFactsWidgetOptions): TWidgetItem[] => {
const { t } = useTranslation('widgets');
const fact = getRandomFact();
const fact = useMemo(() => getRandomFact(), []);

return [
{
Expand Down
12 changes: 8 additions & 4 deletions src/screens/Activity/ActivityDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import type {
RootNavigationProp,
RootStackScreenProps,
} from '../../navigation/types';
import { useSheetRef } from '../../sheets/SheetRefsProvider';
import {
activityItemSelector,
activityItemsSelector,
Expand All @@ -85,7 +86,6 @@ import {
deleteMetaTxTag,
} from '../../store/slices/metadata';
import { ETransferStatus } from '../../store/types/wallet';
import { showSheet } from '../../store/utils/ui';
import { getBoostedTransactionParents } from '../../utils/boost';
import {
ellipsis,
Expand Down Expand Up @@ -159,6 +159,8 @@ const OnchainActivityDetail = ({
const { wallet } = useOnchainWallet();
const { t } = useTranslation('wallet');
const { t: tTime } = useTranslation('intl', { i18n: i18nTime });
const boostSheetRef = useSheetRef('boost');
const activityTagsSheetRef = useSheetRef('activityTags');
const switchUnit = useSwitchUnit();
const dispatch = useAppDispatch();
const contacts = useAppSelector(contactsSelector);
Expand Down Expand Up @@ -235,11 +237,11 @@ const OnchainActivityDetail = ({
};

const handleBoost = (): void => {
showSheet('boost', { activityItem: item });
boostSheetRef.current?.present({ activityItem: item });
};

const handleAddTag = (): void => {
showSheet('activityTags', { id });
activityTagsSheetRef.current?.present({ id });
};

const handleRemoveTag = (tag: string): void => {
Expand Down Expand Up @@ -678,8 +680,10 @@ const LightningActivityDetail = ({
}): ReactElement => {
const { t } = useTranslation('wallet');
const { t: tTime } = useTranslation('intl', { i18n: i18nTime });
const activityTagsSheetRef = useSheetRef('activityTags');
const switchUnit = useSwitchUnit();
const colors = useColors();

const {
id,
txType,
Expand All @@ -700,7 +704,7 @@ const LightningActivityDetail = ({
});

const handleAddTag = (): void => {
showSheet('activityTags', { id });
activityTagsSheetRef.current?.present({ id });
};

const handleRemoveTag = (tag: string): void => {
Expand Down
8 changes: 1 addition & 7 deletions src/screens/Contacts/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { useBalance } from '../../hooks/wallet';
import { RootStackScreenProps } from '../../navigation/types';
import { contactsSelector } from '../../store/reselect/slashtags';
import { isLDKReadySelector } from '../../store/reselect/ui';
import { selectedNetworkSelector } from '../../store/reselect/wallet';
import { deleteContact } from '../../store/slices/slashtags';
import { AnimatedView, View } from '../../styles/components';
import {
Expand All @@ -45,7 +44,6 @@ const Contact = ({
const [loading, setLoading] = useState(false);

const dispatch = useAppDispatch();
const selectedNetwork = useAppSelector(selectedNetworkSelector);
const contacts = useAppSelector(contactsSelector);
const isLDKReady = useAppSelector(isLDKReadySelector);

Expand Down Expand Up @@ -91,11 +89,7 @@ const Contact = ({
});
}

const res = await processUri({
uri: url,
source: 'send',
selectedNetwork,
});
const res = await processUri({ uri: url });
setLoading(false);
if (res.isOk()) {
navigation.popToTop();
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Settings/AddressViewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { updateWallet } from '../../../store/slices/wallet';
import { TWalletName } from '../../../store/types/wallet';
import { updateActivityList } from '../../../store/utils/activity';
import { updateOnchainFeeEstimates } from '../../../store/utils/fees';
import { showSheet } from '../../../store/utils/ui';
import {
View as ThemedView,
TouchableOpacity,
Expand Down Expand Up @@ -620,6 +619,7 @@ const AddressViewer = (): ReactElement => {
* The on-chain transaction will retrieve and include the app's receiving address by default.
* Finally, this method will prompt the sendNavigation modal to appear for the user to finalize and confirm the transaction.
*/
// biome-ignore lint/correctness/useExhaustiveDependencies: sheetRef doesn't change
const onSpendFundsPress = useCallback(
async (utxosLength, selectedUtxosLength): Promise<void> => {
if (utxosLength <= 0) {
Expand Down Expand Up @@ -649,7 +649,7 @@ const AddressViewer = (): ReactElement => {
}),
);
sendMax();
showSheet('send', { screen: 'ReviewAndSend' });
sendSheetRef.current?.present({ screen: 'ReviewAndSend' });
},
[selectedUtxos, utxos, selectedNetwork, dispatch],
);
Expand Down
9 changes: 5 additions & 4 deletions src/screens/Settings/Security/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import React, { memo, ReactElement, useMemo, useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { StyleSheet } from 'react-native';

import { View as ThemedView } from '../../../styles/components';

import { IsSensorAvailableResult } from '../../../components/Biometrics';
import { EItemType, IListData } from '../../../components/List';
import { useAppDispatch, useAppSelector } from '../../../hooks/redux';
import type { SettingsScreenProps } from '../../../navigation/types';
import { useSheetRef } from '../../../sheets/SheetRefsProvider';
import { updateSettings } from '../../../store/slices/settings';
import { showSheet } from '../../../store/utils/ui';
import { View as ThemedView } from '../../../styles/components';
import rnBiometrics from '../../../utils/biometrics';
import SettingsView from '../SettingsView';

Expand All @@ -18,6 +17,7 @@ const SecuritySettings = ({
}: SettingsScreenProps<'SecuritySettings'>): ReactElement => {
const { t } = useTranslation('settings');
const dispatch = useAppDispatch();
const pinSheetRef = useSheetRef('pinNavigation');
const [biometryData, setBiometricData] = useState<IsSensorAvailableResult>();
const {
enableAutoReadClipboard,
Expand Down Expand Up @@ -53,6 +53,7 @@ const SecuritySettings = ({
? t('security.footer', { biometryTypeName })
: undefined;

// biome-ignore lint/correctness/useExhaustiveDependencies: sheetRef doesn't change
const settingsListData: IListData[] = useMemo(
() => [
{
Expand Down Expand Up @@ -119,7 +120,7 @@ const SecuritySettings = ({
if (pin) {
navigation.navigate('DisablePin');
} else {
showSheet('pinNavigation', { showLaterButton: false });
pinSheetRef.current?.present({ showLaterButton: false });
}
},
},
Expand Down
7 changes: 4 additions & 3 deletions src/screens/Transfer/Funding.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { ReactElement } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { StyleSheet, View } from 'react-native';
import { useAppSelector } from '../../hooks/redux';

import NavigationHeader from '../../components/NavigationHeader';
import SafeAreaInset from '../../components/SafeAreaInset';
import RectangleButton from '../../components/buttons/RectangleButton';
import { useAppSelector } from '../../hooks/redux';
import { useBalance } from '../../hooks/wallet';
import type { TransferScreenProps } from '../../navigation/types';
import { useSheetRef } from '../../sheets/SheetRefsProvider';
import { spendingIntroSeenSelector } from '../../store/reselect/settings';
import { isGeoBlockedSelector } from '../../store/reselect/user';
import { showSheet } from '../../store/utils/ui';
import { View as ThemedView } from '../../styles/components';
import { QrIcon, ShareAndroidIcon, TransferIcon } from '../../styles/icons';
import { BodyM, Display } from '../../styles/text';
Expand All @@ -21,6 +21,7 @@ const Funding = ({
}: TransferScreenProps<'Funding'>): ReactElement => {
const { t } = useTranslation('lightning');
const { onchainBalance } = useBalance();
const receiveSheetRef = useSheetRef('receive');
const isGeoBlocked = useAppSelector(isGeoBlockedSelector);
const spendingIntroSeen = useAppSelector(spendingIntroSeenSelector);

Expand All @@ -34,7 +35,7 @@ const Funding = ({

const onFund = (): void => {
navigation.popTo('Wallet', { screen: 'Home' });
showSheet('receive', { screen: 'ReceiveAmount' });
receiveSheetRef.current?.present({ screen: 'ReceiveAmount' });
};

const onAdvanced = (): void => {
Expand Down
15 changes: 8 additions & 7 deletions src/screens/Wallets/Receive/ReceiveDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { ReactElement, memo, useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Image, StyleSheet, View } from 'react-native';
import { FadeIn, FadeOut } from 'react-native-reanimated';
import { Image, Platform, StyleSheet, View } from 'react-native';
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';

import BottomSheetNavigationHeader from '../../../components/BottomSheetNavigationHeader';
import GradientView from '../../../components/GradientView';
Expand All @@ -27,7 +27,7 @@ import {
updatePendingInvoice,
} from '../../../store/slices/metadata';
import { removeInvoiceTag, updateInvoice } from '../../../store/slices/receive';
import { AnimatedView, BottomSheetTextInput } from '../../../styles/components';
import { BottomSheetTextInput } from '../../../styles/components';
import { TagIcon } from '../../../styles/icons';
import { Caption13Up } from '../../../styles/text';
import { estimateOrderFee } from '../../../utils/blocktank';
Expand Down Expand Up @@ -174,11 +174,12 @@ const ReceiveDetails = ({
</View>

{!keyboardShown && (
<AnimatedView
<Animated.View
style={styles.bottom}
color="transparent"
entering={FadeIn}
exiting={FadeOut}>
// FadeOut causing a bug on Android
exiting={Platform.OS === 'ios' ? FadeOut : undefined}
>
<Caption13Up style={styles.label} color="secondary">
{t('tags')}
</Caption13Up>
Expand Down Expand Up @@ -209,7 +210,7 @@ const ReceiveDetails = ({
<Image style={styles.image} source={imageSrc} />
</View>
)}
</AnimatedView>
</Animated.View>
)}

<View style={styles.buttonContainer}>
Expand Down
2 changes: 1 addition & 1 deletion src/sheets/AddContact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const AddContact = ({
};

const onSuccess = async (): Promise<void> => {
navigation.navigate('ContactEdit', { url });
navigation.navigate('ContactEdit', { url: contactUrl });
setUrl('');
};

Expand Down
Loading