fix: Loaded coroutines #2541

This commit is contained in:
J-Jamet committed 2026-06-08 21:54:08 +02:00
1 parent 95ec187b8c
commit db8df323ef
2 files changed
+21 -14

No files matched your search

@@ -112,7 +112,12 @@ class EntryEditViewModel: NodeEditViewModel() {
viewModelScope.launch {
// Just to compensate TemplateView bug
mTemplates?.let { templates ->
_entryEditUIState.update { it.copy(templates = templates) }
_entryEditUIState.update {
it.copy(
loaded = false,
templates = templates
)
}
}
withContext(Dispatchers.IO) {
mDatabase?.let { database ->
@@ -146,7 +151,9 @@ class EntryEditViewModel: NodeEditViewModel() {
if (!initialized) {
initialized = true
entryInfo?.let {
_entryEditEvents.emit(EntryEditEvent.EntryLoaded(entryInfo))
withContext(Dispatchers.Main) {
_entryEditEvents.emit(EntryEditEvent.EntryLoaded(entryInfo))
}
}
}
val selectedTemplate = entryInfo?.template ?: Template.STANDARD
@@ -155,13 +162,15 @@ class EntryEditViewModel: NodeEditViewModel() {
defaultTemplate = selectedTemplate
)
mTemplates = templates
_entryEditEvents.emit(EntryEditEvent.OnTemplateChanged(selectedTemplate))
_entryEditUIState.update { entryEdit ->
entryEdit.copy(
loaded = true,
entryInfo = entryInfo,
templates = templates
)
withContext(Dispatchers.Main) {
_entryEditEvents.emit(EntryEditEvent.OnTemplateChanged(selectedTemplate))
_entryEditUIState.update { entryEdit ->
entryEdit.copy(
loaded = true,
entryInfo = entryInfo,
templates = templates
)
}
}
}
@@ -149,12 +149,10 @@ class GroupViewModel(application: Application): AndroidViewModel(application) {
) {
viewModelScope.launch {
mDatabase?.let { database ->
_groupUIState.update { groupState ->
groupState.copy(loaded = false)
}
withContext(Dispatchers.IO) {
withContext(Dispatchers.Main) {
_groupUIState.update { groupState ->
groupState.copy(loaded = false)
}
}
val groupId = groupState?.groupId
val showFromPosition = groupState?.firstVisibleItem
val group = if (groupId != null) {