Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bahugunajii committed Nov 25, 2024
1 parent 33ead2e commit 2073b39
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ export default function Home() {

const fetchUserSessions = async () => {
try {
const groupConfig = getGroupConfig(group || 'defaultGroup');
const shouldFetchQuizzes = groupConfig.showTests || groupConfig.showPracticeTests || groupConfig.showHomework;

const [liveSessionData, quizSessionData] = await Promise.all([
groupConfig.showLiveClasses ? fetchUserSession(userDbId!) : Promise.resolve([]),
groupConfig.showTests || groupConfig.showPracticeTests || groupConfig.showHomework
? fetchUserSession(userDbId!, true)
: Promise.resolve([])
shouldFetchQuizzes ? fetchUserSession(userDbId!, true) : Promise.resolve([])
]);

if (groupConfig.showTests || groupConfig.showPracticeTests || groupConfig.showHomework) {
if (quizSessionData.length > 0) {
const quizData = await Promise.all(quizSessionData.map(async (quiz: Session) => {
const sessionOccurrenceData = await getSessionOccurrences(quiz.session_id);
if (!sessionOccurrenceData) return null;
Expand All @@ -100,7 +101,7 @@ export default function Home() {
setQuizzes(quizSessions);
}

if (groupConfig.showLiveClasses && liveSessionData.length > 0) {
if (liveSessionData.length > 0) {
const sessionsData = await Promise.all(liveSessionData.map(async (liveSession: Session) => {
const sessionOccurrenceData = await getSessionOccurrences(liveSession.session_id);
if (!sessionOccurrenceData) return null;
Expand Down

0 comments on commit 2073b39

Please sign in to comment.