From 33b2e98868f5740778a3c12f7644431fa2ee68d1 Mon Sep 17 00:00:00 2001 From: Yuichiro Kinoshita Date: Mon, 16 Oct 2023 13:04:02 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20DB=E3=81=8B=E3=82=89=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=8C=E7=B5=82=E3=82=8F=E3=82=8B=E3=81=BE=E3=81=A7?= =?UTF-8?q?=E3=81=AF=E3=83=A1=E3=83=A2=E3=83=AA=E4=B8=8A=E3=81=A7=E6=A4=9C?= =?UTF-8?q?=E7=B4=A2=E3=81=97=E3=81=9F=E7=B5=90=E6=9E=9C=E3=82=92=E8=BF=94?= =?UTF-8?q?=E3=81=99=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/emoji/CustomEmojiRepositoryImpl.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/emoji/CustomEmojiRepositoryImpl.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/emoji/CustomEmojiRepositoryImpl.kt index c5201b6811..12e2ecb6d0 100644 --- a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/emoji/CustomEmojiRepositoryImpl.kt +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/emoji/CustomEmojiRepositoryImpl.kt @@ -5,6 +5,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.withContext import net.pantasystem.milktea.common.runCancellableCatching import net.pantasystem.milktea.common_android.hilt.DefaultDispatcher @@ -172,7 +173,13 @@ internal class CustomEmojiRepositoryImpl @Inject constructor( override fun observeWithSearch(host: String, keyword: String): Flow> { return customEmojiDAO.observeAndSearch(host, keyword).map { list -> convertToModel(list) - }.flowOn(defaultDispatcher) + }.flowOn(defaultDispatcher).onStart { + customEmojiCache.get(host)?.filter { + it.name.contains(keyword) + }?.let { + emit(it) + } + } } override suspend fun search(host: String, keyword: String): Result> = runCancellableCatching {