diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-05-21 19:33:48 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-05-21 19:33:48 -0400 |
| commit | 494677881ac50438af19009b5996cb8548026d61 (patch) | |
| tree | 9494f17483021af4a0be05593f9c3301b3b58c18 /src/components | |
| parent | 1a298f4b0db4a2e598f62d0651dc36466c6508be (diff) | |
Add MomentTagType, Add logic to fetch tags for each moment
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/moments/MomentPostContent.tsx | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx index 193bf40c..9a174e73 100644 --- a/src/components/moments/MomentPostContent.tsx +++ b/src/components/moments/MomentPostContent.tsx @@ -1,10 +1,11 @@ import {useNavigation} from '@react-navigation/native'; -import React, {useEffect} from 'react'; +import React, {useEffect, useState} from 'react'; import {Image, StyleSheet, Text, View, ViewProps} from 'react-native'; import {useDispatch, useStore} from 'react-redux'; -import {getCommentsCount} from '../../services'; +import {getCommentsCount, loadMomentTags} from '../../services'; +import {userMomentsFetched} from '../../store/reducers'; import {RootState} from '../../store/rootReducer'; -import {ScreenType, UserType} from '../../types'; +import {MomentTagType, ScreenType, UserType} from '../../types'; import { getTimePosted, navigateToProfile, @@ -30,13 +31,24 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ dateTime, style, }) => { - const [elapsedTime, setElapsedTime] = React.useState<string>(); - const [comments_count, setCommentsCount] = React.useState(''); + const [elapsedTime, setElapsedTime] = useState(''); + const [comments_count, setCommentsCount] = useState(''); + const [tags, setTags] = useState<MomentTagType[]>([]); const state: RootState = useStore().getState(); const navigation = useNavigation(); const dispatch = useDispatch(); useEffect(() => { + const loadTags = async () => { + const response = await loadMomentTags(momentId); + if (response) { + setTags(response); + } + }; + loadTags(); + }, []); + + useEffect(() => { const fetchCommentsCount = async () => { const count = await getCommentsCount(momentId, false); setCommentsCount(count); |
