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