Improving groups

This commit is contained in:
Adolfo Reyna
2023-01-22 22:47:48 -05:00
parent 9b20377f87
commit acab0eef66
3 changed files with 32 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
import React, { useEffect } from "react";
import { Searchbar } from 'react-native-paper';
import { Searchbar, Title } from 'react-native-paper';
import { StyleSheet, SafeAreaView, FlatList } from 'react-native';
import API from "../API";
import GroupCard from "../components/GroupCard";
@@ -11,9 +11,9 @@ const Groups = () => {
useEffect(() => {
let subscribed = true;
API.getRecentGroups('').then((data) => {
API.getFollowingGroups('').then((data) => {
if (subscribed)
setGroups(data.groups || []);
setGroups(data?.groups || []);
});
return () => {
subscribed = false;
@@ -27,7 +27,7 @@ const Groups = () => {
if (queryTimer) clearTimeout(queryTimer);
let timerId = setTimeout(() => {
if (!query) {
return API.getRecentGroups('').then((data) => {
return API.getFollowingGroups('').then((data) => {
setGroups(data.groups || []);
});
}
@@ -50,11 +50,11 @@ const Groups = () => {
/>
<FlatList
contentContainerStyle={styles.container}
numColumns={2}
columnWrapperStyle={{ justifyContent: "space-evenly" }}
numColumns={1}
data={groups}
renderItem={renderProfile}
keyExtractor={item => item._id}
ListHeaderComponent={searchQuery ? <></> : <Title style={styles.title} >Groups you follow:</Title>}
/>
</SafeAreaView>
)
@@ -66,4 +66,11 @@ const styles = StyleSheet.create({
container: {
padding: 5,
},
title: {
padding: 10,
fontSize: 30,
marginTop: 15,
fontWeight: "bold",
color: "#777"
}
});