mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-14 20:39:59 -05:00
Fix login prompts despite being logged in to trackers in Manga screen
This commit is contained in:
parent
2092c81bad
commit
cbcd8bd668
2 changed files with 15 additions and 25 deletions
|
@ -138,7 +138,7 @@ class MangaScreen(
|
|||
)
|
||||
}.takeIf { isHttpSource },
|
||||
onTrackingClicked = {
|
||||
if (successState.loggedInTracker.isEmpty()) {
|
||||
if (!successState.hasLoggedInTrackers) {
|
||||
navigator.push(SettingsScreen(SettingsScreen.Destination.Tracking))
|
||||
} else {
|
||||
screenModel.showTrackDialog()
|
||||
|
|
|
@ -28,11 +28,9 @@ import eu.kanade.tachiyomi.data.download.DownloadCache
|
|||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.data.track.EnhancedTracker
|
||||
import eu.kanade.tachiyomi.data.track.Tracker
|
||||
import eu.kanade.tachiyomi.data.track.TrackerManager
|
||||
import eu.kanade.tachiyomi.network.HttpException
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.ui.manga.track.TrackItem
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import eu.kanade.tachiyomi.util.chapter.getNextUnread
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
|
@ -192,16 +190,6 @@ class MangaScreenModel(
|
|||
}
|
||||
}
|
||||
|
||||
screenModelScope.launchIO {
|
||||
trackerManager.loggedInTrackersFlow()
|
||||
.distinctUntilChanged()
|
||||
.collectLatest { trackers ->
|
||||
updateSuccessState {
|
||||
it.copy(loggedInTracker = trackers)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
observeDownloads()
|
||||
|
||||
screenModelScope.launchIO {
|
||||
|
@ -990,15 +978,20 @@ class MangaScreenModel(
|
|||
getTracks.subscribe(manga.id).catch { logcat(LogPriority.ERROR, it) },
|
||||
trackerManager.loggedInTrackersFlow(),
|
||||
) { mangaTracks, loggedInTrackers ->
|
||||
loggedInTrackers
|
||||
// Map to TrackItem
|
||||
.map { service -> TrackItem(mangaTracks.find { it.trackerId == service.id }, service) }
|
||||
// Show only if the service supports this manga's source
|
||||
.filter { (it.tracker as? EnhancedTracker)?.accept(source!!) ?: true }
|
||||
// Show only if the service supports this manga's source
|
||||
val supportedTrackers = loggedInTrackers.filter { (it as? EnhancedTracker)?.accept(source!!) ?: true }
|
||||
val supportedTrackerIds = supportedTrackers.map { it.id }.toHashSet()
|
||||
val supportedTrackerTracks = mangaTracks.filter { it.trackerId in supportedTrackerIds }
|
||||
supportedTrackerTracks.size to supportedTrackers.isNotEmpty()
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
.collectLatest { trackItems ->
|
||||
updateSuccessState { it.copy(trackItems = trackItems) }
|
||||
.collectLatest { (trackingCount, hasLoggedInTrackers) ->
|
||||
updateSuccessState {
|
||||
it.copy(
|
||||
trackingCount = trackingCount,
|
||||
hasLoggedInTrackers = hasLoggedInTrackers,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1062,11 +1055,11 @@ class MangaScreenModel(
|
|||
val chapters: List<ChapterList.Item>,
|
||||
val availableScanlators: Set<String>,
|
||||
val excludedScanlators: Set<String>,
|
||||
val trackItems: List<TrackItem> = emptyList(),
|
||||
val trackingCount: Int = 0,
|
||||
val hasLoggedInTrackers: Boolean = false,
|
||||
val isRefreshingData: Boolean = false,
|
||||
val dialog: Dialog? = null,
|
||||
val hasPromptedToAddBefore: Boolean = false,
|
||||
val loggedInTracker: List<Tracker> = emptyList(),
|
||||
) : State {
|
||||
val processedChapters by lazy {
|
||||
chapters.applyFilters(manga).toList()
|
||||
|
@ -1109,9 +1102,6 @@ class MangaScreenModel(
|
|||
val filterActive: Boolean
|
||||
get() = scanlatorFilterActive || manga.chaptersFiltered()
|
||||
|
||||
val trackingCount: Int
|
||||
get() = trackItems.count { it.track != null }
|
||||
|
||||
/**
|
||||
* Applies the view filters to the list of chapters obtained from the database.
|
||||
* @return an observable of the list of chapters filtered and sorted.
|
||||
|
|
Loading…
Reference in a new issue