From e3571b2fcb4a78ea11466ff4bfb0405ae4028aea Mon Sep 17 00:00:00 2001
From: Ivan Chen <ivan@tagg.id>
Date: Wed, 26 May 2021 19:08:28 -0400
Subject: Finish logic for draggables, Caption screen logic is done

---
 src/screens/profile/CaptionScreen.tsx | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

(limited to 'src/screens/profile/CaptionScreen.tsx')

diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx
index 69f4b3d9..d85ffead 100644
--- a/src/screens/profile/CaptionScreen.tsx
+++ b/src/screens/profile/CaptionScreen.tsx
@@ -29,7 +29,7 @@ import {
   updateProfileCompletionStage,
 } from '../../store/actions';
 import {RootState} from '../../store/rootReducer';
-import {ProfilePreviewType} from '../../types';
+import {MomentTagType} from '../../types';
 import {SCREEN_WIDTH, StatusBarHeight} from '../../utils';
 import {mentionPartTypes} from '../../utils/comments';
 
@@ -47,26 +47,26 @@ interface CaptionScreenProps {
 }
 
 const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
-  const {title, image, screenType, selectedUsers} = route.params;
+  const {title, image, screenType, selectedTags} = route.params;
   const {
     user: {userId},
   } = useSelector((state: RootState) => state.user);
   const dispatch = useDispatch();
   const [caption, setCaption] = useState('');
   const [loading, setLoading] = useState(false);
-  const [taggedUsers, setTaggedUsers] = useState<ProfilePreviewType[]>([]);
+  const [tags, setTags] = useState<MomentTagType[]>([]);
   const [taggedList, setTaggedList] = useState<string>('');
 
   useEffect(() => {
-    setTaggedUsers(selectedUsers ? selectedUsers : []);
-  }, [route.params]);
+    setTags(selectedTags ? selectedTags : []);
+  }, [selectedTags]);
 
   useEffect(() => {
     const getTaggedUsersListString = () => {
       let listString = '';
-      for (let i = 0; i < taggedUsers.length; i++) {
+      for (let i = 0; i < tags.length; i++) {
         if (listString.length < 21) {
-          listString = listString.concat(`@${taggedUsers[i].username} `);
+          listString = listString.concat(`@${tags[i].user.username} `);
         } else {
           break;
         }
@@ -74,7 +74,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
       setTaggedList(listString);
     };
     getTaggedUsersListString();
-  }, [taggedUsers]);
+  }, [tags]);
 
   const navigateToProfile = () => {
     //Since the logged In User is navigating to own profile, useXId is not required
@@ -115,11 +115,11 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
     }
     const momentTagResponse = await postMomentTags(
       momentResponse.moment_id,
-      taggedUsers.map((u, index) => ({
-        x: index * 50,
-        y: index * 50,
-        z: 1,
-        user_id: u.id,
+      tags.map((tag) => ({
+        x: tag.x,
+        y: tag.y,
+        z: tag.z,
+        user_id: tag.id,
       })),
     );
     if (!momentTagResponse) {
@@ -174,7 +174,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
                 navigation.navigate('TagFriendsScreen', {
                   image: image,
                   screenType: screenType,
-                  selectedUsers: taggedUsers,
+                  selectedTags: tags,
                 })
               }
               style={styles.tagFriendsContainer}>
-- 
cgit v1.2.3-70-g09d2

