Valtio and new tab menu

This commit is contained in:
aeroreyna
2022-03-24 22:00:00 -07:00
parent 0bee9204f2
commit 296c153b47
13 changed files with 93 additions and 66 deletions

View File

@@ -4,6 +4,8 @@ import { ScrollView, ActivityIndicator, StyleSheet, SafeAreaView, FlatList } fro
import { Title } from 'react-native-paper';
import API from "../API";
import CourseCard from "../components/CourseCard";
import { useSnapshot } from 'valtio';
import GlobalState from '../contexts/GlobalState.js';
const getCourses = async (profileObj) => {
@@ -48,7 +50,8 @@ const getCourses = async (profileObj) => {
}
const Courses = () => {
const [Me, setMeProfile] = React.useState({});
const gState = useSnapshot(GlobalState);
const viewer = gState.me;
const [searchQuery, setSearchQuery] = React.useState('');
const [groups, setGroups] = React.useState([]);
const [popular, setPopular] = React.useState([]);
@@ -56,12 +59,7 @@ const Courses = () => {
const [queryTimer, setQueryTimer] = React.useState(0);
useEffect(async () => {
let Me = await API.getMe();
setMeProfile(Me);
//API.getCourses('').then((data) => {
// setGroups(data.groups || []);
//});
let r = await getCourses(Me);
let r = await getCourses(viewer);
setGroups(r.courses || []);
setPopular(r.popular || []);
setWatching(r.watching || []);