Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(transfer): #2222 skip transfer intros after first time #2309

Merged
merged 1 commit into from
Oct 10, 2024
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
1 change: 0 additions & 1 deletion e2e/channels.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ d('Transfer', () => {
await element(by.id('NavigationClose')).tap();
await element(by.id('ActivitySavings')).tap();
await element(by.id('TransferToSpending')).tap();
await element(by.id('SpendingIntro-button')).tap();
await element(by.id('N1').withAncestor(by.id('SpendingAmount'))).tap();
await element(by.id('N0').withAncestor(by.id('SpendingAmount'))).multiTap(
5,
Expand Down
12 changes: 9 additions & 3 deletions src/components/Suggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import SuggestionCard from './SuggestionCard';
import { ITodo, TTodoType } from '../store/types/todos';
import { channelsNotificationsShown, hideTodo } from '../store/slices/todos';
import { showBottomSheet } from '../store/utils/ui';
import { pinSelector } from '../store/reselect/settings';
import { transferIntroSeenSelector } from '../store/reselect/user';
import {
newChannelsNotificationsSelector,
todosFullSelector,
} from '../store/reselect/todos';
import { pinSelector } from '../store/reselect/settings';
import { useAppDispatch, useAppSelector } from '../hooks/redux';
import type { RootNavigationProp } from '../navigation/types';
import { appName, appStoreUrl, playStoreUrl } from '../constants/app';
Expand All @@ -34,6 +35,7 @@ const Suggestions = (): ReactElement => {
const pinTodoDone = useAppSelector(pinSelector);
const suggestions = useAppSelector(todosFullSelector);
const newChannels = useAppSelector(newChannelsNotificationsSelector);
const transferIntroSeen = useAppSelector(transferIntroSeenSelector);
const [index, setIndex] = useState(0);

// this code is needed in order to avoid flashing wrong balance on channel open
Expand Down Expand Up @@ -73,7 +75,11 @@ const Suggestions = (): ReactElement => {
}

if (id === 'lightning') {
navigation.navigate('TransferRoot', { screen: 'TransferIntro' });
if (transferIntroSeen) {
navigation.navigate('TransferRoot', { screen: 'Funding' });
} else {
navigation.navigate('TransferRoot', { screen: 'TransferIntro' });
}
}

if (id === 'lightningSettingUp') {
Expand Down Expand Up @@ -111,7 +117,7 @@ const Suggestions = (): ReactElement => {
});
}
},
[navigation, pinTodoDone, onShare],
[navigation, transferIntroSeen, pinTodoDone, onShare],
);

const handleRenderItem = useCallback(
Expand Down
12 changes: 10 additions & 2 deletions src/screens/Activity/ActivitySavings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import ActivityList from './ActivityList';
import { useBalance } from '../../hooks/wallet';
import { useAppSelector } from '../../hooks/redux';
import { EActivityType } from '../../store/types/activity';
import { isGeoBlockedSelector } from '../../store/reselect/user';
import {
isGeoBlockedSelector,
spendingIntroSeenSelector,
} from '../../store/reselect/user';
import { activityItemsSelector } from '../../store/reselect/activity';
import { WalletScreenProps } from '../../navigation/types';

Expand All @@ -28,6 +31,7 @@ const ActivitySavings = ({
const { onchainBalance, balanceInTransferToSavings } = useBalance();
const items = useAppSelector(activityItemsSelector);
const isGeoBlocked = useAppSelector(isGeoBlockedSelector);
const spendingIntroSeen = useAppSelector(spendingIntroSeenSelector);

const savingsItems = useMemo(() => {
return items.filter((item) => {
Expand All @@ -45,7 +49,11 @@ const ActivitySavings = ({
const showOnboarding = onchainBalance === 0 && savingsItems.length === 0;

const onTransfer = (): void => {
navigation.navigate('TransferRoot', { screen: 'SpendingIntro' });
if (spendingIntroSeen) {
navigation.navigate('TransferRoot', { screen: 'SpendingAmount' });
} else {
navigation.navigate('TransferRoot', { screen: 'SpendingIntro' });
}
};

const canTransfer = onchainBalance && !isGeoBlocked;
Expand Down
8 changes: 7 additions & 1 deletion src/screens/Activity/ActivitySpending.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useBalance } from '../../hooks/wallet';
import { useAppSelector } from '../../hooks/redux';
import { EActivityType } from '../../store/types/activity';
import { spendingOnboardingSelector } from '../../store/reselect/aggregations';
import { savingsIntroSeenSelector } from '../../store/reselect/user';
import { WalletScreenProps } from '../../navigation/types';

const imageSrc = require('../../assets/illustrations/coin-stack-x-2.png');
Expand All @@ -26,6 +27,7 @@ const ActivitySpending = ({
const { t } = useTranslation('wallet');
const { lightningBalance, balanceInTransferToSpending } = useBalance();
const isSpendingOnboarding = useAppSelector(spendingOnboardingSelector);
const savingsIntroSeen = useAppSelector(savingsIntroSeenSelector);

const filter = useMemo(() => {
return {
Expand All @@ -35,7 +37,11 @@ const ActivitySpending = ({
}, []);

const onTransfer = (): void => {
navigation.navigate('TransferRoot', { screen: 'SavingsIntro' });
if (savingsIntroSeen) {
navigation.navigate('TransferRoot', { screen: 'Availability' });
} else {
navigation.navigate('TransferRoot', { screen: 'SavingsIntro' });
}
};

const canTransfer = !!lightningBalance;
Expand Down
12 changes: 10 additions & 2 deletions src/screens/Transfer/Funding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import RectangleButton from '../../components/buttons/RectangleButton';
import SafeAreaInset from '../../components/SafeAreaInset';
import NavigationHeader from '../../components/NavigationHeader';
import { useBalance } from '../../hooks/wallet';
import { isGeoBlockedSelector } from '../../store/reselect/user';
import {
isGeoBlockedSelector,
spendingIntroSeenSelector,
} from '../../store/reselect/user';
import { TRANSACTION_DEFAULTS } from '../../utils/wallet/constants';
import { showBottomSheet } from '../../store/utils/ui';
import type { TransferScreenProps } from '../../navigation/types';
Expand All @@ -21,9 +24,14 @@ const Funding = ({
const { t } = useTranslation('lightning');
const { onchainBalance } = useBalance();
const isGeoBlocked = useAppSelector(isGeoBlockedSelector);
const spendingIntroSeen = useAppSelector(spendingIntroSeenSelector);

const onTransfer = (): void => {
navigation.navigate('SpendingIntro');
if (spendingIntroSeen) {
navigation.navigate('SpendingAmount');
} else {
navigation.navigate('SpendingIntro');
}
};

const onFund = (): void => {
Expand Down
4 changes: 4 additions & 0 deletions src/screens/Transfer/SavingsIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Trans, useTranslation } from 'react-i18next';

import { Display } from '../../styles/text';
import OnboardingScreen from '../../components/OnboardingScreen';
import { useAppDispatch } from '../../hooks/redux';
import { updateUser } from '../../store/slices/user';
import type { TransferScreenProps } from '../../navigation/types';

const imageSrc = require('../../assets/illustrations/piggybank.png');
Expand All @@ -11,13 +13,15 @@ const SavingsIntro = ({
navigation,
}: TransferScreenProps<'SavingsIntro'>): ReactElement => {
const { t } = useTranslation('lightning');
const dispatch = useAppDispatch();

const onClose = (): void => {
navigation.navigate('Wallet');
};

const onContinue = (): void => {
navigation.navigate('Availability');
dispatch(updateUser({ savingsIntroSeen: true }));
};

return (
Expand Down
4 changes: 4 additions & 0 deletions src/screens/Transfer/SpendingIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Trans, useTranslation } from 'react-i18next';

import { Display } from '../../styles/text';
import OnboardingScreen from '../../components/OnboardingScreen';
import { useAppDispatch } from '../../hooks/redux';
import { updateUser } from '../../store/slices/user';
import type { TransferScreenProps } from '../../navigation/types';

const imageSrc = require('../../assets/illustrations/coin-stack-x.png');
Expand All @@ -11,9 +13,11 @@ const SpendingIntro = ({
navigation,
}: TransferScreenProps<'SpendingIntro'>): ReactElement => {
const { t } = useTranslation('lightning');
const dispatch = useAppDispatch();

const onContinue = (): void => {
navigation.navigate('SpendingAmount');
dispatch(updateUser({ spendingIntroSeen: true }));
};

return (
Expand Down
4 changes: 4 additions & 0 deletions src/screens/Transfer/TransferIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Trans, useTranslation } from 'react-i18next';

import { Display } from '../../styles/text';
import OnboardingScreen from '../../components/OnboardingScreen';
import { useAppDispatch } from '../../hooks/redux';
import { updateUser } from '../../store/slices/user';
import type { TransferScreenProps } from '../../navigation/types';

const imageSrc = require('../../assets/illustrations/lightning.png');
Expand All @@ -11,9 +13,11 @@ const TransferIntro = ({
navigation,
}: TransferScreenProps<'TransferIntro'>): ReactElement => {
const { t } = useTranslation('lightning');
const dispatch = useAppDispatch();

const onContinue = (): void => {
navigation.navigate('Funding');
dispatch(updateUser({ transferIntroSeen: true }));
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const persistConfig = {
key: 'root',
storage: reduxStorage,
// increase version after store shape changes
version: 45,
version: 46,
stateReconciler: autoMergeLevel2,
blacklist: ['receive', 'ui'],
migrate: createMigrate(migrations, { debug: __ENABLE_MIGRATION_DEBUG__ }),
Expand Down
11 changes: 11 additions & 0 deletions src/store/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ const migrations = {
},
};
},
46: (state): PersistedState => {
return {
...state,
user: {
...state.user,
transferIntroSeen: false,
spendingIntroSeen: false,
savingsIntroSeen: false,
},
};
},
};

export default migrations;
12 changes: 12 additions & 0 deletions src/store/reselect/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,15 @@ export const scanAllAddressesTimestampSelector = createSelector(
[userState],
(user): number => user.scanAllAddressesTimestamp,
);

export const transferIntroSeenSelector = (state: RootState): boolean => {
return state.user.transferIntroSeen;
};

export const spendingIntroSeenSelector = (state: RootState): boolean => {
return state.user.spendingIntroSeen;
};

export const savingsIntroSeenSelector = (state: RootState): boolean => {
return state.user.savingsIntroSeen;
};
1 change: 0 additions & 1 deletion src/store/shapes/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export const initialSettingsState: TSettings = {
customFeeRate: 0,
hideBalance: false,
hideBalanceOnOpen: false,
hideBeta: false,
hideOnboardingMessage: false,
enableDevOptions: __DEV__,
treasureChests: [],
Expand Down
1 change: 0 additions & 1 deletion src/store/slices/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export type TSettings = {
customFeeRate: number;
hideBalance: boolean;
hideBalanceOnOpen: boolean;
hideBeta: boolean;
hideOnboardingMessage: boolean;
enableDevOptions: boolean;
treasureChests: TChest[];
Expand Down
6 changes: 6 additions & 0 deletions src/store/slices/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export type TUser = {
ignoresHideBalanceToast: boolean;
ignoresSwitchUnitToast: boolean;
scanAllAddressesTimestamp: number;
transferIntroSeen: boolean;
spendingIntroSeen: boolean;
savingsIntroSeen: boolean;
};

export const initialUserState: TUser = {
Expand All @@ -30,6 +33,9 @@ export const initialUserState: TUser = {
ignoresHideBalanceToast: false,
ignoresSwitchUnitToast: false,
scanAllAddressesTimestamp: 0,
transferIntroSeen: false,
spendingIntroSeen: false,
savingsIntroSeen: false,
};

export const userSlice = createSlice({
Expand Down
Loading