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
2 changes: 2 additions & 0 deletions src/AppOnboarded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const AppOnboarded = (): ReactElement => {
const appStateSubscription = AppState.addEventListener(
'change',
(nextAppState) => {
dispatch(updateUi({ appState: nextAppState }));

// on App to foreground
if (
appState.current.match(/inactive|background/) &&
Expand Down
12 changes: 12 additions & 0 deletions src/screens/Wallets/Receive/ReceiveQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { createLightningInvoice } from '../../../store/utils/lightning';
import { updatePendingInvoice } from '../../../store/slices/metadata';
import { generateNewReceiveAddress } from '../../../store/actions/wallet';
import {
appStateSelector,
isLDKReadySelector,
viewControllerIsOpenSelector,
} from '../../../store/reselect/ui';
Expand Down Expand Up @@ -93,6 +94,7 @@ const ReceiveQR = ({
const addressType = useAppSelector(addressTypeSelector);
const isGeoBlocked = useAppSelector(isGeoBlockedSelector);
const isLDKReady = useAppSelector(isLDKReadySelector);
const appState = useAppSelector(appStateSelector);
const { id, amount, message, tags, jitOrder } =
useAppSelector(receiveSelector);
const lightningBalance = useLightningBalance(false);
Expand Down Expand Up @@ -244,6 +246,16 @@ const ReceiveQR = ({
dispatch,
]);

useEffect(() => {
if (receiveNavigationIsOpen && enableInstant && appState !== 'active') {
showToast({
type: 'error',
title: t('receive_foreground_title'),
description: t('receive_foreground_msg'),
});
}
}, [t, appState, enableInstant, receiveNavigationIsOpen]);

const uri = useMemo((): string => {
if (!receiveNavigationIsOpen) {
return '';
Expand Down
2 changes: 2 additions & 0 deletions src/store/reselect/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,5 @@ export const fromAddressViewerSelector = createSelector(
[uiState],
(ui) => ui.fromAddressViewer,
);

export const appStateSelector = createSelector([uiState], (ui) => ui.appState);
1 change: 1 addition & 0 deletions src/store/shapes/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ export const initialUiState: TUiState = {
viewControllers: defaultViewControllers,
fromAddressViewer: false, // When true, ensures tx inputs are not cleared when sweeping from address viewer.
paymentMethod: 'onchain',
appState: 'active',
};
2 changes: 2 additions & 0 deletions src/store/types/ui.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AppStateStatus } from 'react-native';
import { LNURLWithdrawParams, LNURLPayParams } from 'js-lnurl';
import { EActivityType, TOnchainActivityItem } from './activity';
import { ReceiveStackParamList } from '../../navigation/bottom-sheet/ReceiveNavigation';
Expand Down Expand Up @@ -91,4 +92,5 @@ export type TUiState = {
language: string;
fromAddressViewer: boolean;
paymentMethod: 'onchain' | 'lightning';
appState: AppStateStatus;
};
8 changes: 8 additions & 0 deletions src/utils/i18n/locales/en/wallet.json
Original file line number Diff line number Diff line change
Expand Up @@ -686,5 +686,13 @@
},
"receive_insufficient_text": {
"string": "Insufficient receiving capacity to receive this amount over Lightning."
},
"receive_foreground_title": {
"string": "Keep Bitkit In Foreground",
"developer_comment": "This message appears when the user is shown an LN invoice but tries to switch to another app"
},
"receive_foreground_msg": {
"string": "Payments to your spending balance might fail if you switch between apps.",
"developer_comment": "This message appears when the user is shown an LN invoice but tries to switch to another app"
}
}