diff --git a/lib/views/course_view/list_courses_view/courses_list_view.dart b/lib/views/course_view/list_courses_view/courses_list_view.dart index 521d632..437e136 100644 --- a/lib/views/course_view/list_courses_view/courses_list_view.dart +++ b/lib/views/course_view/list_courses_view/courses_list_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:gocast_mobile/base/networking/api/gocast/api_v2.pbgrpc.dart'; +import 'package:gocast_mobile/providers.dart'; import 'package:gocast_mobile/utils/constants.dart'; import 'package:gocast_mobile/views/course_view/components/course_card.dart'; @@ -29,7 +30,7 @@ class CoursesList extends ConsumerWidget { bool isTablet = MediaQuery.of(context).size.width >= 600; return courses.isEmpty ? _buildPlaceholder() - : _buildCourseListView(context, isTablet); + : _buildCourseListView(context, isTablet, ref); } Padding _buildPlaceholder() { @@ -39,7 +40,10 @@ class CoursesList extends ConsumerWidget { ); } - Widget _buildCourseListView(BuildContext context, bool isTablet) { + Widget _buildCourseListView(BuildContext context, bool isTablet, WidgetRef ref) { + final liveStreams = ref.watch(videoViewModelProvider).liveStreams ?? []; + var liveCourseIds = liveStreams.map((stream) => stream.courseID).toSet(); + List liveCourses = courses.where((course) => liveCourseIds.contains(course.id)).toList(); return ConstrainedBox( constraints: BoxConstraints(maxHeight: isTablet ? 600 : 400), child: ListView.builder( @@ -53,7 +57,7 @@ class CoursesList extends ConsumerWidget { title: course.name, tumID: course.tUMOnlineIdentifier, path: 'assets/images/course2.png', - live: course.streams.any((stream) => stream.liveNow), + live: liveCourses.contains(course), courseId: course.id, semester: course.semester.teachingTerm + course.semester.year.toString(), diff --git a/lib/views/course_view/pinned_courses_view/pinned_courses_view.dart b/lib/views/course_view/pinned_courses_view/pinned_courses_view.dart index d92240f..d976549 100644 --- a/lib/views/course_view/pinned_courses_view/pinned_courses_view.dart +++ b/lib/views/course_view/pinned_courses_view/pinned_courses_view.dart @@ -69,6 +69,9 @@ class PinnedCoursesState extends ConsumerState { @override Widget build(BuildContext context) { final userPinned = ref.watch(userViewModelProvider).displayedCourses ?? []; + final liveStreams = ref.watch(videoViewModelProvider).liveStreams ?? []; + var liveCourseIds = liveStreams.map((stream) => stream.courseID).toSet(); + List liveCourses = userPinned.where((course) => liveCourseIds.contains(course.id)).toList(); final filterOptions = ref.watch(userViewModelProvider).semestersAsString ?? []; return Scaffold( @@ -85,6 +88,7 @@ class PinnedCoursesState extends ConsumerState { final isPinned = userPinned.any((pinnedCourse) => pinnedCourse.id == course.id); return CourseCard( + live: liveCourses.contains(course), isCourse: true, title: course.name, courseId: course.id, @@ -110,7 +114,7 @@ class PinnedCoursesState extends ConsumerState { ); } - Future _togglePin(Course course, bool isPinned) async { + /*Future _togglePin(Course course, bool isPinned) async { final viewModel = ref.read(userViewModelProvider.notifier); if (isPinned) { await viewModel.unpinCourse(course.id); @@ -118,7 +122,7 @@ class PinnedCoursesState extends ConsumerState { await viewModel.pinCourse(course.id); } await _refreshPinnedCourses(); - } + }*/ VideoSourceType determineSourceType(String videoSource) { return videoSource.startsWith('http')