mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 11:59:19 +01:00
Pass listing query to BrowseSourceScreen (#8763)
* Pass listing query to BrowseSourceScreen * Don't use referential equality
This commit is contained in:
parent
dac04f2929
commit
46417fe427
@ -15,7 +15,6 @@ import androidx.compose.foundation.verticalScroll
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.OpenInNew
|
import androidx.compose.material.icons.filled.OpenInNew
|
||||||
import androidx.compose.material.icons.outlined.NewReleases
|
import androidx.compose.material.icons.outlined.NewReleases
|
||||||
import androidx.compose.material3.Button
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.NavigationBarDefaults
|
import androidx.compose.material3.NavigationBarDefaults
|
||||||
@ -68,7 +67,7 @@ fun NewUpdateScreen(
|
|||||||
vertical = MaterialTheme.padding.small,
|
vertical = MaterialTheme.padding.small,
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
Button(
|
TextButton(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onClick = onAcceptUpdate,
|
onClick = onAcceptUpdate,
|
||||||
) {
|
) {
|
||||||
|
@ -50,7 +50,6 @@ import eu.kanade.tachiyomi.source.Source
|
|||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.ui.browse.migration.MigrationFlags
|
import eu.kanade.tachiyomi.ui.browse.migration.MigrationFlags
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreenModel.Listing
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||||
@ -78,7 +77,7 @@ class MigrateSearchScreen(private val mangaId: Long) : Screen {
|
|||||||
if (!screenModel.incognitoMode.get()) {
|
if (!screenModel.incognitoMode.get()) {
|
||||||
screenModel.lastUsedSourceId.set(it.id)
|
screenModel.lastUsedSourceId.set(it.id)
|
||||||
}
|
}
|
||||||
navigator.push(SourceSearchScreen(state.manga!!, it.id, Listing.Search(state.searchQuery, it.getFilterList())))
|
navigator.push(SourceSearchScreen(state.manga!!, it.id, state.searchQuery))
|
||||||
},
|
},
|
||||||
onClickItem = { screenModel.setDialog(MigrateSearchDialog.Migrate(it)) },
|
onClickItem = { screenModel.setDialog(MigrateSearchDialog.Migrate(it)) },
|
||||||
onLongClickItem = { navigator.push(MangaScreen(it.id, true)) },
|
onLongClickItem = { navigator.push(MangaScreen(it.id, true)) },
|
||||||
|
@ -40,7 +40,7 @@ import kotlinx.coroutines.launch
|
|||||||
data class SourceSearchScreen(
|
data class SourceSearchScreen(
|
||||||
private val oldManga: Manga,
|
private val oldManga: Manga,
|
||||||
private val sourceId: Long,
|
private val sourceId: Long,
|
||||||
private val listing: BrowseSourceScreenModel.Listing,
|
private val query: String?,
|
||||||
) : Screen {
|
) : Screen {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -50,7 +50,7 @@ data class SourceSearchScreen(
|
|||||||
val navigator = LocalNavigator.currentOrThrow
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
val screenModel = rememberScreenModel { BrowseSourceScreenModel(sourceId, listing) }
|
val screenModel = rememberScreenModel { BrowseSourceScreenModel(sourceId, query) }
|
||||||
val state by screenModel.state.collectAsState()
|
val state by screenModel.state.collectAsState()
|
||||||
|
|
||||||
val snackbarHostState = remember { SnackbarHostState() }
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
|
@ -48,7 +48,7 @@ fun Screen.sourcesTab(): TabContent {
|
|||||||
contentPadding = contentPadding,
|
contentPadding = contentPadding,
|
||||||
onClickItem = { source, listing ->
|
onClickItem = { source, listing ->
|
||||||
screenModel.onOpenSource(source)
|
screenModel.onOpenSource(source)
|
||||||
navigator.push(BrowseSourceScreen(source.id, listing))
|
navigator.push(BrowseSourceScreen(source.id, listing.query))
|
||||||
},
|
},
|
||||||
onClickPin = screenModel::togglePin,
|
onClickPin = screenModel::togglePin,
|
||||||
onLongClickItem = screenModel::showSourceDialog,
|
onLongClickItem = screenModel::showSourceDialog,
|
||||||
|
@ -62,7 +62,7 @@ import kotlinx.coroutines.flow.receiveAsFlow
|
|||||||
|
|
||||||
data class BrowseSourceScreen(
|
data class BrowseSourceScreen(
|
||||||
private val sourceId: Long,
|
private val sourceId: Long,
|
||||||
private val listing: Listing,
|
private val listingQuery: String?,
|
||||||
) : Screen, AssistContentScreen {
|
) : Screen, AssistContentScreen {
|
||||||
|
|
||||||
private var assistUrl: String? = null
|
private var assistUrl: String? = null
|
||||||
@ -79,7 +79,7 @@ data class BrowseSourceScreen(
|
|||||||
val haptic = LocalHapticFeedback.current
|
val haptic = LocalHapticFeedback.current
|
||||||
val uriHandler = LocalUriHandler.current
|
val uriHandler = LocalUriHandler.current
|
||||||
|
|
||||||
val screenModel = rememberScreenModel { BrowseSourceScreenModel(sourceId, listing) }
|
val screenModel = rememberScreenModel { BrowseSourceScreenModel(sourceId, listingQuery) }
|
||||||
val state by screenModel.state.collectAsState()
|
val state by screenModel.state.collectAsState()
|
||||||
|
|
||||||
val snackbarHostState = remember { SnackbarHostState() }
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
|
@ -79,7 +79,7 @@ import eu.kanade.tachiyomi.source.model.Filter as SourceModelFilter
|
|||||||
|
|
||||||
class BrowseSourceScreenModel(
|
class BrowseSourceScreenModel(
|
||||||
private val sourceId: Long,
|
private val sourceId: Long,
|
||||||
listing: Listing,
|
listingQuery: String?,
|
||||||
private val sourceManager: SourceManager = Injekt.get(),
|
private val sourceManager: SourceManager = Injekt.get(),
|
||||||
sourcePreferences: SourcePreferences = Injekt.get(),
|
sourcePreferences: SourcePreferences = Injekt.get(),
|
||||||
private val libraryPreferences: LibraryPreferences = Injekt.get(),
|
private val libraryPreferences: LibraryPreferences = Injekt.get(),
|
||||||
@ -95,7 +95,7 @@ class BrowseSourceScreenModel(
|
|||||||
private val updateManga: UpdateManga = Injekt.get(),
|
private val updateManga: UpdateManga = Injekt.get(),
|
||||||
private val insertTrack: InsertTrack = Injekt.get(),
|
private val insertTrack: InsertTrack = Injekt.get(),
|
||||||
private val syncChaptersWithTrackServiceTwoWay: SyncChaptersWithTrackServiceTwoWay = Injekt.get(),
|
private val syncChaptersWithTrackServiceTwoWay: SyncChaptersWithTrackServiceTwoWay = Injekt.get(),
|
||||||
) : StateScreenModel<BrowseSourceScreenModel.State>(State(listing)) {
|
) : StateScreenModel<BrowseSourceScreenModel.State>(State(Listing.valueOf(listingQuery))) {
|
||||||
|
|
||||||
private val loggedServices by lazy { Injekt.get<TrackManager>().services.filter { it.isLogged } }
|
private val loggedServices by lazy { Injekt.get<TrackManager>().services.filter { it.isLogged } }
|
||||||
|
|
||||||
@ -133,7 +133,19 @@ class BrowseSourceScreenModel(
|
|||||||
.stateIn(coroutineScope, SharingStarted.Lazily, emptyFlow())
|
.stateIn(coroutineScope, SharingStarted.Lazily, emptyFlow())
|
||||||
|
|
||||||
init {
|
init {
|
||||||
mutableState.update { it.copy(filters = source.getFilterList()) }
|
mutableState.update {
|
||||||
|
val initialListing = it.listing
|
||||||
|
val listing = if (initialListing is Listing.Search) {
|
||||||
|
initialListing.copy(filters = source.getFilterList())
|
||||||
|
} else {
|
||||||
|
initialListing
|
||||||
|
}
|
||||||
|
|
||||||
|
it.copy(
|
||||||
|
listing = listing,
|
||||||
|
filters = source.getFilterList(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getColumnsPreference(orientation: Int): GridCells {
|
fun getColumnsPreference(orientation: Int): GridCells {
|
||||||
@ -374,6 +386,16 @@ class BrowseSourceScreenModel(
|
|||||||
object Popular : Listing(query = GetRemoteManga.QUERY_POPULAR, filters = FilterList())
|
object Popular : Listing(query = GetRemoteManga.QUERY_POPULAR, filters = FilterList())
|
||||||
object Latest : Listing(query = GetRemoteManga.QUERY_LATEST, filters = FilterList())
|
object Latest : Listing(query = GetRemoteManga.QUERY_LATEST, filters = FilterList())
|
||||||
data class Search(override val query: String?, override val filters: FilterList) : Listing(query = query, filters = filters)
|
data class Search(override val query: String?, override val filters: FilterList) : Listing(query = query, filters = filters)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun valueOf(query: String?): Listing {
|
||||||
|
return when (query) {
|
||||||
|
GetRemoteManga.QUERY_POPULAR -> Popular
|
||||||
|
GetRemoteManga.QUERY_LATEST -> Latest
|
||||||
|
else -> Search(query = query, filters = FilterList()) // filters are filled in later
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class Dialog {
|
sealed class Dialog {
|
||||||
|
@ -10,7 +10,6 @@ import cafe.adriel.voyager.navigator.LocalNavigator
|
|||||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||||
import eu.kanade.presentation.browse.GlobalSearchScreen
|
import eu.kanade.presentation.browse.GlobalSearchScreen
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreen
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreen
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreenModel.Listing
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||||
|
|
||||||
class GlobalSearchScreen(
|
class GlobalSearchScreen(
|
||||||
@ -47,7 +46,7 @@ class GlobalSearchScreen(
|
|||||||
if (!screenModel.incognitoMode.get()) {
|
if (!screenModel.incognitoMode.get()) {
|
||||||
screenModel.lastUsedSourceId.set(it.id)
|
screenModel.lastUsedSourceId.set(it.id)
|
||||||
}
|
}
|
||||||
navigator.push(BrowseSourceScreen(it.id, Listing.Search(state.searchQuery, it.getFilterList())))
|
navigator.push(BrowseSourceScreen(it.id, state.searchQuery))
|
||||||
},
|
},
|
||||||
onClickItem = { navigator.push(MangaScreen(it.id, true)) },
|
onClickItem = { navigator.push(MangaScreen(it.id, true)) },
|
||||||
onLongClickItem = { navigator.push(MangaScreen(it.id, true)) },
|
onLongClickItem = { navigator.push(MangaScreen(it.id, true)) },
|
||||||
|
Loading…
Reference in New Issue
Block a user