From 57282539883890a16ab56f8e87cab887e5917cc0 Mon Sep 17 00:00:00 2001 From: Acclorite <140836141+Acclorite@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:28:28 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Small=20fixes=20&=20imp?= =?UTF-8?q?rovements=20in=20Reader=20loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Preventing error from showing (after successful load) * Removed unnecessary delay --- .../screens/reader/data/ReaderViewModel.kt | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/screens/reader/data/ReaderViewModel.kt b/app/src/main/java/ua/acclorite/book_story/presentation/screens/reader/data/ReaderViewModel.kt index 0dd48f8f..643820ef 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/screens/reader/data/ReaderViewModel.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/screens/reader/data/ReaderViewModel.kt @@ -103,10 +103,10 @@ class ReaderViewModel @Inject constructor( event.checkForUpdate() - delay(100) _state.update { it.copy( - loading = false + loading = false, + errorMessage = null ) } @@ -526,7 +526,7 @@ class ReaderViewModel @Inject constructor( } clear() - launch { + withContext(Dispatchers.Default) { onEvent( ReaderEvent.OnShowHideMenu( show = false, @@ -535,27 +535,28 @@ class ReaderViewModel @Inject constructor( activity = activity ) ) - onEvent( - ReaderEvent.OnLoadText( - checkForUpdate = { - if (checkForTextUpdate) { - onEvent( - ReaderEvent.OnCheckTextForUpdate { - checkForTextUpdateToast() - } - ) - } - }, - refreshList = { refreshList(it) }, - onError = { - onError(it) - }, - onTextIsEmpty = { - onEvent(ReaderEvent.OnTextIsEmpty) - } - ) - ) } + + onEvent( + ReaderEvent.OnLoadText( + checkForUpdate = { + if (checkForTextUpdate) { + onEvent( + ReaderEvent.OnCheckTextForUpdate { + checkForTextUpdateToast() + } + ) + } + }, + refreshList = { refreshList(it) }, + onError = { + onError(it) + }, + onTextIsEmpty = { + onEvent(ReaderEvent.OnTextIsEmpty) + } + ) + ) } }