Skip to content

Commit

Permalink
Merge pull request #1786 from synonymdev/fix/various-fixes
Browse files Browse the repository at this point in the history
fix: various fixes
  • Loading branch information
pwltr authored May 6, 2024
2 parents 2c5b077 + 4b5d7db commit 13cc008
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"clean:android": "cd android && npx del-cli build app/build",
"clean:ios": "cd ios && npx del-cli Pods Podfile.lock build && pod deintegrate && pod install",
"bundle": "yarn clean:android && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.jsbundle --assets-dest android/app/build/intermediates/res/merged/release/ && cd android && ./gradlew assembleRelease --no-daemon",
"prepare": "husky install",
"prepare": "husky",
"postinstall": "node postinstall.js"
},
"dependencies": {
Expand Down
6 changes: 5 additions & 1 deletion src/navigation/bottom-sheet/AppUpdatePrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const AppUpdatePrompt = ({ enabled }: { enabled: boolean }): ReactElement => {
};
}, [shouldShowBottomSheet]);

const onClose = (): void => {
dispatch(ignoreAppUpdate());
};

const onCancel = (): void => {
dispatch(ignoreAppUpdate());
dispatch(closeSheet('appUpdatePrompt'));
Expand All @@ -92,7 +96,7 @@ const AppUpdatePrompt = ({ enabled }: { enabled: boolean }): ReactElement => {
view="appUpdatePrompt"
snapPoints={snapPoints}
backdrop={true}
onClose={ignoreAppUpdate}>
onClose={onClose}>
<View style={styles.root}>
<BottomSheetNavigationHeader
title={t('update_title')}
Expand Down
22 changes: 3 additions & 19 deletions src/screens/Settings/Lightning/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
createLightningInvoice,
savePeer,
} from '../../../store/utils/lightning';
import { useBalance } from '../../../hooks/wallet';
import {
selectedNetworkSelector,
selectedWalletSelector,
Expand All @@ -65,7 +64,6 @@ import {
pendingChannelsSelector,
} from '../../../store/reselect/lightning';
import { enableDevOptionsSelector } from '../../../store/reselect/settings';
import { TRANSACTION_DEFAULTS } from '../../../utils/wallet/constants';
import { zipLogs } from '../../../utils/lightning/logs';
import { SettingsScreenProps } from '../../../navigation/types';
import {
Expand All @@ -75,7 +73,6 @@ import {
import { TPaidBlocktankOrders } from '../../../store/types/blocktank';
import { EUnit } from '../../../store/types/wallet';
import { EChannelStatus, TChannel } from '../../../store/types/lightning';
import { isGeoBlockedSelector } from '../../../store/reselect/user';

/**
* Convert pending (non-channel) blocktank orders to (fake) channels.
Expand Down Expand Up @@ -228,7 +225,6 @@ const Channels = ({
const [spendingStuckOutputs, setSpendingStuckOutputs] = useState(false);

const colors = useColors();
const { onchainBalance } = useBalance();
const { localBalance, remoteBalance } = useLightningBalance();
const selectedWallet = useAppSelector(selectedWalletSelector);
const selectedNetwork = useAppSelector(selectedNetworkSelector);
Expand All @@ -239,7 +235,6 @@ const Channels = ({
const openChannels = useAppSelector(openChannelsSelector);
const pendingChannels = useAppSelector(pendingChannelsSelector);
const closedChannels = useAppSelector(closedChannelsSelector);
const isGeoBlocked = useAppSelector(isGeoBlockedSelector);
const blocktankNodeKey = useAppSelector((state) => {
return state.blocktank.info.nodes[0]?.pubkey;
});
Expand All @@ -252,10 +247,7 @@ const Channels = ({
const pendingConnections = [...pendingOrders, ...pendingChannels];

const handleAdd = useCallback((): void => {
navigation.navigate('LightningRoot', {
screen: 'CustomSetup',
params: { spending: true },
});
navigation.navigate('LightningRoot', { screen: 'Funding' });

// TODO: Update this view once we enable creating channels with nodes other than Blocktank.
// navigation.navigate('LightningAddConnection');
Expand Down Expand Up @@ -355,20 +347,13 @@ const Channels = ({
});
}, [peer, selectedNetwork, selectedWallet, t]);

const addConnectionIsDisabled =
onchainBalance <= TRANSACTION_DEFAULTS.recommendedBaseFee || isGeoBlocked;

return (
<ThemedView style={styles.root}>
<SafeAreaInset type="top" />
<NavigationHeader
title={t('connections')}
onActionPress={addConnectionIsDisabled ? undefined : handleAdd}
actionIcon={
addConnectionIsDisabled ? undefined : (
<PlusIcon width={24} height={24} />
)
}
actionIcon={<PlusIcon width={24} height={24} />}
onActionPress={handleAdd}
/>
<ScrollView
contentContainerStyle={styles.content}
Expand Down Expand Up @@ -666,7 +651,6 @@ const Channels = ({
style={styles.button}
text={t('conn_button_add')}
size="large"
disabled={addConnectionIsDisabled}
onPress={handleAdd}
/>
</View>
Expand Down
20 changes: 11 additions & 9 deletions src/screens/Wallets/NewTxPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ const NewTxPrompt = (): ReactElement => {
snapPoints={snapPoints}
backdrop={true}>
<View style={styles.root}>
<View style={styles.confetti} pointerEvents="none">
<Lottie
source={isOnchainItem ? confettiOrangeSrc : confettiPurpleSrc}
style={styles.lottie}
resizeMode="cover"
autoPlay
loop
/>
</View>
{activityItem && (
<View style={styles.confetti} pointerEvents="none">
<Lottie
source={isOnchainItem ? confettiOrangeSrc : confettiPurpleSrc}
style={styles.lottie}
resizeMode="cover"
autoPlay
loop
/>
</View>
)}
<BottomSheetNavigationHeader
title={
isOnchainItem
Expand Down
4 changes: 3 additions & 1 deletion src/store/utils/activity.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ok, Result } from '@synonymdev/result';
import { TChannel } from '@synonymdev/react-native-ldk';
import { EPaymentType } from 'beignet';

import { EActivityType, TLightningActivityItem } from '../types/activity';
import { getBlocktankStore, dispatch } from '../helpers';
import { vibrate } from '../../utils/helpers';
import { getCurrentWallet } from '../../utils/wallet';
import { getChannels } from '../../utils/lightning';
import { formatBoostedActivityItems } from '../../utils/boost';
Expand All @@ -12,7 +14,6 @@ import { updateSettings } from '../slices/settings';
import { closeSheet } from '../slices/ui';
import { addActivityItem, updateActivityItems } from '../slices/activity';
import { showBottomSheet } from './ui';
import { EPaymentType } from 'beignet';

/**
* Attempts to determine if a given channel open was in response to
Expand Down Expand Up @@ -57,6 +58,7 @@ export const addCJitActivityItem = async (channelId: string): Promise<void> => {
dispatch(addActivityItem(activityItem));
dispatch(updateSettings({ hideOnboardingMessage: true }));
dispatch(closeSheet('receiveNavigation'));
vibrate({ type: 'default' });
showBottomSheet('newTxPrompt', { activityItem });
};

Expand Down
5 changes: 4 additions & 1 deletion src/store/utils/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { getBuildNumber } from 'react-native-device-info';

import { getActivityStore, dispatch } from '../helpers';
import { closeSheet, setAppUpdateInfo, showSheet } from '../slices/ui';
import { TAvailableUpdate, ViewControllerParamList } from '../types/ui';
import { vibrate } from '../../utils/helpers';
import { EActivityType } from '../types/activity';
import { TAvailableUpdate, ViewControllerParamList } from '../types/ui';

const releaseUrl =
'https://github.com/synonymdev/bitkit/releases/download/updater/release.json';
Expand All @@ -25,6 +26,7 @@ export const showNewOnchainTxPrompt = ({
id: string;
value: number;
}): void => {
vibrate({ type: 'default' });
showBottomSheet('newTxPrompt', {
activityItem: {
id,
Expand All @@ -40,6 +42,7 @@ export const showNewTxPrompt = (txId: string): void => {
const activityItem = getActivityStore().items.find(({ id }) => id === txId);

if (activityItem) {
vibrate({ type: 'default' });
showBottomSheet('newTxPrompt', { activityItem });
dispatch(closeSheet('receiveNavigation'));
}
Expand Down
10 changes: 9 additions & 1 deletion src/utils/lightning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ import {
updateLightningNodeIdThunk,
updateLightningNodeVersionThunk,
} from '../../store/utils/lightning';
import { promiseTimeout, reduceValue, sleep, tryNTimes } from '../helpers';
import {
promiseTimeout,
reduceValue,
sleep,
tryNTimes,
vibrate,
} from '../helpers';
import {
EActivityType,
TLightningActivityItem,
Expand Down Expand Up @@ -428,6 +434,7 @@ export const handleLightningPaymentSubscription = async ({
};

dispatch(addActivityItem(activityItem));
vibrate({ type: 'default' });
showBottomSheet('newTxPrompt', { activityItem });
dispatch(closeSheet('receiveNavigation'));

Expand Down Expand Up @@ -999,6 +1006,7 @@ export const isLdkRunning = async (): Promise<boolean> => {
export const waitForLdk = async (): Promise<void> => {
await tryNTimes({
toTry: getNodeId,
times: 30,
interval: 500,
});
};
Expand Down

0 comments on commit 13cc008

Please sign in to comment.