mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 02:55:23 +00:00
fix: getters weren't getters properly in the config factory, fixed new onboarding from configs
This commit is contained in:
parent
e159e4ad52
commit
548862c37d
@ -116,6 +116,7 @@ import kotlin.Unit;
|
||||
import kotlinx.coroutines.Job;
|
||||
import network.loki.messenger.BuildConfig;
|
||||
import network.loki.messenger.libsession_util.ConfigBase;
|
||||
import network.loki.messenger.libsession_util.UserProfile;
|
||||
|
||||
/**
|
||||
* Will be called once when the TextSecure process is created.
|
||||
@ -203,6 +204,9 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
||||
@Override
|
||||
public void notifyUpdates(@NonNull ConfigBase forConfigObject) {
|
||||
// forward to the config factory / storage ig
|
||||
if (forConfigObject instanceof UserProfile && !textSecurePreferences.getConfigurationMessageSynced()) {
|
||||
textSecurePreferences.setConfigurationMessageSynced(true);
|
||||
}
|
||||
storage.notifyConfigUpdates(forConfigObject);
|
||||
}
|
||||
@Override
|
||||
|
@ -2,10 +2,12 @@ package org.thoughtcrime.securesms.database
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import androidx.core.database.getStringOrNull
|
||||
import android.database.Cursor
|
||||
import androidx.core.database.getStringOrNull
|
||||
import org.session.libsession.messaging.contacts.Contact
|
||||
import org.session.libsession.messaging.utilities.SessionId
|
||||
import org.session.libsignal.utilities.Base64
|
||||
import org.session.libsignal.utilities.IdPrefix
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||
|
||||
class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper) {
|
||||
@ -43,6 +45,9 @@ class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Da
|
||||
val database = databaseHelper.readableDatabase
|
||||
return database.getAll(sessionContactTable, null, null) { cursor ->
|
||||
contactFromCursor(cursor)
|
||||
}.filter { contact ->
|
||||
val sessionId = SessionId(contact.sessionID)
|
||||
sessionId.prefix == IdPrefix.STANDARD
|
||||
}.toSet()
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import network.loki.messenger.libsession_util.UserProfile
|
||||
import org.session.libsession.utilities.ConfigFactoryProtocol
|
||||
import org.session.libsession.utilities.ConfigFactoryUpdateListener
|
||||
import org.session.libsignal.protos.SignalServiceProtos.SharedConfigMessage
|
||||
import org.session.libsignal.utilities.Log
|
||||
import org.thoughtcrime.securesms.database.ConfigDatabase
|
||||
import java.util.concurrent.ConcurrentSkipListSet
|
||||
|
||||
@ -39,9 +40,11 @@ class ConfigFactory(private val context: Context,
|
||||
fun registerListener(listener: ConfigFactoryUpdateListener) { listeners += listener }
|
||||
fun unregisterListener(listener: ConfigFactoryUpdateListener) { listeners -= listener }
|
||||
|
||||
override val user: UserProfile? = synchronized(userLock) {
|
||||
override val user: UserProfile? get() = synchronized(userLock) {
|
||||
if (_userConfig == null) {
|
||||
Log.d("Loki-DBG", "Getting user info")
|
||||
val (secretKey, publicKey) = maybeGetUserInfo() ?: return@synchronized null
|
||||
Log.d("Loki-DBG", "Getting user configs and hashes")
|
||||
val userDump = configDatabase.retrieveConfigAndHashes(SharedConfigMessage.Kind.USER_PROFILE.name, publicKey)
|
||||
_userConfig = if (userDump != null) {
|
||||
val (bytes, hashes) = userDump
|
||||
@ -55,7 +58,7 @@ class ConfigFactory(private val context: Context,
|
||||
_userConfig
|
||||
}
|
||||
|
||||
override val contacts: Contacts? = synchronized(contactsLock) {
|
||||
override val contacts: Contacts? get() = synchronized(contactsLock) {
|
||||
if (_contacts == null) {
|
||||
val (secretKey, publicKey) = maybeGetUserInfo() ?: return@synchronized null
|
||||
val contactsDump = configDatabase.retrieveConfigAndHashes(SharedConfigMessage.Kind.CONTACTS.name, publicKey)
|
||||
@ -71,7 +74,7 @@ class ConfigFactory(private val context: Context,
|
||||
_contacts
|
||||
}
|
||||
|
||||
override val convoVolatile: ConversationVolatileConfig? = synchronized(convoVolatileLock) {
|
||||
override val convoVolatile: ConversationVolatileConfig? get() = synchronized(convoVolatileLock) {
|
||||
if (_convoVolatileConfig == null) {
|
||||
val (secretKey, publicKey) = maybeGetUserInfo() ?: return@synchronized null
|
||||
val convoDump = configDatabase.retrieveConfigAndHashes(SharedConfigMessage.Kind.CONVO_INFO_VOLATILE.name, publicKey)
|
||||
|
@ -133,9 +133,8 @@ class LinkDeviceActivity : BaseActionBarActivity(), ScanQRCodeWrapperFragmentDel
|
||||
.setAction(R.string.registration_activity__skip) { register(true) }
|
||||
|
||||
val skipJob = launch {
|
||||
delay(30_000L)
|
||||
delay(15_000L)
|
||||
snackBar.show()
|
||||
// show a dialog or something saying do you want to skip this bit?
|
||||
}
|
||||
// start polling and wait for updated message
|
||||
ApplicationContext.getInstance(this@LinkDeviceActivity).apply {
|
||||
|
@ -187,6 +187,12 @@ class Poller(private val configFactory: ConfigFactoryProtocol, debounceTimer: Ti
|
||||
requestSparseArray[request.namespace!!] = request
|
||||
}
|
||||
|
||||
if (requestSparseArray.size() == 1) {
|
||||
// only one (the personal messages)
|
||||
Log.d("Loki-DBG", "Not building requests for the configs, current config state:")
|
||||
Log.d("Loki-DBG", "${listOf(configFactory.user, configFactory.contacts, configFactory.convoVolatile)}")
|
||||
}
|
||||
|
||||
val requests = requestSparseArray.valueIterator().asSequence().toList()
|
||||
|
||||
SnodeAPI.getRawBatchResponse(snode, userPublicKey, requests).bind { rawResponses ->
|
||||
|
Loading…
Reference in New Issue
Block a user