mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-24 02:47:44 +00:00
feat: start to implement group list info classes and wrappers and refactor to use library based hashes
This commit is contained in:
@@ -73,7 +73,7 @@ data class ConfigurationSyncJob(val destination: Destination): Job {
|
||||
}
|
||||
|
||||
val toDeleteRequest = configsRequiringPush.map { base ->
|
||||
configFactory.getHashesFor(base)
|
||||
base.obsoleteHashes()
|
||||
// accumulate by adding together
|
||||
}.reduce(List<String>::plus).let { toDeleteFromAllNamespaces ->
|
||||
if (toDeleteFromAllNamespaces.isEmpty()) null
|
||||
@@ -137,11 +137,9 @@ data class ConfigurationSyncJob(val destination: Destination): Job {
|
||||
// confirm pushed seqno
|
||||
val thisSeqNo = toPushMessage.seqNo
|
||||
config.confirmPushed(thisSeqNo, insertHash)
|
||||
config.
|
||||
// wipe any of the existing hashes which we deleted (they may or may not be in this namespace)
|
||||
if (configFactory.removeHashesFor(config, deletedHashes.toSet())) {
|
||||
Log.d(TAG, "Successfully removed the deleted hashes from ${config.javaClass.simpleName}")
|
||||
}
|
||||
config.removeObsoleteHashes(deletedHashes.toTypedArray())
|
||||
Log.d(TAG, "Successfully removed the deleted hashes from ${config.javaClass.simpleName}")
|
||||
// dump and write config after successful
|
||||
if (config.needsDump()) { // usually this will be true?
|
||||
configFactory.persist(config)
|
||||
|
||||
@@ -137,7 +137,7 @@ class Poller(private val configFactory: ConfigFactoryProtocol, debounceTimer: Ti
|
||||
namespace,
|
||||
updateLatestHash = false,
|
||||
updateStoredHashes = false,
|
||||
).filter { (_, hash) -> !configFactory.getHashesFor(forConfigObject).contains(hash) }
|
||||
).filter { (_, hash) -> !forConfigObject.obsoleteHashes().contains(hash) }
|
||||
|
||||
if (messages.isEmpty()) {
|
||||
// no new messages to process
|
||||
@@ -153,8 +153,7 @@ class Poller(private val configFactory: ConfigFactoryProtocol, debounceTimer: Ti
|
||||
return@forEach
|
||||
}
|
||||
Log.d("Loki-DBG", "Merging config of kind ${message.kind} into ${forConfigObject.javaClass.simpleName}")
|
||||
forConfigObject.merge(message.data)
|
||||
configFactory.appendHash(forConfigObject, hash!!)
|
||||
forConfigObject.merge(hash!! to message.data)
|
||||
} catch (e: Exception) {
|
||||
Log.e("Loki", e)
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ interface ConfigFactoryProtocol {
|
||||
val contacts: Contacts?
|
||||
val convoVolatile: ConversationVolatileConfig?
|
||||
fun persist(forConfigObject: ConfigBase)
|
||||
fun appendHash(configObject: ConfigBase, hash: String)
|
||||
fun getHashesFor(forConfigObject: ConfigBase): List<String>
|
||||
fun removeHashesFor(config: ConfigBase, deletedHashes: Set<String>): Boolean
|
||||
}
|
||||
|
||||
interface ConfigFactoryUpdateListener {
|
||||
|
||||
Reference in New Issue
Block a user