|
|
|
@ -1,21 +1,14 @@
|
|
|
|
package org.koitharu.kotatsu.stats.ui
|
|
|
|
package org.koitharu.kotatsu.stats.ui
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.lifecycle.viewModelScope
|
|
|
|
|
|
|
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
|
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
import kotlinx.coroutines.flow.MutableStateFlow
|
|
|
|
import kotlinx.coroutines.flow.MutableStateFlow
|
|
|
|
import kotlinx.coroutines.flow.SharingStarted
|
|
|
|
|
|
|
|
import kotlinx.coroutines.flow.collectLatest
|
|
|
|
import kotlinx.coroutines.flow.collectLatest
|
|
|
|
import kotlinx.coroutines.flow.combine
|
|
|
|
import kotlinx.coroutines.flow.combine
|
|
|
|
import kotlinx.coroutines.flow.flow
|
|
|
|
|
|
|
|
import kotlinx.coroutines.flow.stateIn
|
|
|
|
|
|
|
|
import kotlinx.coroutines.flow.take
|
|
|
|
import kotlinx.coroutines.flow.take
|
|
|
|
import kotlinx.coroutines.flow.update
|
|
|
|
|
|
|
|
import kotlinx.coroutines.plus
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.R
|
|
|
|
import org.koitharu.kotatsu.R
|
|
|
|
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
|
|
|
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
|
|
|
import org.koitharu.kotatsu.core.ui.BaseViewModel
|
|
|
|
import org.koitharu.kotatsu.core.ui.BaseViewModel
|
|
|
|
import org.koitharu.kotatsu.core.ui.model.DateTimeAgo
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.core.ui.util.ReversibleAction
|
|
|
|
import org.koitharu.kotatsu.core.ui.util.ReversibleAction
|
|
|
|
import org.koitharu.kotatsu.core.util.ext.MutableEventFlow
|
|
|
|
import org.koitharu.kotatsu.core.util.ext.MutableEventFlow
|
|
|
|
import org.koitharu.kotatsu.core.util.ext.call
|
|
|
|
import org.koitharu.kotatsu.core.util.ext.call
|
|
|
|
@ -63,7 +56,7 @@ class StatsViewModel @Inject constructor(
|
|
|
|
selectedCategories.value = snapshot
|
|
|
|
selectedCategories.value = snapshot
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun clear() {
|
|
|
|
fun clearStats() {
|
|
|
|
launchLoadingJob(Dispatchers.Default) {
|
|
|
|
launchLoadingJob(Dispatchers.Default) {
|
|
|
|
repository.clearStats()
|
|
|
|
repository.clearStats()
|
|
|
|
readingStats.value = emptyList()
|
|
|
|
readingStats.value = emptyList()
|
|
|
|
|