mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 03:11:38 +03:00
commit
290cbd9513
@ -153,7 +153,7 @@ const postsListContainer = ({
|
||||
data={posts}
|
||||
showsVerticalScrollIndicator={false}
|
||||
renderItem={_renderItem}
|
||||
keyExtractor={(content) => `${content.author}/${content.permlink}`}
|
||||
keyExtractor={(content, index) => `${content.author}/${content.permlink}-${index}`}
|
||||
removeClippedSubviews
|
||||
onEndReachedThreshold={1}
|
||||
maxToRenderPerBatch={3}
|
||||
|
@ -254,7 +254,7 @@ class ProfileView extends PureComponent {
|
||||
isFeedScreen={false}
|
||||
tabContentOverrides={tabContentOverrides}
|
||||
onChangeTab={this._onTabChange}
|
||||
imagesToggleEnabled={false}
|
||||
imagesToggleEnabled={true}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
@ -15,7 +15,7 @@ export const TabbedPosts = ({
|
||||
feedUsername,
|
||||
pageType,
|
||||
tabContentOverrides,
|
||||
imagesToggleEnabled = true,
|
||||
imagesToggleEnabled,
|
||||
stackedTabs,
|
||||
onTabChange,
|
||||
...props
|
||||
@ -89,6 +89,7 @@ export const TabbedPosts = ({
|
||||
secondStack={subFilters}
|
||||
initialFirstStackIndex={selectedOptionIndex}
|
||||
onFilterSelect={_onFilterSelect}
|
||||
toggleHideImagesFlag={imagesToggleEnabled}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ export const loadPosts = async ({
|
||||
observer: feedUsername,
|
||||
sort: 'created',
|
||||
tag: 'my',
|
||||
limit,
|
||||
};
|
||||
} else {
|
||||
func = getAccountPosts;
|
||||
|
@ -39,7 +39,7 @@ const NewPostsPopup = ({
|
||||
|
||||
{popupAvatars.map((url, index) => (
|
||||
<FastImage
|
||||
key={`image_bubble_${url}`}
|
||||
key={`image_bubble_${url}-${index}`}
|
||||
source={{ uri: url }}
|
||||
style={[styles.popupImage, { zIndex: 10 - index }]}
|
||||
/>
|
||||
|
@ -1,6 +1,8 @@
|
||||
import React, { useRef, useState } from "react";
|
||||
import { useIntl } from "react-intl";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { CustomiseFiltersModal, FilterBar } from "../..";
|
||||
import { hidePostsThumbnails } from "../../../redux/actions/uiAction";
|
||||
import { CustomiseFiltersModalRef } from "../../customiseFiltersModal/customiseFiltersModal";
|
||||
|
||||
export interface TabItem {
|
||||
@ -18,6 +20,7 @@ interface StackedTabBarProps {
|
||||
secondStack:TabItem[];
|
||||
initialFirstStackIndex:number;
|
||||
onFilterSelect:(filterKey:string)=>void;
|
||||
toggleHideImagesFlag:boolean;
|
||||
}
|
||||
|
||||
export const StackedTabBar = ({
|
||||
@ -29,12 +32,18 @@ export const StackedTabBar = ({
|
||||
secondStack,
|
||||
initialFirstStackIndex,
|
||||
onFilterSelect,
|
||||
toggleHideImagesFlag
|
||||
|
||||
}:StackedTabBarProps) => {
|
||||
|
||||
const customiseModalRef = useRef<CustomiseFiltersModalRef>();
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const intl = useIntl();
|
||||
|
||||
const customiseModalRef = useRef<CustomiseFiltersModalRef>();
|
||||
|
||||
//redux properties
|
||||
const isHideImages = useSelector((state) => state.ui.hidePostsThumbnails);
|
||||
|
||||
const [selectedFilterIndex, setSelectedFilterIndex] = useState(initialFirstStackIndex);
|
||||
const [selectedSecondStackIndex, setSelectedSecondStackIndex] = useState(0);
|
||||
|
||||
@ -44,6 +53,10 @@ export const StackedTabBar = ({
|
||||
}
|
||||
}
|
||||
|
||||
const _onToggleImagesPress = () => {
|
||||
dispatch(hidePostsThumbnails(!isHideImages))
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<FilterBar
|
||||
@ -55,6 +68,8 @@ export const StackedTabBar = ({
|
||||
}
|
||||
|
||||
selectedOptionIndex={selectedFilterIndex}
|
||||
rightIconName={toggleHideImagesFlag && "view-module"}
|
||||
rightIconType={toggleHideImagesFlag && "MaterialIcons"}
|
||||
enableCustomiseButton={enableCustomiseButton}
|
||||
onCustomisePress={_onCustomisePress}
|
||||
onDropdownSelect={(index)=>{
|
||||
@ -70,6 +85,7 @@ export const StackedTabBar = ({
|
||||
}
|
||||
|
||||
}}
|
||||
onRightIconPress={_onToggleImagesPress}
|
||||
/>
|
||||
|
||||
{
|
||||
|
@ -30,7 +30,6 @@ const TabContent = ({
|
||||
handleOnScroll,
|
||||
...props
|
||||
}: TabContentProps) => {
|
||||
let _postFetchTimer = null;
|
||||
let _isMounted = true;
|
||||
|
||||
|
||||
@ -50,13 +49,18 @@ const TabContent = ({
|
||||
const [sessionUser, setSessionUser] = useState(username);
|
||||
const [tabMeta, setTabMeta] = useState(DEFAULT_TAB_META);
|
||||
const [latestPosts, setLatestPosts] = useState<any[]>([]);
|
||||
|
||||
const [postFetchTimer, setPostFetchTimer] = useState(0)
|
||||
|
||||
//refs
|
||||
let postsListRef = useRef<PostsListRef>()
|
||||
const appState = useRef(AppState.currentState);
|
||||
const postsRef = useRef(posts);
|
||||
const sessionUserRef = useRef(sessionUser);
|
||||
|
||||
//init state refs;
|
||||
postsRef.current = posts;
|
||||
sessionUserRef.current = sessionUser;
|
||||
|
||||
|
||||
//side effects
|
||||
useEffect(() => {
|
||||
@ -89,8 +93,8 @@ const TabContent = ({
|
||||
|
||||
const _cleanup = () => {
|
||||
_isMounted = false;
|
||||
if(_postFetchTimer){
|
||||
clearTimeout(_postFetchTimer);
|
||||
if(postFetchTimer){
|
||||
clearTimeout(postFetchTimer);
|
||||
}
|
||||
if (isFeedScreen) {
|
||||
AppState.removeEventListener('change', _handleAppStateChange);
|
||||
@ -110,17 +114,22 @@ const TabContent = ({
|
||||
};
|
||||
|
||||
|
||||
const _initContent = (isFirstCall = false, feedUsername:string) => {
|
||||
const _initContent = (isFirstCall = false, _feedUsername:string) => {
|
||||
_scrollToTop();
|
||||
|
||||
const initialPosts = isFirstCall && isFeedScreen && isInitialTab ? initPosts : [];
|
||||
|
||||
setPosts(initialPosts);
|
||||
setTabMeta(DEFAULT_TAB_META)
|
||||
setSessionUser(username);
|
||||
setSessionUser(_feedUsername);
|
||||
setLatestPosts([]);
|
||||
|
||||
if(postFetchTimer){
|
||||
clearTimeout(postFetchTimer);
|
||||
}
|
||||
|
||||
if(username || (filterKey !== 'friends' && filterKey !== 'communities')){
|
||||
_loadPosts(!isFirstCall, false, feedUsername, initialPosts, DEFAULT_TAB_META );
|
||||
_loadPosts(!isFirstCall, false, _feedUsername, initialPosts, DEFAULT_TAB_META );
|
||||
_getPromotedPosts();
|
||||
}
|
||||
}
|
||||
@ -129,7 +138,7 @@ const TabContent = ({
|
||||
const _loadPosts = async (
|
||||
shouldReset:boolean = false,
|
||||
isLatestPostsCheck:boolean = false,
|
||||
_feedUsername:string = feedUsername,
|
||||
_feedUsername:string = isFeedScreen? sessionUserRef.current:feedUsername,
|
||||
_posts:any[] = postsRef.current,
|
||||
_tabMeta:TabMeta = tabMeta
|
||||
) => {
|
||||
@ -177,17 +186,18 @@ const TabContent = ({
|
||||
//schedules post fetch
|
||||
const _scheduleLatestPostsCheck = (firstPost:any) => {
|
||||
if (firstPost) {
|
||||
if (_postFetchTimer) {
|
||||
clearTimeout(_postFetchTimer);
|
||||
if (postFetchTimer) {
|
||||
clearTimeout(postFetchTimer);
|
||||
}
|
||||
|
||||
const timeLeft = calculateTimeLeftForPostCheck(firstPost)
|
||||
_postFetchTimer = setTimeout(() => {
|
||||
const _postFetchTimer = setTimeout(() => {
|
||||
const isLatestPostsCheck = true;
|
||||
_loadPosts(false, isLatestPostsCheck);
|
||||
},
|
||||
timeLeft
|
||||
);
|
||||
setPostFetchTimer(_postFetchTimer)
|
||||
}
|
||||
};
|
||||
|
||||
@ -210,7 +220,9 @@ const TabContent = ({
|
||||
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 (isInitialTab) {
|
||||
dispatch(setInitPosts(updatedPosts));
|
||||
|
@ -111,6 +111,7 @@ const UpvoteContainer = (props) => {
|
||||
setIsVoted(true);
|
||||
}
|
||||
|
||||
setTotalPayout(totalPayout + amountNum);
|
||||
//update redux
|
||||
const postId = get(content, 'post_id');
|
||||
const vote = {
|
||||
|
@ -106,6 +106,7 @@ const CommunityScreen = ({ navigation }) => {
|
||||
filterOptionsValue={GLOBAL_POST_FILTERS_VALUE}
|
||||
selectedOptionIndex={_getSelectedIndex()}
|
||||
tag={tag}
|
||||
imagesToggleEnabled={true}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
@ -69,6 +69,7 @@ const TagResultScreen = ({ navigation }) => {
|
||||
filterOptionsValue={GLOBAL_POST_FILTERS_VALUE}
|
||||
selectedOptionIndex={_getSelectedIndex()}
|
||||
tag={tag}
|
||||
imagesToggleEnabled={true}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
Loading…
Reference in New Issue
Block a user