mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 05:42:33 +03:00
fixed issues with initial posts, fixed tab sorting
This commit is contained in:
parent
8fac936079
commit
46acc61f7f
@ -19,6 +19,9 @@ export interface CustomiseFiltersModalRef {
|
||||
}
|
||||
|
||||
|
||||
const getFeedScreenFilterIndex = (key:string) => Object.keys(FEED_SCREEN_FILTER_MAP).indexOf(key)
|
||||
|
||||
|
||||
const CustomiseFiltersModal = (props:any, ref:Ref<CustomiseFiltersModalRef>) => {
|
||||
const sheetModalRef = useRef<ActionSheet>();
|
||||
const dispatch = useDispatch();
|
||||
@ -26,7 +29,10 @@ const CustomiseFiltersModal = (props:any, ref:Ref<CustomiseFiltersModalRef>) =>
|
||||
const feedScreenFilters = useSelector(state => state.posts.feedScreenFilters || DEFAULT_FEED_FILTERS);
|
||||
|
||||
const [selectedFilters, setSelectedFilters] = useState<Map<string, number>>(
|
||||
new Map(feedScreenFilters.map((key:string, index:number)=>[key, index]))
|
||||
new Map(feedScreenFilters.map((key:string)=>[
|
||||
key,
|
||||
getFeedScreenFilterIndex(key)
|
||||
]))
|
||||
);
|
||||
|
||||
const intl = useIntl();
|
||||
@ -67,7 +73,7 @@ const CustomiseFiltersModal = (props:any, ref:Ref<CustomiseFiltersModalRef>) =>
|
||||
if(isSelected){
|
||||
selectedFilters.delete(key);
|
||||
}else{
|
||||
var index = Object.keys(FEED_SCREEN_FILTER_MAP).indexOf(key);
|
||||
var index = getFeedScreenFilterIndex(key);
|
||||
selectedFilters.set(key, index);
|
||||
}
|
||||
setSelectedFilters(new Map([...selectedFilters]));
|
||||
|
@ -79,7 +79,7 @@ export const TabbedPosts = ({
|
||||
key={filter.filterKey}
|
||||
filterKey={filter.filterKey}
|
||||
isFeedScreen={isFeedScreen}
|
||||
isFirstTab={ index == 0}
|
||||
isInitialTab={ initialTabIndex == index }
|
||||
feedUsername={feedUsername}
|
||||
pageType={pageType}
|
||||
filterScrollRequest={filterScrollRequest}
|
||||
|
@ -49,7 +49,7 @@ export interface TabMeta {
|
||||
export interface TabContentProps {
|
||||
filterKey:string,
|
||||
isFeedScreen:boolean,
|
||||
isFirstTab:boolean,
|
||||
isInitialTab:boolean,
|
||||
getFor:string,
|
||||
pageType:string,
|
||||
feedUsername:string,
|
||||
|
@ -20,7 +20,7 @@ const DEFAULT_TAB_META = {
|
||||
const TabContent = ({
|
||||
filterKey,
|
||||
isFeedScreen,
|
||||
isFirstTab,
|
||||
isInitialTab,
|
||||
pageType,
|
||||
forceLoadPosts,
|
||||
filterScrollRequest,
|
||||
@ -42,7 +42,7 @@ const TabContent = ({
|
||||
const isConnected = useSelector((state) => state.application.isConnected);
|
||||
const username = useSelector((state) => state.account.currentAccount.name);
|
||||
const initPosts = useSelector((state) => {
|
||||
if(isFeedScreen && isFirstTab){
|
||||
if(isFeedScreen && isInitialTab){
|
||||
return state.posts.initPosts
|
||||
}
|
||||
return []
|
||||
@ -152,7 +152,7 @@ const TabContent = ({
|
||||
|
||||
const result = await loadPosts(options)
|
||||
if(_isMounted && result){
|
||||
_postProcessLoadResult(result, shouldReset)
|
||||
_postProcessLoadResult(result)
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ const TabContent = ({
|
||||
|
||||
|
||||
//processes response from loadPost
|
||||
const _postProcessLoadResult = ({updatedPosts, latestPosts}:any, shouldReset:boolean) => {
|
||||
const _postProcessLoadResult = ({updatedPosts, latestPosts}:any) => {
|
||||
//process new posts avatart
|
||||
if(latestPosts && Array.isArray(latestPosts)){
|
||||
if(latestPosts.length > 0){
|
||||
@ -200,11 +200,13 @@ const TabContent = ({
|
||||
|
||||
//process returned data
|
||||
if(updatedPosts && Array.isArray(updatedPosts)){
|
||||
if (isFeedScreen && shouldReset) {
|
||||
//match new and old first post
|
||||
const firstPostChanged = posts.length == 0 || (posts[0].permlink !== updatedPosts[0].permlink);
|
||||
if (isFeedScreen && firstPostChanged) {
|
||||
// //schedule refetch of new posts by checking time of current post
|
||||
_scheduleLatestPostsCheck(updatedPosts[0]);
|
||||
|
||||
if (isFirstTab) {
|
||||
if (isInitialTab) {
|
||||
dispatch(setInitPosts(updatedPosts));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user