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

View File

@@ -130,7 +130,7 @@ class DomainModule : InjektModule {
addFactory { GetExtensionLanguages(get(), get()) }
addSingletonFactory<UpdatesRepository> { UpdatesRepositoryImpl(get()) }
addFactory { GetUpdates(get(), get()) }
addFactory { GetUpdates(get()) }
addSingletonFactory<SourceRepository> { SourceRepositoryImpl(get(), get()) }
addSingletonFactory<SourceDataRepository> { SourceDataRepositoryImpl(get()) }

View File

@@ -60,8 +60,7 @@ class LibraryPreferences(
fun languageBadge() = preferenceStore.getBoolean("display_language_badge", false)
fun showUpdatesNavBadge() = preferenceStore.getBoolean("library_update_show_tab_badge", false)
fun unreadUpdatesCount() = preferenceStore.getInt("library_unread_updates_count", 0)
fun newUpdatesCount() = preferenceStore.getInt("library_unseen_updates_count", 0)
// endregion

View File

@@ -1,24 +1,17 @@
package eu.kanade.domain.updates.interactor
import eu.kanade.domain.library.service.LibraryPreferences
import eu.kanade.domain.updates.model.UpdatesWithRelations
import eu.kanade.domain.updates.repository.UpdatesRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.onEach
import java.util.Calendar
class GetUpdates(
private val repository: UpdatesRepository,
private val preferences: LibraryPreferences,
) {
fun subscribe(calendar: Calendar): Flow<List<UpdatesWithRelations>> = subscribe(calendar.time.time)
fun subscribe(after: Long): Flow<List<UpdatesWithRelations>> {
return repository.subscribeAll(after)
.onEach { updates ->
// Set unread chapter count for bottom bar badge
preferences.unreadUpdatesCount().set(updates.count { !it.read })
}
}
}