Skip to content

Commit

Permalink
Fetch info server blog data
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-edge committed Jan 3, 2024
1 parent 43ec2f5 commit a3f0a48
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/components/ui4/scenes/HomeSceneUi4.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { asBlogPosts, BlogPost } from 'edge-info-server/types'
import * as React from 'react'
import { View } from 'react-native'
import FastImage from 'react-native-fast-image'
Expand All @@ -11,6 +12,7 @@ import { config } from '../../../theme/appConfig'
import { useSelector } from '../../../types/reactRedux'
import { EdgeSceneProps } from '../../../types/routerTypes'
import { getUi4ImageUri } from '../../../util/CdnUris'
import { fetchInfo } from '../../../util/network'
import { NotificationSceneWrapper } from '../../common/SceneWrapper'
import { PasswordReminderModal } from '../../modals/PasswordReminderModal'
import { Airship } from '../../services/AirshipInstance'
Expand Down Expand Up @@ -52,8 +54,17 @@ export const HomeSceneUi4 = (props: Props) => {
navigation.navigate('walletsTab', { screen: 'walletList' })
})

// TODO: Reimplement after info server is published
const blogData: any[] = []
const [blogPosts, setBlogPosts] = React.useState<BlogPost[]>([])

// Check for AssetStatuses from info server (known sync issues, etc):
React.useEffect(() => {
fetchInfo(`v1/blogPosts/${config.appId ?? 'edge'}`)
.then(async res => {
const infoData = await res.json()
setBlogPosts(asBlogPosts(infoData))
})
.catch(e => console.log(String(e)))
}, [])

// Show the password reminder on mount if required:
useAsyncEffect(
Expand Down Expand Up @@ -118,12 +129,12 @@ export const HomeSceneUi4 = (props: Props) => {
<MarketsCardUi4 navigation={navigation} numRows={5} />
</>
{/* TODO: Reimplement after info server is published */}
{blogData == null || blogData.length === 0 ? null : (
{blogPosts == null || blogPosts.length === 0 ? null : (
<>
<SectionHeaderUi4 leftTitle={lstrings.title_learn} />
<View style={styles.carouselContainer}>
<CarouselUi4 height={theme.rem(13)} width={screenWidth}>
{blogData.map((blogPost, index) => (
{blogPosts.map((blogPost, index) => (
<BlogCard blogPost={blogPost} key={`${JSON.stringify(blogPost.localeTitle)}-${index}`} />
))}
</CarouselUi4>
Expand Down

0 comments on commit a3f0a48

Please sign in to comment.