Add prefix search to search by internal DB ID (mihonapp/mihon#1856)
This prefix searches entries in the library based on the ID in the
database. It is a niche feature but could be very helpful in certain
situations, such as a corrupted cover causing a crash that just shows
"🚨 Failed - MangaCover(mangaId=2245, sourceId=1, isMangaFavorite=true, url=, lastModified=0)".
With this prefix search it is possible to find the entry in question
without much hassle.
Notably, the database includes literally anything Mihon has ever seen
from extension and such, even if they weren't added to the collection.
This means that IDs actually present in the collection are not
expected to be purely sequential.
For example, in my emulator, I had two entries in the collection but
the assigned IDs were 5 and 56.
(cherry picked from commit 05012de569130e131be92b71fbfc9308ea6c629c)
This commit is contained in:
parent
6fa34ab5e9
commit
2783cee02e
2 changed files with 6 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
||||||
- Add back support for drag-and-drop category reordering ([@cuong-tran](https://github.com/cuong-tran)) ([#1427](https://github.com/mihonapp/mihon/pull/1427))
|
- Add back support for drag-and-drop category reordering ([@cuong-tran](https://github.com/cuong-tran)) ([#1427](https://github.com/mihonapp/mihon/pull/1427))
|
||||||
- Add option to mark duplicate read chapters as read after library update or while reading ([@AntsyLich](https://github.com/AntsyLich)) ([#1785](https://github.com/mihonapp/mihon/pull/1785), [#1791](https://github.com/mihonapp/mihon/pull/1791), [#1870](https://github.com/mihonapp/mihon/pull/1870))
|
- Add option to mark duplicate read chapters as read after library update or while reading ([@AntsyLich](https://github.com/AntsyLich)) ([#1785](https://github.com/mihonapp/mihon/pull/1785), [#1791](https://github.com/mihonapp/mihon/pull/1791), [#1870](https://github.com/mihonapp/mihon/pull/1870))
|
||||||
- Display staff information on Anilist tracker search results ([@NarwhalHorns](https://github.com/NarwhalHorns)) ([#1810](https://github.com/mihonapp/mihon/pull/1810))
|
- Display staff information on Anilist tracker search results ([@NarwhalHorns](https://github.com/NarwhalHorns)) ([#1810](https://github.com/mihonapp/mihon/pull/1810))
|
||||||
|
- Add `id:` prefix search to library to search by internal DB ID ([@MajorTanya](https://github.com/MajorTanya)) ([#1856](https://github.com/mihonapp/mihon/pull/1856))
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Sliders UI
|
- Sliders UI
|
||||||
|
|
|
||||||
|
|
@ -981,7 +981,7 @@ class LibraryScreenModel(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun filterLibrary(unfiltered: List<LibraryItem>, query: String?, loggedInTrackServices: Map<Long, TriState>): List<LibraryItem> {
|
private suspend fun filterLibrary(unfiltered: List<LibraryItem>, query: String?, loggedInTrackServices: Map<Long, TriState>): List<LibraryItem> {
|
||||||
return if (unfiltered.isNotEmpty() && !query.isNullOrBlank()) {
|
return if (unfiltered.isNotEmpty() && !query.isNullOrBlank()) {
|
||||||
// Prepare filter object
|
// Prepare filter object
|
||||||
val parsedQuery = searchEngine.parseQuery(query)
|
val parsedQuery = searchEngine.parseQuery(query)
|
||||||
|
|
@ -997,6 +997,10 @@ class LibraryScreenModel(
|
||||||
.associateBy { it.id }
|
.associateBy { it.id }
|
||||||
unfiltered.asFlow().cancellable().filter { item ->
|
unfiltered.asFlow().cancellable().filter { item ->
|
||||||
val mangaId = item.libraryManga.manga.id
|
val mangaId = item.libraryManga.manga.id
|
||||||
|
if (query.startsWith("id:", true)) {
|
||||||
|
val id = query.substringAfter("id:").toLongOrNull()
|
||||||
|
return@filter mangaId == id
|
||||||
|
}
|
||||||
val sourceId = item.libraryManga.manga.source
|
val sourceId = item.libraryManga.manga.source
|
||||||
if (isMetadataSource(sourceId) && mangaWithMetaIds.binarySearch(mangaId) >= 0) {
|
if (isMetadataSource(sourceId) && mangaWithMetaIds.binarySearch(mangaId) >= 0) {
|
||||||
val tags = getSearchTags.await(mangaId)
|
val tags = getSearchTags.await(mangaId)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue