Skip to content

Commit fc075aa

Browse files
committed
refactor(onboarding): move default widgets to initial state
1 parent 6d85a23 commit fc075aa

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/screens/Wallets/MainOnboarding.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { StyleProp, ViewStyle } from 'react-native';
55
import WalletOnboarding from '../../components/WalletOnboarding';
66
import { useAppDispatch } from '../../hooks/redux';
77
import { updateSettings } from '../../store/slices/settings';
8-
import { saveWidget } from '../../store/slices/widgets';
98
import { Display } from '../../styles/text';
10-
import { getDefaultOptions } from '../../utils/widgets';
119

1210
const MainOnboarding = ({
1311
style,
@@ -16,14 +14,8 @@ const MainOnboarding = ({
1614
}): ReactElement => {
1715
const dispatch = useAppDispatch();
1816
const { t } = useTranslation('onboarding');
19-
const priceOptions = getDefaultOptions('price');
20-
const newsOptions = getDefaultOptions('news');
21-
const blocksOptions = getDefaultOptions('blocks');
2217

2318
const onHideOnboarding = (): void => {
24-
dispatch(saveWidget({ id: 'price', options: priceOptions }));
25-
dispatch(saveWidget({ id: 'news', options: newsOptions }));
26-
dispatch(saveWidget({ id: 'blocks', options: blocksOptions }));
2719
dispatch(updateSettings({ hideOnboardingMessage: true }));
2820
};
2921

src/store/slices/widgets.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
2+
import { getDefaultOptions } from '../../utils/widgets';
23
import { TWidgets } from '../types/widgets';
34

45
export type TWidgetsState = {
@@ -8,7 +9,11 @@ export type TWidgetsState = {
89
};
910

1011
export const initialWidgetsState: TWidgetsState = {
11-
widgets: {},
12+
widgets: {
13+
price: getDefaultOptions('price'),
14+
news: getDefaultOptions('news'),
15+
blocks: getDefaultOptions('blocks'),
16+
},
1217
onboardedWidgets: false,
1318
sortOrder: [],
1419
};

0 commit comments

Comments
 (0)