Enable view-comments.js to retrieve profile data from AsyncStorage
This commit is contained in:
parent
d344ad8933
commit
e07b89b981
|
@ -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 (
|
||||
<ContextJsx>
|
||||
{ state.loaded ?
|
||||
<View style = { { flex: 1 } }>
|
||||
<BackBarJsx navigation = { props.navigation }/>
|
||||
<ScrollView>
|
||||
{ state.loaded ?
|
||||
<View style = { { display: state.loaded ? "block" : "none" } }>
|
||||
<View style = { styles.parentPost }>
|
||||
<CommentJsx
|
||||
|
@ -237,7 +239,6 @@ const ViewCommentsJsx = (props) => {
|
|||
state.descendants.map((thread, i) => {
|
||||
const comment = thread[0];
|
||||
const subs = thread.slice(1);
|
||||
|
||||
return (
|
||||
<View key = { i }>
|
||||
<CommentJsx data = { comment }/>
|
||||
|
@ -259,13 +260,11 @@ const ViewCommentsJsx = (props) => {
|
|||
}
|
||||
</View>
|
||||
</View>
|
||||
: <View></View>
|
||||
}
|
||||
</ScrollView>
|
||||
<View style = { styles.commentForm }>
|
||||
<Image
|
||||
style = { styles.avatar }
|
||||
source = { { uri: TEST_IMAGE } }/>
|
||||
source = { { uri: state.profile.avatar } }/>
|
||||
<TextInput
|
||||
style = { styles.commentInput }
|
||||
placeholder = "Say something..."
|
||||
|
@ -280,6 +279,8 @@ const ViewCommentsJsx = (props) => {
|
|||
</View>
|
||||
</View>
|
||||
</View>
|
||||
: <></>
|
||||
}
|
||||
</ContextJsx>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue