Skip to content

Commit

Permalink
BlueWallet LndHub.io warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Mar 11, 2023
1 parent 560612b commit 2f6f81c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 27 deletions.
26 changes: 26 additions & 0 deletions components/BlueWalletWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { View } from 'react-native';
import { ErrorMessage } from './SuccessErrorMessage';
import stores from '../stores/Stores';
import { localeString } from '../utils/LocaleUtils';

export default function BlueWalletWarning() {
const SettingsStore = stores.settingsStore;
const node: any =
SettingsStore.settings.nodes &&
SettingsStore.settings.nodes[SettingsStore.settings.selectedNode || 0];
const isLndHubIo =
node.implementation === 'lndhub' &&
(node.lndhubUrl.includes('https://lndhub.io') ||
node.lndhubUrl.includes('https://lndhub.herokuapp.com'));

if (!isLndHubIo) return;
return (
<View style={{ width: '100%', paddingLeft: 15, paddingRight: 15 }}>
<ErrorMessage
message={localeString('components.BlueWalletWarning.warning')}
link="https://bluewallet.io/sunsetting-lndhub/"
fontSize={15}
/>
</View>
);
}
45 changes: 26 additions & 19 deletions components/LayerBalances/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import UnitsStore from './../../stores/UnitsStore';
import BackendUtils from '../../utils/BackendUtils';
import { themeColor } from './../../utils/ThemeUtils';

import BlueWalletWarning from '../../components/BlueWalletWarning';

import OnChainSvg from '../../assets/images/SVG/DynamicSVG/OnChainSvg';
import LightningSvg from '../../assets/images/SVG/DynamicSVG/LightningSvg';

Expand Down Expand Up @@ -126,25 +128,30 @@ export default class LayerBalances extends Component<LayerBalancesProps, {}> {
}

return (
<FlatList
data={DATA}
ItemSeparatorComponent={() => <View style={styles.separator} />}
renderItem={({ item, index }) => (
<SwipeableRow
item={item}
index={index}
navigation={navigation}
// select pay method vars
value={value}
amount={amount}
lightning={lightning}
/>
)}
keyExtractor={(_item, index) => `message ${index}`}
style={{ top: 20 }}
onRefresh={() => onRefresh()}
refreshing={false}
/>
<>
<BlueWalletWarning />
<FlatList
data={DATA}
ItemSeparatorComponent={() => (
<View style={styles.separator} />
)}
renderItem={({ item, index }) => (
<SwipeableRow
item={item}
index={index}
navigation={navigation}
// select pay method vars
value={value}
amount={amount}
lightning={lightning}
/>
)}
keyExtractor={(_item, index) => `message ${index}`}
style={{ top: 20 }}
onRefresh={() => onRefresh()}
refreshing={false}
/>
</>
);
}
}
Expand Down
47 changes: 39 additions & 8 deletions components/SuccessErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,57 @@
import * as React from 'react';
import { StyleSheet, Text } from 'react-native';
import { StyleSheet, Text, TouchableOpacity } from 'react-native';
import UrlUtils from '../utils/UrlUtils';

interface MessageProps {
message?: string;
fontSize?: number;
link: string;
mainStyle: any;
}

const SuccessMessage = (props: MessageProps) => (
<Text style={[styles.field, styles.successField]}>{props.message}</Text>
const Message = ({ message, fontSize, link, mainStyle }: MessageProps) =>
link ? (
<TouchableOpacity onPress={() => UrlUtils.goToUrl(link)}>
<Text
style={[styles.field, mainStyle, { fontSize: fontSize || 20 }]}
>
{message}
</Text>
</TouchableOpacity>
) : (
<Text style={[styles.field, styles.errorField]}>{message}</Text>
);

const SuccessMessage = ({ message, fontSize, link }: MessageProps) => (
<Message
message={message}
fontSize={fontSize}
link={link}
mainStyle={styles.successField}
/>
);

const WarningMessage = (props: MessageProps) => (
<Text style={[styles.field, styles.warningField]}>{props.message}</Text>
const WarningMessage = ({ message, fontSize, link }: MessageProps) => (
<Message
message={message}
fontSize={fontSize}
link={link}
mainStyle={styles.warningField}
/>
);

const ErrorMessage = (props: MessageProps) => (
<Text style={[styles.field, styles.errorField]}>{props.message}</Text>
const ErrorMessage = ({ message, fontSize, link }: MessageProps) => (
<Message
message={message}
fontSize={fontSize}
link={link}
mainStyle={styles.errorField}
/>
);

const styles = StyleSheet.create({
field: {
fontFamily: 'Lato-Regular',
fontSize: 20,
width: '100%',
top: 10,
borderRadius: 6,
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@
"components.ChannelPicker.modal.title": "Select Channel to use",
"components.ChannelPicker.modal.description": "Select the Channel to be used in this operation. You may want to only use specific channels to preserve your privacy.",
"components.ChannelPicker.modal.set": "Set Channel",
"components.BlueWalletWarning.warning": "WARNING: LNDHub.io is shutting down. Move your funds by April 30th or you will lose them.",
"backends.LND.wsReq.warning": "You may have to enable Certificate Verification to make these kind of calls",
"utils.handleAnything.lightningAddressError": "Error fetching Lightning Address data",
"utils.handleAnything.notValid": "Value provided was not a valid Bitcoin address or Lightning Invoice",
Expand Down

0 comments on commit 2f6f81c

Please sign in to comment.