mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-21 11:41:32 +00:00
fix: trying to improve performance
This commit is contained in:
parent
df81c66d32
commit
6c55f170ea
@ -1,6 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.dependencies
|
package org.thoughtcrime.securesms.dependencies
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Trace
|
||||||
import network.loki.messenger.libsession_util.ConfigBase
|
import network.loki.messenger.libsession_util.ConfigBase
|
||||||
import network.loki.messenger.libsession_util.Contacts
|
import network.loki.messenger.libsession_util.Contacts
|
||||||
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
||||||
@ -60,11 +61,20 @@ class ConfigFactory(
|
|||||||
listeners -= listener
|
listeners -= listener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private inline fun <T> synchronizedWithLog(lock: Any, body: ()->T): T {
|
||||||
|
Trace.beginSection("synchronizedWithLog")
|
||||||
|
val result = synchronized(lock) {
|
||||||
|
body()
|
||||||
|
}
|
||||||
|
Trace.endSection()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
override val user: UserProfile?
|
override val user: UserProfile?
|
||||||
get() = synchronized(userLock) {
|
get() = synchronizedWithLog(userLock) {
|
||||||
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
||||||
if (_userConfig == null) {
|
if (_userConfig == null) {
|
||||||
val (secretKey, publicKey) = maybeGetUserInfo() ?: return@synchronized null
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
||||||
val userDump = configDatabase.retrieveConfigAndHashes(
|
val userDump = configDatabase.retrieveConfigAndHashes(
|
||||||
SharedConfigMessage.Kind.USER_PROFILE.name,
|
SharedConfigMessage.Kind.USER_PROFILE.name,
|
||||||
publicKey
|
publicKey
|
||||||
@ -81,10 +91,10 @@ class ConfigFactory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val contacts: Contacts?
|
override val contacts: Contacts?
|
||||||
get() = synchronized(contactsLock) {
|
get() = synchronizedWithLog(contactsLock) {
|
||||||
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
||||||
if (_contacts == null) {
|
if (_contacts == null) {
|
||||||
val (secretKey, publicKey) = maybeGetUserInfo() ?: return@synchronized null
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
||||||
val contactsDump = configDatabase.retrieveConfigAndHashes(
|
val contactsDump = configDatabase.retrieveConfigAndHashes(
|
||||||
SharedConfigMessage.Kind.CONTACTS.name,
|
SharedConfigMessage.Kind.CONTACTS.name,
|
||||||
publicKey
|
publicKey
|
||||||
@ -101,10 +111,10 @@ class ConfigFactory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val convoVolatile: ConversationVolatileConfig?
|
override val convoVolatile: ConversationVolatileConfig?
|
||||||
get() = synchronized(convoVolatileLock) {
|
get() = synchronizedWithLog(convoVolatileLock) {
|
||||||
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
||||||
if (_convoVolatileConfig == null) {
|
if (_convoVolatileConfig == null) {
|
||||||
val (secretKey, publicKey) = maybeGetUserInfo() ?: return@synchronized null
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
||||||
val convoDump = configDatabase.retrieveConfigAndHashes(
|
val convoDump = configDatabase.retrieveConfigAndHashes(
|
||||||
SharedConfigMessage.Kind.CONVO_INFO_VOLATILE.name,
|
SharedConfigMessage.Kind.CONVO_INFO_VOLATILE.name,
|
||||||
publicKey
|
publicKey
|
||||||
@ -122,10 +132,10 @@ class ConfigFactory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val userGroups: UserGroupsConfig?
|
override val userGroups: UserGroupsConfig?
|
||||||
get() = synchronized(userGroupsLock) {
|
get() = synchronizedWithLog(userGroupsLock) {
|
||||||
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
if (!ConfigBase.isNewConfigEnabled(isConfigForcedOn, SnodeAPI.nowWithOffset)) return null
|
||||||
if (_userGroups == null) {
|
if (_userGroups == null) {
|
||||||
val (secretKey, publicKey) = maybeGetUserInfo() ?: return@synchronized null
|
val (secretKey, publicKey) = maybeGetUserInfo() ?: return null
|
||||||
val userGroupsDump = configDatabase.retrieveConfigAndHashes(
|
val userGroupsDump = configDatabase.retrieveConfigAndHashes(
|
||||||
SharedConfigMessage.Kind.GROUPS.name,
|
SharedConfigMessage.Kind.GROUPS.name,
|
||||||
publicKey
|
publicKey
|
||||||
|
@ -175,15 +175,17 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
|||||||
}
|
}
|
||||||
binding.sessionToolbar.disableClipping()
|
binding.sessionToolbar.disableClipping()
|
||||||
// Set up seed reminder view
|
// Set up seed reminder view
|
||||||
val hasViewedSeed = textSecurePreferences.getHasViewedSeed()
|
lifecycleScope.launchWhenStarted {
|
||||||
if (!hasViewedSeed) {
|
val hasViewedSeed = textSecurePreferences.getHasViewedSeed()
|
||||||
binding.seedReminderView.isVisible = true
|
if (!hasViewedSeed) {
|
||||||
binding.seedReminderView.title = SpannableString("You're almost finished! 80%") // Intentionally not yet translated
|
binding.seedReminderView.isVisible = true
|
||||||
binding.seedReminderView.subtitle = resources.getString(R.string.view_seed_reminder_subtitle_1)
|
binding.seedReminderView.title = SpannableString("You're almost finished! 80%") // Intentionally not yet translated
|
||||||
binding.seedReminderView.setProgress(80, false)
|
binding.seedReminderView.subtitle = resources.getString(R.string.view_seed_reminder_subtitle_1)
|
||||||
binding.seedReminderView.delegate = this@HomeActivity
|
binding.seedReminderView.setProgress(80, false)
|
||||||
} else {
|
binding.seedReminderView.delegate = this@HomeActivity
|
||||||
binding.seedReminderView.isVisible = false
|
} else {
|
||||||
|
binding.seedReminderView.isVisible = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setupMessageRequestsBanner()
|
setupMessageRequestsBanner()
|
||||||
// Set up recycler view
|
// Set up recycler view
|
||||||
|
Loading…
x
Reference in New Issue
Block a user