Skip to content

Commit 0be4b5c

Browse files
Make sure migration is only done outside ThreadDatabase's constructor (#1325)
1 parent dccb9bb commit 0be4b5c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import org.thoughtcrime.securesms.configs.ConfigUploader
7272
import org.thoughtcrime.securesms.database.EmojiSearchDatabase
7373
import org.thoughtcrime.securesms.database.LokiAPIDatabase
7474
import org.thoughtcrime.securesms.database.Storage
75+
import org.thoughtcrime.securesms.database.ThreadDatabase
7576
import org.thoughtcrime.securesms.database.model.EmojiSearchData
7677
import org.thoughtcrime.securesms.debugmenu.DebugActivity
7778
import org.thoughtcrime.securesms.dependencies.AppComponent
@@ -206,6 +207,9 @@ class ApplicationContext : Application(), DefaultLifecycleObserver,
206207
@Inject
207208
lateinit var openGroupPollerManager: Lazy<OpenGroupPollerManager>
208209

210+
@Inject
211+
lateinit var threadDatabase: Lazy<ThreadDatabase>
212+
209213
@Volatile
210214
var isAppVisible: Boolean = false
211215

@@ -381,6 +385,8 @@ class ApplicationContext : Application(), DefaultLifecycleObserver,
381385
groupPollerManager.get()
382386
expiredGroupManager.get()
383387
openGroupPollerManager.get()
388+
389+
threadDatabase.get().onAppCreated()
384390
}
385391

386392
override fun onStart(owner: LifecycleOwner) {

app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public static String getUnreadMentionCountCommand() {
168168

169169
private ConversationThreadUpdateListener updateListener;
170170
private final Json json;
171+
private final TextSecurePreferences prefs;
171172

172173
@Inject
173174
public ThreadDatabase(
@@ -177,7 +178,12 @@ public ThreadDatabase(
177178
Json json) {
178179
super(context, databaseHelper);
179180
this.json = json;
181+
this.prefs = prefs;
182+
}
180183

184+
// This method is called when the application is created, providing an opportunity to perform
185+
// initialization tasks that need to be done only once.
186+
public void onAppCreated() {
181187
if (!prefs.getMigratedDisappearingMessagesToMessageContent()) {
182188
migrateDisappearingMessagesToMessageContent();
183189
prefs.setMigratedDisappearingMessagesToMessageContent(true);

0 commit comments

Comments
 (0)