aboutsummaryrefslogtreecommitdiff
path: root/src/screens
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-03-12 14:17:55 -0500
committerIvan Chen <ivan@tagg.id>2021-03-12 14:17:55 -0500
commit4a05b26c5c32980ac18c832cc4dd74c6c93922a8 (patch)
treece2c0e37f545d6167ffc2dc024dd2683648c9bdc /src/screens
parentb568f553c4ee2f0452f6bb7ab7b03c84d77c15ab (diff)
using discover/get_users, updated route params, cleaned up code
Diffstat (limited to 'src/screens')
-rw-r--r--src/screens/search/DiscoverUsers.tsx34
-rw-r--r--src/screens/search/SearchScreen.tsx22
2 files changed, 36 insertions, 20 deletions
diff --git a/src/screens/search/DiscoverUsers.tsx b/src/screens/search/DiscoverUsers.tsx
index a9856909..d67e5448 100644
--- a/src/screens/search/DiscoverUsers.tsx
+++ b/src/screens/search/DiscoverUsers.tsx
@@ -29,8 +29,7 @@ interface DiscoverUsersProps {
}
const DiscoverUsers: React.FC<DiscoverUsersProps> = ({route}) => {
- const {type: category_type} = route.params;
- const {id, name} = route.params.searchCategory;
+ const {name} = route.params.searchCategory;
const [categoryName, setCategoryName] = useState<string | undefined>();
const [users, setUsers] = useState<ProfilePreviewType[]>([]);
const [shouldRefresh, setShouldRefresh] = useState(false);
@@ -43,15 +42,15 @@ const DiscoverUsers: React.FC<DiscoverUsersProps> = ({route}) => {
thumbnail_url: '',
});
const dummyUsers = [
- mtUser(1),
- mtUser(2),
- mtUser(3),
- mtUser(4),
- mtUser(5),
- mtUser(6),
- mtUser(7),
- mtUser(8),
- mtUser(9),
+ mtUser(-1),
+ mtUser(-2),
+ mtUser(-3),
+ mtUser(-4),
+ mtUser(-5),
+ mtUser(-6),
+ mtUser(-7),
+ mtUser(-8),
+ mtUser(-9),
];
const [loading, setLoading] = useState(true);
const navigation = useNavigation();
@@ -94,7 +93,13 @@ const DiscoverUsers: React.FC<DiscoverUsersProps> = ({route}) => {
useEffect(() => {
const loadData = async () => {
setLoading(true);
- setUsers(await getDiscoverUsers(id, category_type));
+ if (!categoryName) {
+ return;
+ }
+ const fetched_users = await getDiscoverUsers(categoryName);
+ if (fetched_users) {
+ setUsers(fetched_users);
+ }
setLoading(false);
};
loadData();
@@ -122,10 +127,7 @@ const DiscoverUsers: React.FC<DiscoverUsersProps> = ({route}) => {
ListFooterComponent={() => (
<>
<Text style={styles.otherGroups}>Other Groups</Text>
- <SearchCategories
- darkStyle={true}
- // callBack={(category) => setCategoryName(category)}
- />
+ <SearchCategories darkStyle={true} />
</>
)}
/>
diff --git a/src/screens/search/SearchScreen.tsx b/src/screens/search/SearchScreen.tsx
index 728510c5..f9a42d86 100644
--- a/src/screens/search/SearchScreen.tsx
+++ b/src/screens/search/SearchScreen.tsx
@@ -17,7 +17,12 @@ import {SEARCH_ENDPOINT, TAGG_LIGHT_BLUE} from '../../constants';
import {loadSearchResults} from '../../services';
import {resetScreenType} from '../../store/actions';
import {RootState} from '../../store/rootReducer';
-import {ProfilePreviewType, ScreenType, CategoryPreviewType} from '../../types';
+import {
+ ProfilePreviewType,
+ ScreenType,
+ CategoryPreviewType,
+ SearchCategoryType,
+} from '../../types';
import {normalize, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils';
/**
@@ -37,6 +42,11 @@ const SearchScreen: React.FC = () => {
>([]);
const [searching, setSearching] = useState(false);
const top = Animated.useValue(-SCREEN_HEIGHT);
+ const defaultButtons: SearchCategoryType[] = [21, 22, 23, 24].map((year) => ({
+ id: -1,
+ name: `Brown '${year}`,
+ category: 'Brown',
+ }));
const [keyboardVisible, setKeyboardVisible] = React.useState(
'keyboardVisible',
);
@@ -57,8 +67,12 @@ const SearchScreen: React.FC = () => {
* Main handler for changes in query.
*/
useEffect(() => {
- if (!searching) return;
- if (!query.length) loadRecentSearches();
+ if (!searching) {
+ return;
+ }
+ if (!query.length) {
+ loadRecentSearches();
+ }
if (query.length < 3) {
setResults(undefined);
return;
@@ -181,7 +195,7 @@ const SearchScreen: React.FC = () => {
stickyHeaderIndices={[4]}
contentContainerStyle={styles.contentContainer}
showsVerticalScrollIndicator={false}>
- <SearchCategories />
+ <SearchCategories defaultButtons={defaultButtons} />
<SearchResultsBackground {...{top}}>
{results === undefined &&
recents.length + recentCategories.length !== 0 ? (