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 React, { useEffect, useState } from "react";
|
||||||
import { Dimensions, View, Image, TextInput, Text } from "react-native";
|
import { Dimensions, View, Image, TextInput, Text } from "react-native";
|
||||||
import { ScrollView } from "react-native-gesture-handler";
|
import { ScrollView } from "react-native-gesture-handler";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
|
|
||||||
import { timeToAge } from "src/interface/rendering";
|
import { timeToAge } from "src/interface/rendering";
|
||||||
import { activeOrNot } from "src/interface/interactions";
|
import { activeOrNot } from "src/interface/interactions";
|
||||||
|
@ -212,21 +213,22 @@ const ViewCommentsJsx = (props) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(() => { // Some magical function that will get all the data needed
|
AsyncStorage.getItem("@user_profile").then((profileJSON) => {
|
||||||
setState({ ...state,
|
setState({ ...state,
|
||||||
descendants: threadify(TEST_CONTEXT.descendants),
|
descendants: threadify(TEST_CONTEXT.descendants),
|
||||||
postData: props.navigation.getParam("postData"),
|
postData: props.navigation.getParam("postData"),
|
||||||
|
profile: JSON.parse(profileJSON),
|
||||||
loaded: true,
|
loaded: true,
|
||||||
});
|
});
|
||||||
})();
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextJsx>
|
<ContextJsx>
|
||||||
|
{ state.loaded ?
|
||||||
<View style = { { flex: 1 } }>
|
<View style = { { flex: 1 } }>
|
||||||
<BackBarJsx navigation = { props.navigation }/>
|
<BackBarJsx navigation = { props.navigation }/>
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
{ state.loaded ?
|
|
||||||
<View style = { { display: state.loaded ? "block" : "none" } }>
|
<View style = { { display: state.loaded ? "block" : "none" } }>
|
||||||
<View style = { styles.parentPost }>
|
<View style = { styles.parentPost }>
|
||||||
<CommentJsx
|
<CommentJsx
|
||||||
|
@ -237,7 +239,6 @@ const ViewCommentsJsx = (props) => {
|
||||||
state.descendants.map((thread, i) => {
|
state.descendants.map((thread, i) => {
|
||||||
const comment = thread[0];
|
const comment = thread[0];
|
||||||
const subs = thread.slice(1);
|
const subs = thread.slice(1);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View key = { i }>
|
<View key = { i }>
|
||||||
<CommentJsx data = { comment }/>
|
<CommentJsx data = { comment }/>
|
||||||
|
@ -259,13 +260,11 @@ const ViewCommentsJsx = (props) => {
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
: <View></View>
|
|
||||||
}
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View style = { styles.commentForm }>
|
<View style = { styles.commentForm }>
|
||||||
<Image
|
<Image
|
||||||
style = { styles.avatar }
|
style = { styles.avatar }
|
||||||
source = { { uri: TEST_IMAGE } }/>
|
source = { { uri: state.profile.avatar } }/>
|
||||||
<TextInput
|
<TextInput
|
||||||
style = { styles.commentInput }
|
style = { styles.commentInput }
|
||||||
placeholder = "Say something..."
|
placeholder = "Say something..."
|
||||||
|
@ -280,6 +279,8 @@ const ViewCommentsJsx = (props) => {
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
: <></>
|
||||||
|
}
|
||||||
</ContextJsx>
|
</ContextJsx>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue