1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 09:39:09 -05:00

Fix displaying errors in GradeDetailsPresenter (#1600)

This commit is contained in:
Michael 2021-11-16 21:42:06 +01:00 committed by GitHub
parent 7e0e2fbb67
commit b098ac029b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import io.github.wulkanowy.utils.AnalyticsHelper
import io.github.wulkanowy.utils.afterLoading import io.github.wulkanowy.utils.afterLoading
import io.github.wulkanowy.utils.flowWithResource import io.github.wulkanowy.utils.flowWithResource
import io.github.wulkanowy.utils.flowWithResourceIn import io.github.wulkanowy.utils.flowWithResourceIn
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import timber.log.Timber import timber.log.Timber
@ -47,8 +48,8 @@ class GradeDetailsPresenter @Inject constructor(
fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) { fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) {
currentSemesterId = semesterId currentSemesterId = semesterId
loadData(semesterId, forceRefresh)
if (!forceRefresh) view?.showErrorView(false) if (!forceRefresh) view?.showErrorView(false)
loadData(semesterId, forceRefresh)
} }
fun onGradeItemSelected(grade: Grade, position: Int) { fun onGradeItemSelected(grade: Grade, position: Int) {
@ -198,6 +199,9 @@ class GradeDetailsPresenter @Inject constructor(
enableSwipe(true) enableSwipe(true)
notifyParentDataLoaded(semesterId) notifyParentDataLoaded(semesterId)
} }
}.catch {
errorHandler.dispatch(it)
view?.notifyParentDataLoaded(semesterId)
}.launch() }.launch()
} }
@ -214,6 +218,7 @@ class GradeDetailsPresenter @Inject constructor(
setErrorDetails(message) setErrorDetails(message)
showErrorView(true) showErrorView(true)
showEmpty(false) showEmpty(false)
showProgress(false)
} else showError(message, error) } else showError(message, error)
} }
} }

View File

@ -161,6 +161,9 @@ class MessageTabPresenter @Inject constructor(
enableSwipe(true) enableSwipe(true)
notifyParentDataLoaded() notifyParentDataLoaded()
} }
}.catch {
errorHandler.dispatch(it)
view?.notifyParentDataLoaded()
}.launch() }.launch()
} }
@ -171,6 +174,7 @@ class MessageTabPresenter @Inject constructor(
setErrorDetails(message) setErrorDetails(message)
showErrorView(true) showErrorView(true)
showEmpty(false) showEmpty(false)
showProgress(false)
} else showError(message, error) } else showError(message, error)
} }
} }

View File

@ -9,6 +9,7 @@ import io.github.wulkanowy.ui.base.ErrorHandler
import io.github.wulkanowy.utils.AnalyticsHelper import io.github.wulkanowy.utils.AnalyticsHelper
import io.github.wulkanowy.utils.afterLoading import io.github.wulkanowy.utils.afterLoading
import io.github.wulkanowy.utils.flowWithResourceIn import io.github.wulkanowy.utils.flowWithResourceIn
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
@ -100,6 +101,9 @@ class SchoolPresenter @Inject constructor(
enableSwipe(true) enableSwipe(true)
notifyParentDataLoaded() notifyParentDataLoaded()
} }
}.catch {
errorHandler.dispatch(it)
view?.notifyParentDataLoaded()
}.launch() }.launch()
} }
@ -111,6 +115,7 @@ class SchoolPresenter @Inject constructor(
showErrorView(true) showErrorView(true)
showEmpty(false) showEmpty(false)
showContent(false) showContent(false)
showProgress(false)
} else showError(message, error) } else showError(message, error)
} }
} }

View File

@ -9,6 +9,7 @@ import io.github.wulkanowy.ui.base.ErrorHandler
import io.github.wulkanowy.utils.AnalyticsHelper import io.github.wulkanowy.utils.AnalyticsHelper
import io.github.wulkanowy.utils.afterLoading import io.github.wulkanowy.utils.afterLoading
import io.github.wulkanowy.utils.flowWithResourceIn import io.github.wulkanowy.utils.flowWithResourceIn
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
@ -85,6 +86,9 @@ class TeacherPresenter @Inject constructor(
enableSwipe(true) enableSwipe(true)
notifyParentDataLoaded() notifyParentDataLoaded()
} }
}.catch {
errorHandler.dispatch(it)
view?.notifyParentDataLoaded()
}.launch() }.launch()
} }
@ -95,6 +99,7 @@ class TeacherPresenter @Inject constructor(
setErrorDetails(message) setErrorDetails(message)
showErrorView(true) showErrorView(true)
showEmpty(false) showEmpty(false)
showProgress(false)
} else showError(message, error) } else showError(message, error)
} }
} }