Skip to content

Commit 67554ec

Browse files
committed
Fix launchWithWaiting
1 parent 87487a0 commit 67554ec

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

core/src/main/java/com/omega_r/base/mvp/presenters/OmegaPresenter.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,21 @@ open class OmegaPresenter<View : OmegaView> : MvpPresenter<View>(), CoroutineSco
132132

133133
protected fun launchWithWaiting(
134134
context: CoroutineContext = EmptyCoroutineContext,
135+
waiting: Boolean = true,
135136
waitingText: Text? = null,
136137
block: suspend () -> Unit
137138
): Job {
138-
viewState.setWaiting(true, waitingText)
139+
if (waiting) {
140+
viewState.setWaiting(true, waitingText)
141+
}
139142
return launch(context) {
140143
try {
141144
block()
142145
} finally {
143-
withContext(Dispatchers.Main) {
144-
viewState.setWaiting(false, waitingText)
146+
if (waiting) {
147+
withContext(Dispatchers.Main) {
148+
viewState.setWaiting(false, waitingText)
149+
}
145150
}
146151
}
147152
}

0 commit comments

Comments
 (0)