From 05012de569130e131be92b71fbfc9308ea6c629c Mon Sep 17 00:00:00 2001 From: MajorTanya <39014446+MajorTanya@users.noreply.github.com> Date: Thu, 13 Mar 2025 10:36:34 +0100 Subject: [PATCH] Add prefix search to search by internal DB ID (#1856) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- CHANGELOG.md | 1 + .../main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2138a43d..ef5117ed2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 option to mark duplicate read chapters as read - 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 - Sliders UI diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt index 325e054c1..eb3f3c601 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt @@ -22,6 +22,10 @@ data class LibraryItem( */ fun matches(constraint: String): Boolean { val sourceName by lazy { sourceManager.getOrStub(libraryManga.manga.source).getNameForMangaInfo() } + if (constraint.startsWith("id:", true)) { + val id = constraint.substringAfter("id:").toLongOrNull() + return libraryManga.id == id + } return libraryManga.manga.title.contains(constraint, true) || (libraryManga.manga.author?.contains(constraint, true) ?: false) || (libraryManga.manga.artist?.contains(constraint, true) ?: false) ||