Use lastUpdated as key to better sync regresh
This commit is contained in:
@@ -32,13 +32,18 @@ let Feed = ({ navigation, route }) => {
|
||||
useEffect(() => {
|
||||
let subscribed = true;
|
||||
const getData = async () => {
|
||||
let loggedIn = await API.isLoggedIn();
|
||||
if (!loggedIn) return navigation.reset({
|
||||
index: 0,
|
||||
routes: [{ name: 'Login' }],
|
||||
});
|
||||
if (route.params && route.params.profileid) {
|
||||
return navigation.navigate('Profile', { profileid: route.params.profileid })
|
||||
// TODO: Check for internet connection
|
||||
const internet = true;
|
||||
if(internet){
|
||||
//byPass and load
|
||||
let loggedIn = await API.isLoggedIn();
|
||||
if (!loggedIn) return navigation.reset({
|
||||
index: 0,
|
||||
routes: [{ name: 'Login' }],
|
||||
});
|
||||
if (route.params && route.params.profileid) {
|
||||
return navigation.navigate('Profile', { profileid: route.params.profileid })
|
||||
}
|
||||
}
|
||||
if(!route.params?.reRender){
|
||||
API.getMe().then((me) => {
|
||||
@@ -68,7 +73,7 @@ let Feed = ({ navigation, route }) => {
|
||||
const renderPost = (({ item }) => {
|
||||
if (item.nonOrganicType === 'PopularUsers' || item.nonOrganicType === 'PopularGroups')
|
||||
return (<></>);
|
||||
return (<Post post={item} />);
|
||||
return (<Post post={item} />);
|
||||
});
|
||||
|
||||
|
||||
@@ -77,7 +82,7 @@ let Feed = ({ navigation, route }) => {
|
||||
<FlatList
|
||||
data={Posts}
|
||||
renderItem={renderPost}
|
||||
keyExtractor={item => item._id || item.createdAt}
|
||||
keyExtractor={item => item.lastUpdated || item._id || item.ceatedAt} //This may refresh the component
|
||||
//ListHeaderComponent={<NewPost newPostCB={(newPost) => setPosts([newPost, ...Posts])} />}
|
||||
refreshing={Posts.length === 0}
|
||||
onRefresh={() => {
|
||||
|
||||
Reference in New Issue
Block a user