feat: trying upgrade DB for perf and reducing retry interval to congest threads

This commit is contained in:
Harris
2021-07-29 08:56:34 +10:00
parent 18d8261e33
commit 9d9f543c3b
5 changed files with 20 additions and 20 deletions

View File

@@ -143,11 +143,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
}
@Override
public void onConfigure(SQLiteDatabase db) {
super.onConfigure(db);
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
// Loki - Enable write ahead logging mode and increase the cache size.
// This should be disabled if we ever run into serious race condition bugs.
db.enableWriteAheadLogging();
db.execSQL("PRAGMA cache_size = 10000");
}

View File

@@ -116,19 +116,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
})
// Set up new conversation button set
newConversationButtonSet.delegate = this
// Set up typing observer
ApplicationContext.getInstance(this).typingStatusRepository.typingThreads.observe(this, Observer<Set<Long>> { threadIDs ->
val adapter = recyclerView.adapter as HomeAdapter
adapter.typingThreadIDs = threadIDs ?: setOf()
})
// Set up remaining components if needed
val application = ApplicationContext.getInstance(this)
val userPublicKey = TextSecurePreferences.getLocalNumber(this)
if (userPublicKey != null) {
OpenGroupManager.startPolling()
JobQueue.shared.resumePendingJobs()
}
application.registerForFCMIfNeeded(false)
// Observe blocked contacts changed events
val broadcastReceiver = object : BroadcastReceiver() {
@@ -138,8 +125,21 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
}
this.broadcastReceiver = broadcastReceiver
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter("blockedContactsChanged"))
lifecycleScope.launch {
lifecycleScope.launchWhenResumed {
// update things based on TextSecurePrefs (profile info etc)
// Set up typing observer
ApplicationContext.getInstance(this@HomeActivity).typingStatusRepository.typingThreads.observe(this@HomeActivity, Observer<Set<Long>> { threadIDs ->
val adapter = recyclerView.adapter as HomeAdapter
adapter.typingThreadIDs = threadIDs ?: setOf()
})
// Set up remaining components if needed
val application = ApplicationContext.getInstance(this@HomeActivity)
application.registerForFCMIfNeeded(false)
val userPublicKey = TextSecurePreferences.getLocalNumber(this@HomeActivity)
if (userPublicKey != null) {
OpenGroupManager.startPolling()
JobQueue.shared.resumePendingJobs()
}
updateProfileButton()
IP2Country.configureIfNeeded(this@HomeActivity)
TextSecurePreferences.events.filter { it == TextSecurePreferences.PROFILE_NAME_PREF }.collect {

View File

@@ -9,7 +9,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.database.model.ThreadRecord
import org.thoughtcrime.securesms.mms.GlideRequests
class HomeAdapter(context: Context, cursor: Cursor) : CursorRecyclerViewAdapter<HomeAdapter.ViewHolder>(context, cursor) {
class HomeAdapter(context: Context, cursor: Cursor?) : CursorRecyclerViewAdapter<HomeAdapter.ViewHolder>(context, cursor) {
private val threadDatabase = DatabaseFactory.getThreadDatabase(context)
lateinit var glide: GlideRequests
var typingThreadIDs = setOf<Long>()