From b098ac029bc19efd762c6dc3fa0ec35dc05e25cd Mon Sep 17 00:00:00 2001 From: Michael <5672750+mibac138@users.noreply.github.com> Date: Tue, 16 Nov 2021 21:42:06 +0100 Subject: [PATCH] Fix displaying errors in GradeDetailsPresenter (#1600) --- .../ui/modules/grade/details/GradeDetailsPresenter.kt | 7 ++++++- .../ui/modules/message/tab/MessageTabPresenter.kt | 4 ++++ .../ui/modules/schoolandteachers/school/SchoolPresenter.kt | 5 +++++ .../modules/schoolandteachers/teacher/TeacherPresenter.kt | 5 +++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt index 9b9651e1c..54d4f461e 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt @@ -17,6 +17,7 @@ import io.github.wulkanowy.utils.AnalyticsHelper import io.github.wulkanowy.utils.afterLoading import io.github.wulkanowy.utils.flowWithResource import io.github.wulkanowy.utils.flowWithResourceIn +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.onEach import timber.log.Timber @@ -47,8 +48,8 @@ class GradeDetailsPresenter @Inject constructor( fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) { currentSemesterId = semesterId - loadData(semesterId, forceRefresh) if (!forceRefresh) view?.showErrorView(false) + loadData(semesterId, forceRefresh) } fun onGradeItemSelected(grade: Grade, position: Int) { @@ -198,6 +199,9 @@ class GradeDetailsPresenter @Inject constructor( enableSwipe(true) notifyParentDataLoaded(semesterId) } + }.catch { + errorHandler.dispatch(it) + view?.notifyParentDataLoaded(semesterId) }.launch() } @@ -214,6 +218,7 @@ class GradeDetailsPresenter @Inject constructor( setErrorDetails(message) showErrorView(true) showEmpty(false) + showProgress(false) } else showError(message, error) } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/message/tab/MessageTabPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/message/tab/MessageTabPresenter.kt index 9b76a7f08..f70a1bab7 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/message/tab/MessageTabPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/message/tab/MessageTabPresenter.kt @@ -161,6 +161,9 @@ class MessageTabPresenter @Inject constructor( enableSwipe(true) notifyParentDataLoaded() } + }.catch { + errorHandler.dispatch(it) + view?.notifyParentDataLoaded() }.launch() } @@ -171,6 +174,7 @@ class MessageTabPresenter @Inject constructor( setErrorDetails(message) showErrorView(true) showEmpty(false) + showProgress(false) } else showError(message, error) } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/school/SchoolPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/school/SchoolPresenter.kt index 202d4e5d7..ac8c273ea 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/school/SchoolPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/school/SchoolPresenter.kt @@ -9,6 +9,7 @@ import io.github.wulkanowy.ui.base.ErrorHandler import io.github.wulkanowy.utils.AnalyticsHelper import io.github.wulkanowy.utils.afterLoading import io.github.wulkanowy.utils.flowWithResourceIn +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.onEach import timber.log.Timber import javax.inject.Inject @@ -100,6 +101,9 @@ class SchoolPresenter @Inject constructor( enableSwipe(true) notifyParentDataLoaded() } + }.catch { + errorHandler.dispatch(it) + view?.notifyParentDataLoaded() }.launch() } @@ -111,6 +115,7 @@ class SchoolPresenter @Inject constructor( showErrorView(true) showEmpty(false) showContent(false) + showProgress(false) } else showError(message, error) } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/teacher/TeacherPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/teacher/TeacherPresenter.kt index c83cfe766..bd46ff0b2 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/teacher/TeacherPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/schoolandteachers/teacher/TeacherPresenter.kt @@ -9,6 +9,7 @@ import io.github.wulkanowy.ui.base.ErrorHandler import io.github.wulkanowy.utils.AnalyticsHelper import io.github.wulkanowy.utils.afterLoading import io.github.wulkanowy.utils.flowWithResourceIn +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.onEach import timber.log.Timber import javax.inject.Inject @@ -85,6 +86,9 @@ class TeacherPresenter @Inject constructor( enableSwipe(true) notifyParentDataLoaded() } + }.catch { + errorHandler.dispatch(it) + view?.notifyParentDataLoaded() }.launch() } @@ -95,6 +99,7 @@ class TeacherPresenter @Inject constructor( setErrorDetails(message) showErrorView(true) showEmpty(false) + showProgress(false) } else showError(message, error) } }