Skip to content

Commit

Permalink
fix the bug where the selected semester when filter option is selecte…
Browse files Browse the repository at this point in the history
…d in detail course view
  • Loading branch information
Sainaamr committed Feb 2, 2024
1 parent 7f437ac commit 2d7e0e3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 0 additions & 3 deletions lib/views/components/filter_popup_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class FilterPopupMenuButton extends ConsumerWidget {

return PopupMenuButton<String>(
onSelected: (choice) {
// When an item is selected, update both providers to ensure they stay in sync
ref.read(userViewModelProvider.notifier).setSelectedSemester(choice);
ref.read(pinnedCourseViewModelProvider.notifier).setSelectedSemester(choice);
onClick(choice);
},
itemBuilder: (BuildContext context) {
Expand Down
3 changes: 3 additions & 0 deletions lib/views/course_view/list_courses_view/my_courses_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class MyCoursesState extends ConsumerState<MyCourses> {

void filterCoursesBySemester(String selectedSemester) {
var allUserCourses = ref.watch(userViewModelProvider).userCourses ?? [];
ref
.read(pinnedCourseViewModelProvider.notifier)
.setSelectedSemester(selectedSemester);
ref
.read(userViewModelProvider.notifier)
.updateSelectedSemester(selectedSemester, allUserCourses);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class PublicCoursesState extends ConsumerState<PublicCourses> {

void filterCoursesBySemester(String selectedSemester) {
var allUserCourses = ref.watch(userViewModelProvider).publicCourses ?? [];
ref
.read(pinnedCourseViewModelProvider.notifier)
.setSelectedSemester(selectedSemester);
ref
.read(userViewModelProvider.notifier)
.updateSelectedSemester(selectedSemester, allUserCourses);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class PinnedCoursesState extends ConsumerState<PinnedCourses> {
}

void filterCoursesBySemester(String selectedSemester) {
ref
.read(userViewModelProvider.notifier)
.setSelectedSemester(selectedSemester);
var userPinned = ref.watch(pinnedCourseViewModelProvider).userPinned ?? [];
ref
.read(pinnedCourseViewModelProvider.notifier)
Expand Down

0 comments on commit 2d7e0e3

Please sign in to comment.