mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 11:21:41 +03:00
handling logged out user in tabbedPosts, ignoring momentum load calls
This commit is contained in:
parent
004b8b3fb3
commit
aa3fce6877
@ -16,6 +16,8 @@ interface postsListContainerProps extends FlatListProps<any> {
|
||||
isRefreshing:boolean;
|
||||
}
|
||||
|
||||
let _onEndReachedCalledDuringMomentum = true;
|
||||
|
||||
const postsListContainer = ({
|
||||
promotedPosts,
|
||||
isFeedScreen,
|
||||
@ -24,6 +26,7 @@ const postsListContainer = ({
|
||||
isLoading,
|
||||
...props
|
||||
}:postsListContainerProps, ref) => {
|
||||
|
||||
const flatListRef = useRef(null);
|
||||
|
||||
const [imageHeights, setImageHeights] = useState(new Map<string, number>());
|
||||
@ -88,7 +91,12 @@ const postsListContainer = ({
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
const _onEndReached = () => {
|
||||
if (onLoadPosts && !_onEndReachedCalledDuringMomentum) {
|
||||
onLoadPosts(false);
|
||||
_onEndReachedCalledDuringMomentum = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const _renderItem = ({ item, index }:{item:any, index:number}) => {
|
||||
@ -150,7 +158,10 @@ const postsListContainer = ({
|
||||
initialNumToRender={3}
|
||||
windowSize={5}
|
||||
extraData={imageHeights}
|
||||
onEndReached={()=>{if(onLoadPosts){onLoadPosts(false)}}}
|
||||
onEndReached={_onEndReached}
|
||||
onMomentumScrollBegin={() => {
|
||||
_onEndReachedCalledDuringMomentum = false;
|
||||
}}
|
||||
ListFooterComponent={_renderFooter}
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
|
@ -228,7 +228,7 @@ const TabEmptyView = ({
|
||||
|
||||
|
||||
//render related operations
|
||||
if ((filterKey === 'feed' || filterKey === 'blog') && !isLoggedIn) {
|
||||
if ((filterKey === 'feed' || filterKey === 'blog' || filterKey === 'friends' || filterKey === 'communities') && !isLoggedIn) {
|
||||
return (
|
||||
<NoPost
|
||||
imageStyle={styles.noImage}
|
||||
|
@ -53,8 +53,11 @@ const TabContent = ({
|
||||
isRefreshing:false,
|
||||
} as TabMeta)
|
||||
setSessionUser(username);
|
||||
_loadPosts();
|
||||
_getPromotedPosts();
|
||||
|
||||
if(username || (filterKey !== 'friends' && filterKey !== 'communities')){
|
||||
_loadPosts(true);
|
||||
_getPromotedPosts();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user