-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add Blocks and News feeds as default widgets
- Loading branch information
1 parent
f72a50b
commit 8a53858
Showing
5 changed files
with
115 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import React, { ReactElement, memo } from 'react'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
import { StyleProp, ViewStyle } from 'react-native'; | ||
|
||
import WalletOnboarding from '../../components/WalletOnboarding'; | ||
import { useAppDispatch } from '../../hooks/redux'; | ||
import { useSlashfeed } from '../../hooks/widgets'; | ||
import { updateSettings } from '../../store/slices/settings'; | ||
import { setFeedWidget } from '../../store/slices/widgets'; | ||
import { Display } from '../../styles/text'; | ||
import { SUPPORTED_FEED_TYPES } from '../../utils/widgets'; | ||
import { | ||
BlocksFeedURL, | ||
NewsFeedURL, | ||
PriceFeedURL, | ||
} from '../Widgets/WidgetsSuggestions'; | ||
|
||
const MainOnboarding = ({ | ||
style, | ||
}: { | ||
style: StyleProp<ViewStyle>; | ||
}): ReactElement => { | ||
const dispatch = useAppDispatch(); | ||
const { t } = useTranslation('onboarding'); | ||
const { config: priceConfig } = useSlashfeed({ url: PriceFeedURL }); | ||
const { config: newsConfig } = useSlashfeed({ url: NewsFeedURL }); | ||
const { config: blocksConfig } = useSlashfeed({ url: BlocksFeedURL }); | ||
|
||
const onHideOnboarding = (): void => { | ||
// add default widgets | ||
if (priceConfig) { | ||
dispatch( | ||
setFeedWidget({ | ||
url: PriceFeedURL, | ||
type: SUPPORTED_FEED_TYPES.PRICE_FEED, | ||
fields: priceConfig.fields.filter((f) => f.name === 'BTC/USD'), | ||
extras: { period: '1D', showSource: false }, | ||
}), | ||
); | ||
} | ||
|
||
if (newsConfig) { | ||
dispatch( | ||
setFeedWidget({ | ||
url: NewsFeedURL, | ||
type: SUPPORTED_FEED_TYPES.HEADLINES_FEED, | ||
fields: newsConfig.fields, | ||
}), | ||
); | ||
} | ||
|
||
if (blocksConfig) { | ||
const fields = blocksConfig.fields.filter((f) => { | ||
return ['Block', 'Time', 'Date'].includes(f.name); | ||
}); | ||
|
||
dispatch( | ||
setFeedWidget({ | ||
url: BlocksFeedURL, | ||
type: SUPPORTED_FEED_TYPES.BLOCKS_FEED, | ||
fields, | ||
}), | ||
); | ||
} | ||
|
||
dispatch(updateSettings({ hideOnboardingMessage: true })); | ||
}; | ||
|
||
return ( | ||
<WalletOnboarding | ||
style={style} | ||
onHide={onHideOnboarding} | ||
text={ | ||
<Trans | ||
t={t} | ||
i18nKey="empty_wallet" | ||
components={{ accent: <Display color="brand" /> }} | ||
/> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default memo(MainOnboarding); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters