mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-20 20:01:56 +03:00
reloading posts on user change
This commit is contained in:
parent
e191b0f58a
commit
fe70584c6c
@ -17,6 +17,7 @@ const TabContent = ({
|
|||||||
pageType,
|
pageType,
|
||||||
forceLoadPosts,
|
forceLoadPosts,
|
||||||
filterScrollRequest,
|
filterScrollRequest,
|
||||||
|
feedUsername,
|
||||||
onScrollRequestProcessed,
|
onScrollRequestProcessed,
|
||||||
handleOnScroll,
|
handleOnScroll,
|
||||||
...props
|
...props
|
||||||
@ -64,7 +65,7 @@ const TabContent = ({
|
|||||||
AppState.addEventListener('change', _handleAppStateChange);
|
AppState.addEventListener('change', _handleAppStateChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
_initContent(true);
|
_initContent(true, feedUsername);
|
||||||
|
|
||||||
return _cleanup;
|
return _cleanup;
|
||||||
}, [])
|
}, [])
|
||||||
@ -72,11 +73,7 @@ const TabContent = ({
|
|||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(isConnected && (username !== sessionUser || forceLoadPosts)){
|
if(isConnected && (username !== sessionUser || forceLoadPosts)){
|
||||||
if(filterKey !== 'friends'){
|
_initContent(false, username);
|
||||||
_initContent();
|
|
||||||
}else{
|
|
||||||
setPosts([])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [username, forceLoadPosts])
|
}, [username, forceLoadPosts])
|
||||||
|
|
||||||
@ -113,8 +110,9 @@ const TabContent = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const _initContent = (isFirstCall = false) => {
|
const _initContent = (isFirstCall = false, feedUsername:string) => {
|
||||||
setPosts(initPosts || []);
|
_scrollToTop();
|
||||||
|
setPosts(isFirstCall ? initPosts : []);
|
||||||
setTabMeta({
|
setTabMeta({
|
||||||
startAuthor:'',
|
startAuthor:'',
|
||||||
startPermlink:'',
|
startPermlink:'',
|
||||||
@ -124,13 +122,13 @@ const TabContent = ({
|
|||||||
setSessionUser(username);
|
setSessionUser(username);
|
||||||
|
|
||||||
if(username || (filterKey !== 'friends' && filterKey !== 'communities')){
|
if(username || (filterKey !== 'friends' && filterKey !== 'communities')){
|
||||||
_loadPosts(!isFirstCall);
|
_loadPosts(!isFirstCall, false, feedUsername);
|
||||||
_getPromotedPosts();
|
_getPromotedPosts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fetch posts from server
|
//fetch posts from server
|
||||||
const _loadPosts = async (shouldReset:boolean = false, isLatestPostsCheck:boolean = false) => {
|
const _loadPosts = async (shouldReset:boolean = false, isLatestPostsCheck:boolean = false, _feedUsername:string = feedUsername) => {
|
||||||
const options = {
|
const options = {
|
||||||
setTabMeta:(meta:TabMeta) => {
|
setTabMeta:(meta:TabMeta) => {
|
||||||
if(_isMounted){
|
if(_isMounted){
|
||||||
@ -148,6 +146,7 @@ const TabContent = ({
|
|||||||
refreshing:shouldReset,
|
refreshing:shouldReset,
|
||||||
pageType,
|
pageType,
|
||||||
isLatestPostsCheck,
|
isLatestPostsCheck,
|
||||||
|
feedUsername:_feedUsername,
|
||||||
...props
|
...props
|
||||||
} as LoadPostsOptions
|
} as LoadPostsOptions
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user