diff options
author | Shravya Ramesh <shravs1208@gmail.com> | 2021-05-26 14:56:40 -0700 |
---|---|---|
committer | Shravya Ramesh <shravs1208@gmail.com> | 2021-05-26 14:56:40 -0700 |
commit | 67e809a85b625d13f1a0c5a8995d007bbcf4a37f (patch) | |
tree | 52cdf59163255bafdf8e5b8bb382479a8f27bbfa /src/components/moments/MomentPost.tsx | |
parent | b0b5f7aefb58aad74c4f75d521c7416d393e43f4 (diff) |
Set id to '', Remove drawer btn after remove tag
Diffstat (limited to 'src/components/moments/MomentPost.tsx')
-rw-r--r-- | src/components/moments/MomentPost.tsx | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/components/moments/MomentPost.tsx b/src/components/moments/MomentPost.tsx index 1ab7c1fa..e2875b9a 100644 --- a/src/components/moments/MomentPost.tsx +++ b/src/components/moments/MomentPost.tsx @@ -46,11 +46,17 @@ const MomentPost: React.FC<MomentPostProps> = ({item, userXId, screenType}) => { * Check if loggedInUser has been tagged in the picture and set the id */ useEffect(() => { - tags.forEach((tag) => { - if (tag.user.id === loggedInUserId) { - setMomentTagId(tag.id); + const getMomentTagId = () => { + const ownTag: MomentTagType[] = tags.filter( + (tag) => tag.user.id === loggedInUserId, + ); + if (ownTag?.length > 0) { + setMomentTagId(ownTag[0].id); + } else { + setMomentTagId(''); } - }); + }; + getMomentTagId(); }, [tags]); /* @@ -64,6 +70,10 @@ const MomentPost: React.FC<MomentPostProps> = ({item, userXId, screenType}) => { } }; + useEffect(() => { + console.log('Tags have been altered'); + }, [tags]); + return ( <View style={styles.postContainer}> <MomentPostHeader |