Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
fix the overview so only courses of current semester is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainaamr committed Feb 2, 2024
1 parent 1203fa2 commit b6ec826
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/views/course_view/courses_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:gocast_mobile/providers.dart';
import 'package:gocast_mobile/utils/section_kind.dart';
import 'package:gocast_mobile/utils/sort_utils.dart';
import 'package:gocast_mobile/views/components/base_view.dart';
import 'package:gocast_mobile/views/course_view/components/course_section.dart';
import 'package:gocast_mobile/views/course_view/components/live_stream_section.dart';
Expand Down Expand Up @@ -49,6 +50,12 @@ class CourseOverviewState extends ConsumerState<CourseOverview> {
}
final userCourses = ref.watch(userViewModelProvider).userCourses ?? [];
final publicCourses = ref.watch(userViewModelProvider).publicCourses ?? [];
final currentSemester =
ref.watch(userViewModelProvider).currentAsString ?? "All";
final userCoursesCurrent =
CourseUtils.filterCoursesBySemester(userCourses, currentSemester);
final publicCoursesCurrent =
CourseUtils.filterCoursesBySemester(publicCourses, currentSemester);
final liveStreams = ref.watch(videoViewModelProvider).liveStreams;
final liveStreamWithThumb =
ref.watch(videoViewModelProvider).liveStreamsWithThumb ?? [];
Expand Down Expand Up @@ -76,7 +83,7 @@ class CourseOverviewState extends ConsumerState<CourseOverview> {
child: LiveStreamSection(
ref: ref,
sectionTitle: AppLocalizations.of(context)!.live_now,
courses: (userCourses) + (publicCourses),
courses: (userCoursesCurrent) + (publicCoursesCurrent),
streams: liveStreamWithThumb,
),
),
Expand All @@ -88,15 +95,15 @@ class CourseOverviewState extends ConsumerState<CourseOverview> {
child: _buildSection(
AppLocalizations.of(context)!.my_courses,
SectionKind.myCourses,
userCourses,
userCoursesCurrent,
liveStreams,
),
),
Expanded(
child: _buildSection(
AppLocalizations.of(context)!.public_courses,
SectionKind.publicCourses,
publicCourses,
publicCoursesCurrent,
liveStreams,
),
),
Expand All @@ -106,13 +113,13 @@ class CourseOverviewState extends ConsumerState<CourseOverview> {
_buildSection(
AppLocalizations.of(context)!.my_courses,
SectionKind.myCourses,
userCourses,
userCoursesCurrent,
liveStreams,
),
_buildSection(
AppLocalizations.of(context)!.public_courses,
SectionKind.publicCourses,
publicCourses,
publicCoursesCurrent,
liveStreams,
),
],
Expand Down

0 comments on commit b6ec826

Please sign in to comment.