mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 11:08:31 +00:00
Redownload emoji search index if data is missing.
This commit is contained in:
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.database
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import androidx.core.content.contentValuesOf
|
||||
import org.signal.core.util.exists
|
||||
import org.signal.core.util.readToSingleInt
|
||||
import org.signal.core.util.requireInt
|
||||
import org.signal.core.util.requireNonNullString
|
||||
@@ -104,6 +105,10 @@ class EmojiSearchTable(context: Context, databaseHelper: SignalDatabase) : Datab
|
||||
}
|
||||
}
|
||||
|
||||
fun hasSearchIndexData(): Boolean {
|
||||
return readableDatabase.exists(TABLE_NAME).run()
|
||||
}
|
||||
|
||||
private fun SQLiteDatabase.insert(searchIndex: List<EmojiSearchData>) {
|
||||
for (searchData in searchIndex) {
|
||||
for (label in searchData.tags) {
|
||||
|
||||
@@ -60,6 +60,13 @@ public final class EmojiSearchIndexDownloadJob extends BaseJob {
|
||||
long timeSinceCheck = System.currentTimeMillis() - SignalStore.emoji().getLastSearchIndexCheck();
|
||||
boolean needsCheck = false;
|
||||
|
||||
if (SignalStore.emoji().hasSearchIndex() && !SignalDatabase.emojiSearch().hasSearchIndexData()) {
|
||||
Log.w(TAG, "Emoji search data missing with metadata, clearing version to redownload.");
|
||||
SignalStore.emoji().clearSearchIndexVersion();
|
||||
scheduleImmediately();
|
||||
return;
|
||||
}
|
||||
|
||||
if (SignalStore.emoji().hasSearchIndex()) {
|
||||
needsCheck = timeSinceCheck > INTERVAL_WITH_INDEX;
|
||||
} else {
|
||||
|
||||
@@ -135,6 +135,10 @@ public class EmojiValues extends SignalStoreValues {
|
||||
.apply();
|
||||
}
|
||||
|
||||
public void clearSearchIndexVersion() {
|
||||
getStore().beginWrite().remove(SEARCH_VERSION).apply();
|
||||
}
|
||||
|
||||
public @Nullable String getSearchLanguage() {
|
||||
return getString(SEARCH_LANGUAGE, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user