From e07b89b981e4277ff5e1947f35cf50a8916b60c2 Mon Sep 17 00:00:00 2001 From: natjms Date: Fri, 2 Apr 2021 21:53:29 -0300 Subject: [PATCH] Enable view-comments.js to retrieve profile data from AsyncStorage --- src/components/pages/view-comments.js | 53 ++++++++++++++------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/components/pages/view-comments.js b/src/components/pages/view-comments.js index a385d5f..9bccb75 100644 --- a/src/components/pages/view-comments.js +++ b/src/components/pages/view-comments.js @@ -1,6 +1,7 @@ import React, { useEffect, useState } from "react"; import { Dimensions, View, Image, TextInput, Text } from "react-native"; import { ScrollView } from "react-native-gesture-handler"; +import AsyncStorage from "@react-native-async-storage/async-storage"; import { timeToAge } from "src/interface/rendering"; import { activeOrNot } from "src/interface/interactions"; @@ -212,21 +213,22 @@ const ViewCommentsJsx = (props) => { }); useEffect(() => { - (() => { // Some magical function that will get all the data needed + AsyncStorage.getItem("@user_profile").then((profileJSON) => { setState({ ...state, descendants: threadify(TEST_CONTEXT.descendants), postData: props.navigation.getParam("postData"), + profile: JSON.parse(profileJSON), loaded: true, }); - })(); + }); }, []); return ( - - - - { state.loaded ? + { state.loaded ? + + + { state.descendants.map((thread, i) => { const comment = thread[0]; const subs = thread.slice(1); - return ( @@ -259,27 +260,27 @@ const ViewCommentsJsx = (props) => { } - : - } - - - - setState({...state, reply: c }) }/> - - - - + + + + setState({...state, reply: c }) }/> + + + + + - + : <> + } ); }