Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
fix: Shift date snackbar reappears on screen rotation
Browse files Browse the repository at this point in the history
fixes: LEARNER-9625
  • Loading branch information
omerhabib26 committed Sep 27, 2023
1 parent 9f6d892 commit 84bd02a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class CourseTabsDashboardFragment : BaseFragment() {
}
})

courseDateViewModel.resetCourseDates.observe(viewLifecycleOwner, NonNullObserver {
courseDateViewModel.resetCourseDates.observe(viewLifecycleOwner, EventObserver {
if (!CalendarUtils.isCalendarExists(contextOrThrow, accountName, calendarTitle)) {
showShiftDateSnackBar(true)
binding.toolbar.datesBanner.root.setVisibility(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,15 @@ private void initObserver() {
PreLoadingListener.State.MAIN_UNIT_LOADING :
PreLoadingListener.State.MAIN_UNIT_LOADED));

courseDateViewModel.getResetCourseDates().observe(getViewLifecycleOwner(), resetCourseDates -> {
courseDateViewModel.getResetCourseDates().observe(getViewLifecycleOwner(), new EventObserver<>(resetCourseDates -> {
if (resetCourseDates != null) {
binding.authWebview.loadUrl(true, unit.getBlockUrl());
if (!CalendarUtils.INSTANCE.isCalendarExists(getContextOrThrow(), accountName, calendarTitle)) {
showShiftDateSnackBar(true);
}
}
});
return null;
}));

courseDateViewModel.getErrorMessage().observe(getViewLifecycleOwner(), errorMessage -> {
if (errorMessage != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class CourseDateViewModel @Inject constructor(
val bannerInfo: LiveData<CourseBannerInfoModel?>
get() = _bannerInfo

private val _resetCourseDates = MutableLiveData<ResetCourseDates?>()
val resetCourseDates: LiveData<ResetCourseDates?>
private val _resetCourseDates = MutableLiveData<Event<ResetCourseDates?>>()
val resetCourseDates: LiveData<Event<ResetCourseDates?>>
get() = _resetCourseDates

private val _errorMessage = MutableLiveData<ErrorMessage?>()
Expand Down Expand Up @@ -182,7 +182,7 @@ class CourseDateViewModel @Inject constructor(
callback = object : NetworkResponseCallback<ResetCourseDates> {
override fun onSuccess(result: Result.Success<ResetCourseDates>) {
if (result.isSuccessful && result.data != null) {
_resetCourseDates.postValue(result.data)
_resetCourseDates.postEvent(result.data)
fetchCourseDates(
courseId,
forceRefresh = true,
Expand Down

0 comments on commit 84bd02a

Please sign in to comment.