🛠️ Fix issue with screen reset
This commit is contained in:
parent
d3b537d733
commit
551e52731b
2 changed files with 10 additions and 2 deletions
|
|
@ -62,6 +62,7 @@ class BookInfoModel @Inject constructor(
|
|||
val state = _state.asStateFlow()
|
||||
|
||||
private var eventJob = SupervisorJob()
|
||||
private var resetJob: Job? = null
|
||||
|
||||
private var updateJob: Job? = null
|
||||
private var snackBarJob: Job? = null
|
||||
|
|
@ -785,7 +786,9 @@ class BookInfoModel @Inject constructor(
|
|||
}
|
||||
|
||||
eventJob.cancel()
|
||||
resetJob?.cancel()
|
||||
eventJob.join()
|
||||
resetJob?.join()
|
||||
eventJob = SupervisorJob()
|
||||
|
||||
_state.update {
|
||||
|
|
@ -807,10 +810,11 @@ class BookInfoModel @Inject constructor(
|
|||
}
|
||||
|
||||
fun resetScreen() {
|
||||
viewModelScope.launch(Dispatchers.Main) {
|
||||
resetJob = viewModelScope.launch(Dispatchers.Main) {
|
||||
eventJob.cancel()
|
||||
eventJob = SupervisorJob()
|
||||
|
||||
yield()
|
||||
_state.update { BookInfoState() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class ReaderModel @Inject constructor(
|
|||
val state = _state.asStateFlow()
|
||||
|
||||
private var eventJob = SupervisorJob()
|
||||
private var resetJob: Job? = null
|
||||
|
||||
private var scrollJob: Job? = null
|
||||
private var updateJob: Job? = null
|
||||
|
|
@ -564,7 +565,9 @@ class ReaderModel @Inject constructor(
|
|||
}
|
||||
|
||||
eventJob.cancel()
|
||||
resetJob?.cancel()
|
||||
eventJob.join()
|
||||
resetJob?.join()
|
||||
eventJob = SupervisorJob()
|
||||
|
||||
_state.update {
|
||||
|
|
@ -687,10 +690,11 @@ class ReaderModel @Inject constructor(
|
|||
}
|
||||
|
||||
fun resetScreen() {
|
||||
viewModelScope.launch(Dispatchers.Main) {
|
||||
resetJob = viewModelScope.launch(Dispatchers.Main) {
|
||||
eventJob.cancel()
|
||||
eventJob = SupervisorJob()
|
||||
|
||||
yield()
|
||||
_state.update { ReaderState() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue