mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 16:49:40 +01:00
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:
committed by
Greyson Parrelli
parent
23b7ea90a1
commit
f0df1b99e5
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user