Change Updates icon badge to show new updates count (#8659)

* Change Updates icon badge to show new updates count

* Fix reference

* review changes

* Lint
This commit is contained in:
AntsyLich
2022-12-04 01:44:30 +06:00
committed by GitHub
parent 7be9b49143
commit 373463e995
9 changed files with 20 additions and 29 deletions
@@ -60,10 +60,10 @@ class UpdatesScreenModel(
private val getUpdates: GetUpdates = Injekt.get(),
private val getManga: GetManga = Injekt.get(),
private val getChapter: GetChapter = Injekt.get(),
private val libraryPreferences: LibraryPreferences = Injekt.get(),
val snackbarHostState: SnackbarHostState = SnackbarHostState(),
basePreferences: BasePreferences = Injekt.get(),
uiPreferences: UiPreferences = Injekt.get(),
libraryPreferences: LibraryPreferences = Injekt.get(),
) : StateScreenModel<UpdatesState>(UpdatesState()) {
private val _events: Channel<Event> = Channel(Int.MAX_VALUE)
@@ -371,6 +371,10 @@ class UpdatesScreenModel(
mutableState.update { it.copy(dialog = dialog) }
}
fun resetNewUpdatesCount() {
libraryPreferences.newUpdatesCount().set(0)
}
sealed class Dialog {
data class DeleteConfirmation(val toDelete: List<UpdatesItem>) : Dialog()
}
@@ -4,6 +4,7 @@ import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@@ -110,5 +111,12 @@ object UpdatesTab : Tab {
(context as? MainActivity)?.ready = true
}
}
DisposableEffect(Unit) {
screenModel.resetNewUpdatesCount()
onDispose {
screenModel.resetNewUpdatesCount()
}
}
}
}