From 50554c6936865f04c534290ebc7ea7fbde857a18 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Fri, 28 Jul 2023 16:40:21 +0300 Subject: [PATCH] Fix tags suggestions --- .../org/koitharu/kotatsu/core/db/dao/TagsDao.kt | 11 +++++++---- .../kotatsu/core/ui/widgets/SelectableTextView.kt | 6 +----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/dao/TagsDao.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/dao/TagsDao.kt index e84ffa352..bde4641d6 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/dao/TagsDao.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/dao/TagsDao.kt @@ -1,6 +1,8 @@ package org.koitharu.kotatsu.core.db.dao -import androidx.room.* +import androidx.room.Dao +import androidx.room.Query +import androidx.room.Upsert import org.koitharu.kotatsu.core.db.entity.TagEntity @Dao @@ -12,6 +14,7 @@ abstract class TagsDao { @Query( """SELECT tags.* FROM tags LEFT JOIN manga_tags ON tags.tag_id = manga_tags.tag_id + WHERE manga_tags.manga_id IN (SELECT manga_id FROM history UNION SELECT manga_id FROM favourites) GROUP BY tags.title ORDER BY COUNT(manga_id) DESC LIMIT :limit""", @@ -21,7 +24,7 @@ abstract class TagsDao { @Query( """SELECT tags.* FROM tags LEFT JOIN manga_tags ON tags.tag_id = manga_tags.tag_id - WHERE tags.source = :source + WHERE tags.source = :source GROUP BY tags.title ORDER BY COUNT(manga_id) DESC LIMIT :limit""", @@ -31,7 +34,7 @@ abstract class TagsDao { @Query( """SELECT tags.* FROM tags LEFT JOIN manga_tags ON tags.tag_id = manga_tags.tag_id - WHERE tags.source = :source AND title LIKE :query + WHERE tags.source = :source AND title LIKE :query GROUP BY tags.title ORDER BY COUNT(manga_id) DESC LIMIT :limit""", @@ -41,7 +44,7 @@ abstract class TagsDao { @Query( """SELECT tags.* FROM tags LEFT JOIN manga_tags ON tags.tag_id = manga_tags.tag_id - WHERE title LIKE :query + WHERE title LIKE :query AND manga_tags.manga_id IN (SELECT manga_id FROM history UNION SELECT manga_id FROM favourites) GROUP BY tags.title ORDER BY COUNT(manga_id) DESC LIMIT :limit""", diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/SelectableTextView.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/SelectableTextView.kt index 7c14c6b8b..1f80fb57b 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/SelectableTextView.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/widgets/SelectableTextView.kt @@ -28,10 +28,6 @@ class SelectableTextView @JvmOverloads constructor( } override fun scrollTo(x: Int, y: Int) { - if (maxLines in 1 until Integer.MAX_VALUE) { - super.scrollTo(0, 0) - } else { - super.scrollTo(x, y) - } + super.scrollTo(0, 0) } }