Skip to content

Commit 196ee0a

Browse files
committed
fix: show warning if user tryies to use slashpay and LDK is not ready yet
1 parent 37dd5ad commit 196ee0a

File tree

2 files changed

+36
-18
lines changed

2 files changed

+36
-18
lines changed

src/screens/Contacts/Contact.tsx

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1+
import Clipboard from '@react-native-clipboard/clipboard';
2+
import { parse } from '@synonymdev/slashtags-url';
13
import React, { ReactElement, useCallback, useMemo, useState } from 'react';
4+
import { useTranslation } from 'react-i18next';
25
import { ActivityIndicator, StyleSheet } from 'react-native';
3-
import { useAppDispatch, useAppSelector } from '../../hooks/redux';
46
import { FadeIn, FadeOut } from 'react-native-reanimated';
5-
import Clipboard from '@react-native-clipboard/clipboard';
67
import Share from 'react-native-share';
7-
import { useTranslation } from 'react-i18next';
8-
import { parse } from '@synonymdev/slashtags-url';
98

9+
import Dialog from '../../components/Dialog';
10+
import NavigationHeader from '../../components/NavigationHeader';
11+
import ProfileCard from '../../components/ProfileCard';
12+
import ProfileLinks from '../../components/ProfileLinks';
13+
import SafeAreaInset from '../../components/SafeAreaInset';
14+
import Tooltip from '../../components/Tooltip';
15+
import IconButton from '../../components/buttons/IconButton';
16+
import { useAppDispatch, useAppSelector } from '../../hooks/redux';
17+
import { useProfile } from '../../hooks/slashtags';
18+
import { useBalance } from '../../hooks/wallet';
19+
import { RootStackScreenProps } from '../../navigation/types';
20+
import { contactsSelector } from '../../store/reselect/slashtags';
21+
import { isLDKReadySelector } from '../../store/reselect/ui';
22+
import { selectedNetworkSelector } from '../../store/reselect/wallet';
23+
import { deleteContact } from '../../store/slices/slashtags';
1024
import { AnimatedView, View } from '../../styles/components';
1125
import {
1226
CoinsIcon,
@@ -15,22 +29,9 @@ import {
1529
ShareIcon,
1630
TrashIcon,
1731
} from '../../styles/icons';
18-
import NavigationHeader from '../../components/NavigationHeader';
19-
import SafeAreaInset from '../../components/SafeAreaInset';
20-
import ProfileCard from '../../components/ProfileCard';
21-
import ProfileLinks from '../../components/ProfileLinks';
22-
import { processUri } from '../../utils/scanner/scanner';
23-
import { useProfile } from '../../hooks/slashtags';
24-
import { useBalance } from '../../hooks/wallet';
2532
import { truncate } from '../../utils/helpers';
2633
import { showToast } from '../../utils/notifications';
27-
import { RootStackScreenProps } from '../../navigation/types';
28-
import Dialog from '../../components/Dialog';
29-
import Tooltip from '../../components/Tooltip';
30-
import IconButton from '../../components/buttons/IconButton';
31-
import { deleteContact } from '../../store/slices/slashtags';
32-
import { selectedNetworkSelector } from '../../store/reselect/wallet';
33-
import { contactsSelector } from '../../store/reselect/slashtags';
34+
import { processUri } from '../../utils/scanner/scanner';
3435

3536
const Contact = ({
3637
navigation,
@@ -46,6 +47,7 @@ const Contact = ({
4647
const dispatch = useAppDispatch();
4748
const selectedNetwork = useAppSelector(selectedNetworkSelector);
4849
const contacts = useAppSelector(contactsSelector);
50+
const isLDKReady = useAppSelector(isLDKReadySelector);
4951

5052
const { profile } = useProfile(url);
5153
const savedContact = useMemo(() => {
@@ -75,7 +77,20 @@ const Contact = ({
7577
}, [navigation, url, dispatch]);
7678

7779
const handleSend = async (): Promise<void> => {
80+
if (loading) {
81+
return;
82+
}
7883
setLoading(true);
84+
85+
// if LDK is not ready yet, show a toast warning that it might take a few seconds
86+
if (!isLDKReady) {
87+
showToast({
88+
type: 'info',
89+
title: t('contact_ldk_not_ready'),
90+
description: t('lightning:wait_text_top'),
91+
});
92+
}
93+
7994
const res = await processUri({
8095
uri: url,
8196
source: 'send',

src/utils/i18n/locales/en/slashtags.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
"contact_pay_error": {
5454
"string": "Unable To Pay Contact"
5555
},
56+
"contact_ldk_not_ready": {
57+
"string": "Lightning is not ready yet"
58+
},
5659
"contact_share": {
5760
"string": "Share Profile Key"
5861
},

0 commit comments

Comments
 (0)