mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-23 13:22:02 +03:00
Merge pull request #1790 from ecency/feature/subfilter-for-feed
Add subfilters for feed
This commit is contained in:
commit
6d5df4e6e0
@ -42,6 +42,7 @@
|
||||
05B6C4AF24C306CE00B7FA60 /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34E88D888DD444F8B285363C /* SimpleLineIcons.ttf */; };
|
||||
05B6C4B024C306CE00B7FA60 /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 980BC9BC0D3B4AC69645C842 /* Zocial.ttf */; };
|
||||
0A1D279E0D3CD306C889592E /* libPods-Ecency-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7093E51BBC0EE2F41AB19EBA /* libPods-Ecency-tvOS.a */; };
|
||||
1CD0B89E258019B600A7D78E /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1CD0B89B258019B600A7D78E /* GoogleService-Info.plist */; };
|
||||
2B3CF3607B7CB9B7296FD5EF /* (null) in Frameworks */ = {isa = PBXBuildFile; };
|
||||
2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
|
||||
2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
|
||||
@ -125,6 +126,7 @@
|
||||
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Ecency/Info.plist; sourceTree = "<group>"; };
|
||||
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Ecency/main.m; sourceTree = "<group>"; };
|
||||
150E6CAFA5EF11AE47ED825C /* Pods-RnDiffAppTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RnDiffAppTests.release.xcconfig"; path = "Target Support Files/Pods-RnDiffAppTests/Pods-RnDiffAppTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
1CD0B89B258019B600A7D78E /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
|
||||
22F5F05A06E142C2B41A4D38 /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf"; sourceTree = "<group>"; };
|
||||
263FA8C0EF21473FAAAD3EDD /* MaterialIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf"; sourceTree = "<group>"; };
|
||||
2D02E47B1E0B4A5D006451C7 /* Ecency-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Ecency-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@ -373,6 +375,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
588019232355C26B008397D1 /* AppCenter-Config.plist */,
|
||||
1CD0B89B258019B600A7D78E /* GoogleService-Info.plist */,
|
||||
13B07FAE1A68108700A75B9A /* Ecency */,
|
||||
832341AE1AAA6A7D00B99B32 /* Libraries */,
|
||||
00E356EF1AD99517003FC87E /* EcencyTests */,
|
||||
@ -617,6 +620,7 @@
|
||||
05B6C49F24C306CE00B7FA60 /* Roboto-medium.ttf in Resources */,
|
||||
05B6C4A024C306CE00B7FA60 /* FontAwesome5_Regular.ttf in Resources */,
|
||||
05B6C4A124C306CE00B7FA60 /* FontAwesome5_Solid.ttf in Resources */,
|
||||
1CD0B89E258019B600A7D78E /* GoogleService-Info.plist in Resources */,
|
||||
05B6C4A224C306CE00B7FA60 /* Fontisto.ttf in Resources */,
|
||||
05B6C4A324C306CE00B7FA60 /* RobotoMono-Regular.ttf in Resources */,
|
||||
05B6C4A424C306CE00B7FA60 /* Sansation_Bold.ttf in Resources */,
|
||||
|
@ -708,4 +708,4 @@ SPEC CHECKSUMS:
|
||||
|
||||
PODFILE CHECKSUM: 1f30c7da5061dbc47185442a6ab4a3c95ac48c04
|
||||
|
||||
COCOAPODS: 1.9.3
|
||||
COCOAPODS: 1.9.1
|
||||
|
@ -28,6 +28,8 @@ const PostsContainer = ({
|
||||
tag,
|
||||
filterOptionsValue,
|
||||
feedUsername,
|
||||
feedSubfilterOptions,
|
||||
feedSubfilterOptionsValue,
|
||||
}) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
@ -50,6 +52,11 @@ const PostsContainer = ({
|
||||
const [selectedFilterValue, setSelectedFilterValue] = useState(
|
||||
filterOptionsValue && filterOptionsValue[selectedFilterIndex],
|
||||
);
|
||||
const [selectedFeedSubfilterIndex, setSelectedFeedSubfilterIndex] = useState(0);
|
||||
const [selectedFeedSubfilterValue, setSelectedFeedSubfilterValue] = useState(
|
||||
feedSubfilterOptionsValue && feedSubfilterOptions[selectedFeedSubfilterIndex],
|
||||
);
|
||||
|
||||
const elem = useRef(null);
|
||||
const isMountedRef = useIsMountedRef();
|
||||
|
||||
@ -67,6 +74,7 @@ const PostsContainer = ({
|
||||
isConnected,
|
||||
pageType,
|
||||
selectedOptionIndex,
|
||||
selectedFeedSubfilterIndex,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
@ -75,6 +83,7 @@ const PostsContainer = ({
|
||||
setStartAuthor('');
|
||||
setStartPermlink('');
|
||||
setSelectedFilterIndex(selectedOptionIndex || 0);
|
||||
isLoggedIn && setSelectedFeedSubfilterIndex(selectedFeedSubfilterIndex || 0);
|
||||
setIsNoPost(false);
|
||||
|
||||
_loadPosts();
|
||||
@ -83,7 +92,14 @@ const PostsContainer = ({
|
||||
changeForceLoadPostState(false);
|
||||
}
|
||||
}
|
||||
}, [_loadPosts, changeForceLoadPostState, username, forceLoadPost, selectedOptionIndex]);
|
||||
}, [
|
||||
_loadPosts,
|
||||
changeForceLoadPostState,
|
||||
username,
|
||||
forceLoadPost,
|
||||
selectedOptionIndex,
|
||||
selectedFeedSubfilterIndex,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!startAuthor && !startPermlink) {
|
||||
@ -146,6 +162,7 @@ const PostsContainer = ({
|
||||
}
|
||||
|
||||
const filter = type || selectedFilterValue;
|
||||
const subfilter = selectedFeedSubfilterValue;
|
||||
let options = {};
|
||||
const limit = 7;
|
||||
let func = null;
|
||||
@ -157,8 +174,17 @@ const PostsContainer = ({
|
||||
getFor === 'blog' ||
|
||||
filter === 'reblogs'
|
||||
) {
|
||||
if (filter === 'feed' && subfilter === 'communities') {
|
||||
func = getRankedPosts;
|
||||
options = {
|
||||
observer: feedUsername,
|
||||
sort: 'trending',
|
||||
tag: 'my',
|
||||
};
|
||||
} else {
|
||||
func = getAccountPosts;
|
||||
options = {
|
||||
observer: feedUsername || '',
|
||||
account: feedUsername,
|
||||
limit,
|
||||
sort: filter,
|
||||
@ -167,6 +193,7 @@ const PostsContainer = ({
|
||||
if (pageType === 'profiles' && (filter === 'feed' || filter === 'posts')) {
|
||||
options.sort = 'posts';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
func = getRankedPosts;
|
||||
options = {
|
||||
@ -241,7 +268,7 @@ const PostsContainer = ({
|
||||
_getPromotePosts();
|
||||
};
|
||||
|
||||
const _handleOnDropdownSelect = (index) => {
|
||||
const _handleFilterOnDropdownSelect = (index) => {
|
||||
setSelectedFilterIndex(index);
|
||||
setPosts([]);
|
||||
setStartPermlink('');
|
||||
@ -249,6 +276,14 @@ const PostsContainer = ({
|
||||
setIsNoPost(false);
|
||||
};
|
||||
|
||||
const _handleFeedSubfilterOnDropdownSelect = (index) => {
|
||||
setSelectedFeedSubfilterIndex(index);
|
||||
setPosts([]);
|
||||
setStartPermlink('');
|
||||
setStartAuthor('');
|
||||
setIsNoPost(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<PostsView
|
||||
ref={elem}
|
||||
@ -269,9 +304,14 @@ const PostsContainer = ({
|
||||
promotedPosts={promotedPosts}
|
||||
selectedFilterValue={selectedFilterValue}
|
||||
setSelectedFilterValue={setSelectedFilterValue}
|
||||
handleOnDropdownSelect={_handleOnDropdownSelect}
|
||||
handleFilterOnDropdownSelect={_handleFilterOnDropdownSelect}
|
||||
loadPosts={_loadPosts}
|
||||
handleOnRefreshPosts={_handleOnRefreshPosts}
|
||||
feedSubfilterOptions={feedSubfilterOptions}
|
||||
selectedFeedSubfilterIndex={selectedFeedSubfilterIndex}
|
||||
feedSubfilterOptionsValue={feedSubfilterOptionsValue}
|
||||
handleFeedSubfilterOnDropdownSelect={_handleFeedSubfilterOnDropdownSelect}
|
||||
setSelectedFeedSubfilterValue={setSelectedFeedSubfilterValue}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
@ -35,14 +35,19 @@ const PostsView = ({
|
||||
selectedFilterValue,
|
||||
setSelectedFilterValue,
|
||||
filterOptionsValue,
|
||||
handleOnDropdownSelect,
|
||||
handleFilterOnDropdownSelect,
|
||||
handleOnRefreshPosts,
|
||||
loadPosts,
|
||||
feedSubfilterOptions,
|
||||
selectedFeedSubfilterIndex,
|
||||
feedSubfilterOptionsValue,
|
||||
handleFeedSubfilterOnDropdownSelect,
|
||||
setSelectedFeedSubfilterValue,
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const postsList = useRef(null);
|
||||
|
||||
const _handleOnDropdownSelect = async (index) => {
|
||||
const _handleFilterOnDropdownSelect = async (index) => {
|
||||
if (index === selectedFilterIndex) {
|
||||
_scrollTop();
|
||||
} else {
|
||||
@ -50,7 +55,19 @@ const PostsView = ({
|
||||
setSelectedFilterValue(filterOptionsValue[index]);
|
||||
}
|
||||
|
||||
handleOnDropdownSelect(index);
|
||||
handleFilterOnDropdownSelect(index);
|
||||
}
|
||||
};
|
||||
|
||||
const _handleFeedSubfilterOnDropdownSelect = async (index) => {
|
||||
if (index === selectedFeedSubfilterIndex) {
|
||||
_scrollTop();
|
||||
} else {
|
||||
if (feedSubfilterOptions && feedSubfilterOptions.length > 0) {
|
||||
setSelectedFeedSubfilterValue(feedSubfilterOptionsValue[index]);
|
||||
}
|
||||
|
||||
handleFeedSubfilterOnDropdownSelect(index);
|
||||
}
|
||||
};
|
||||
|
||||
@ -93,7 +110,12 @@ const PostsView = ({
|
||||
id: 'profile.havent_posted',
|
||||
})}
|
||||
defaultText={intl.formatMessage({
|
||||
id: selectedFilterValue === 'feed' ? 'profile.follow_people' : 'profile.havent_posted',
|
||||
id:
|
||||
selectedFilterValue === 'feed'
|
||||
? setSelectedFeedSubfilterValue === 'friends'
|
||||
? 'profile.follow_people'
|
||||
: 'profile.follow_communities'
|
||||
: 'profile.havent_posted',
|
||||
})}
|
||||
/>
|
||||
);
|
||||
@ -169,10 +191,21 @@ const PostsView = ({
|
||||
defaultText={filterOptions[selectedOptionIndex]}
|
||||
rightIconName="view-module"
|
||||
rightIconType="MaterialIcons"
|
||||
onDropdownSelect={_handleOnDropdownSelect}
|
||||
onDropdownSelect={_handleFilterOnDropdownSelect}
|
||||
onRightIconPress={handleImagesHide}
|
||||
/>
|
||||
)}
|
||||
{isLoggedIn && selectedFilterValue === 'feed' && (
|
||||
<FilterBar
|
||||
dropdownIconName="arrow-drop-down"
|
||||
options={feedSubfilterOptions.map((item) =>
|
||||
intl.formatMessage({ id: `home.${item.toLowerCase()}` }).toUpperCase(),
|
||||
)}
|
||||
selectedOptionIndex={selectedFeedSubfilterIndex}
|
||||
defaultText={feedSubfilterOptions[selectedFeedSubfilterIndex]}
|
||||
onDropdownSelect={_handleFeedSubfilterOnDropdownSelect}
|
||||
/>
|
||||
)}
|
||||
|
||||
<FlatList
|
||||
ref={postsList}
|
||||
|
@ -159,6 +159,7 @@
|
||||
"voting_power": "Voting power",
|
||||
"login_to_see": "Login to see",
|
||||
"follow_people": "Follow some people to fill your feed",
|
||||
"follow_communities": "Join some communities to fill your feed",
|
||||
"havent_commented": "haven't commented anything yet",
|
||||
"havent_posted": "haven't posted anything yet",
|
||||
"steem_power": "Hive Power",
|
||||
@ -239,7 +240,9 @@
|
||||
"hot": "Hot",
|
||||
"new": "New",
|
||||
"blog": "Blog",
|
||||
"posts": "Posts"
|
||||
"posts": "Posts",
|
||||
"friends": "Friends",
|
||||
"communities": "Communities"
|
||||
},
|
||||
"side_menu": {
|
||||
"profile": "Profile",
|
||||
|
@ -1,6 +1,9 @@
|
||||
export const POPULAR_FILTERS = ['FEED', 'TOP', 'HOT', 'NEW'];
|
||||
export const POPULAR_FILTERS_VALUE = ['feed', 'trending', 'hot', 'created'];
|
||||
|
||||
export const FEED_SUBFILTERS = ['FRIENDS', 'COMMUNITIES'];
|
||||
export const FEED_SUBFILTERS_VALUE = ['friends', 'communities'];
|
||||
|
||||
export const GLOBAL_POST_FILTERS = ['TOP', 'HOT', 'NEW'];
|
||||
export const GLOBAL_POST_FILTERS_VALUE = ['trending', 'hot', 'created'];
|
||||
|
||||
|
@ -11,7 +11,12 @@ import { AccountContainer } from '../../../containers';
|
||||
// Styles
|
||||
import styles from './feedStyles';
|
||||
|
||||
import { POPULAR_FILTERS, POPULAR_FILTERS_VALUE } from '../../../constants/options/filters';
|
||||
import {
|
||||
POPULAR_FILTERS,
|
||||
POPULAR_FILTERS_VALUE,
|
||||
FEED_SUBFILTERS,
|
||||
FEED_SUBFILTERS_VALUE,
|
||||
} from '../../../constants/options/filters';
|
||||
|
||||
const FeedScreen = () => {
|
||||
return (
|
||||
@ -23,9 +28,11 @@ const FeedScreen = () => {
|
||||
<Posts
|
||||
filterOptions={[...POPULAR_FILTERS]}
|
||||
filterOptionsValue={[...POPULAR_FILTERS_VALUE]}
|
||||
feedSubfilterOptions={[...FEED_SUBFILTERS]}
|
||||
feedSubfilterOptionsValue={[...FEED_SUBFILTERS_VALUE]}
|
||||
getFor={get(currentAccount, 'name', null) ? 'feed' : 'hot'}
|
||||
selectedOptionIndex={get(currentAccount, 'name', null) ? 0 : 2}
|
||||
feedUsername={get(currentAccount, 'name')}
|
||||
feedUsername={get(currentAccount, 'name', null)}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
</Fragment>
|
||||
|
Loading…
Reference in New Issue
Block a user