Always include english translations for emoji search.

Updates the `emoji_search` table by including English emoji labels alongside existing localized labels, enabling users to search for emojis in both their preferred language and English.
This commit is contained in:
jeffrey-signal
2025-09-12 11:41:42 -04:00
committed by Greyson Parrelli
parent 23b7ea90a1
commit f0df1b99e5
5 changed files with 90 additions and 33 deletions

View File

@@ -93,21 +93,26 @@ class EmojiSearchTable(context: Context, databaseHelper: SignalDatabase) : Datab
/**
* Deletes the content of the current search index and replaces it with the new one.
*/
fun setSearchIndex(searchIndex: List<EmojiSearchData>) {
val db = databaseHelper.signalReadableDatabase
db.withinTransaction {
fun setSearchIndex(
localizedSearchIndex: List<EmojiSearchData>,
englishSearchIndex: List<EmojiSearchData>
) {
databaseHelper.signalReadableDatabase.withinTransaction { db ->
db.delete(TABLE_NAME, null, null)
db.insert(localizedSearchIndex)
db.insert(englishSearchIndex)
}
}
for (searchData in searchIndex) {
for (label in searchData.tags) {
val values = contentValuesOf(
LABEL to label,
EMOJI to searchData.emoji,
RANK to if (searchData.rank == 0) Int.MAX_VALUE else searchData.rank
)
db.insert(TABLE_NAME, null, values)
}
private fun SQLiteDatabase.insert(searchIndex: List<EmojiSearchData>) {
for (searchData in searchIndex) {
for (label in searchData.tags) {
val values = contentValuesOf(
LABEL to label,
EMOJI to searchData.emoji,
RANK to if (searchData.rank == 0) Int.MAX_VALUE else searchData.rank
)
insert(TABLE_NAME, null, values)
}
}
}