From 281b8dac33208a181636b312289870370ab6d43f Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Wed, 3 May 2023 19:26:40 +1000 Subject: [PATCH] fix: checking the last read open to message and make sure that scroll behaviour matches expected, fix the config sync job not deleting ALL old hashes only latest --- .../conversation/v2/ConversationActivityV2.kt | 3 +++ .../messaging/jobs/ConfigurationSyncJob.kt | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 3448150ba1..1bcd0639ee 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -440,6 +440,9 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) { // only update the conversation every 3 seconds maximum // channel is rendezvous and shouldn't block on try send calls as often as we want + val layoutManager = binding?.conversationRecyclerView?.layoutManager as? LinearLayoutManager ?: return@repeatOnLifecycle + val lastItemPos = layoutManager.findLastCompletelyVisibleItemPosition() +// adapter.item withContext(Dispatchers.IO) { storage.markConversationAsRead(viewModel.threadId, SnodeAPI.nowWithOffset) } diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/ConfigurationSyncJob.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/ConfigurationSyncJob.kt index fabf76e5b2..c046658dfc 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/ConfigurationSyncJob.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/ConfigurationSyncJob.kt @@ -54,17 +54,12 @@ data class ConfigurationSyncJob(val destination: Destination): Job { if (configsRequiringPush.isEmpty()) return delegate.handleJobSucceeded(this, dispatcherName) // need to get the current hashes before we call `push()` - val toDeleteRequest = configsRequiringPush.map { base -> - // accumulate by adding together - base.currentHashes() - }.reduce(List::plus).let { toDeleteFromAllNamespaces -> - if (toDeleteFromAllNamespaces.isEmpty()) null - else SnodeAPI.buildAuthenticatedDeleteBatchInfo(destination.destinationPublicKey(), toDeleteFromAllNamespaces) - } + val toDeleteHashes = mutableListOf() // allow null results here so the list index matches configsRequiringPush val batchObjects: List?> = configsRequiringPush.map { config -> - val (data, seqNo) = config.push() + val (data, seqNo, obsoleteHashes) = config.push() + toDeleteHashes += obsoleteHashes SharedConfigurationMessage(config.protoKindFor(), data, seqNo) to config }.map { (message, config) -> // return a list of batch request objects @@ -77,6 +72,11 @@ data class ConfigurationSyncJob(val destination: Destination): Job { message to authenticated // to keep track of seqNo for calling confirmPushed later } + val toDeleteRequest = toDeleteHashes.let { toDeleteFromAllNamespaces -> + if (toDeleteFromAllNamespaces.isEmpty()) null + else SnodeAPI.buildAuthenticatedDeleteBatchInfo(destination.destinationPublicKey(), toDeleteFromAllNamespaces) + } + if (batchObjects.any { it == null }) { // stop running here, something like a signing error occurred return delegate.handleJobFailedPermanently(this, dispatcherName, NullPointerException("One or more requests had a null batch request info"))