Merge pull request #1057 from session-foundation/merge-1.21.3

Bring 1.21.3 to dev
pull/1713/head
SessionHero01 4 weeks ago committed by GitHub
commit 1420612876
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -15,7 +15,7 @@ configurations.configureEach {
exclude module: "commons-logging"
}
def canonicalVersionCode = 399
def canonicalVersionCode = 401
def canonicalVersionName = "1.21.3"
def postFixSize = 10

@ -690,11 +690,7 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
if (author != null && messageTimestamp >= 0) {
jumpToMessage(author, messageTimestamp, firstLoad.get(), null)
} else {
if (firstLoad.getAndSet(false)) {
lifecycleScope.launch(Dispatchers.Main) {
scrollToFirstUnreadMessageIfNeeded(true)
}
}
if (firstLoad.getAndSet(false)) scrollToFirstUnreadMessageIfNeeded(true)
handleRecyclerViewScrolled()
}
}
@ -1045,13 +1041,9 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate,
}
}
private suspend fun scrollToFirstUnreadMessageIfNeeded(isFirstLoad: Boolean = false, shouldHighlight: Boolean = false): Int {
val lastSeenItemPosition = withContext(Dispatchers.Default) {
val lastSeenTimestamp = threadDb.getLastSeenAndHasSent(viewModel.threadId).first()
adapter.findLastSeenItemPosition(lastSeenTimestamp)
}
if(lastSeenItemPosition == null) return -1
private fun scrollToFirstUnreadMessageIfNeeded(isFirstLoad: Boolean = false, shouldHighlight: Boolean = false): Int {
val lastSeenTimestamp = threadDb.getLastSeenAndHasSent(viewModel.threadId).first()
val lastSeenItemPosition = adapter.findLastSeenItemPosition(lastSeenTimestamp) ?: return -1
// If this is triggered when first opening a conversation then we want to position the top
// of the first unread message in the middle of the screen

@ -299,6 +299,8 @@ class GroupManagerV2Impl @Inject constructor(
configs.groupInfo.getName().orEmpty()
}
Log.w(TAG, "Failed to invite members to group $group", e)
throw GroupInviteException(
isPromotion = false,
inviteeAccountIds = newMembers.map { it.hexString },

@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChanged
@ -25,12 +26,14 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onErrorResume
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
import network.loki.messenger.R
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_HIDDEN
import org.session.libsession.utilities.ConfigUpdateNotification
import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsignal.utilities.Log
import org.session.libsession.utilities.UsernameUtils
import org.thoughtcrime.securesms.database.DatabaseContentProviders
import org.thoughtcrime.securesms.database.ThreadDatabase
@ -101,9 +104,11 @@ class HomeViewModel @Inject constructor(
)
}
}
)
}
.stateIn(viewModelScope, SharingStarted.Eagerly, null)
) as? Data?
}.catch { err ->
Log.e("HomeViewModel", "Error loading conversation list", err)
emit(null)
}.stateIn(viewModelScope, SharingStarted.Eagerly, null)
private fun hasHiddenMessageRequests() = TextSecurePreferences.events
.filter { it == TextSecurePreferences.HAS_HIDDEN_MESSAGE_REQUESTS }

@ -21,6 +21,7 @@ import org.session.libsession.utilities.getGroup
import org.session.libsignal.protos.SignalServiceProtos.DataMessage.GroupUpdateInviteMessage
import org.session.libsignal.protos.SignalServiceProtos.DataMessage.GroupUpdateMessage
import org.session.libsignal.utilities.AccountId
import org.session.libsignal.utilities.Log
class InviteContactsJob(val groupSessionId: String, val memberSessionIds: Array<String>) : Job {
@ -100,18 +101,31 @@ class InviteContactsJob(val groupSessionId: String, val memberSessionIds: Array<
val groupName = configs.withGroupConfigs(sessionId) { it.groupInfo.getName() }
?: configs.getGroup(sessionId)?.name
val failures = results.filter { it.second.isFailure }
// Gather all the exceptions, while keeping track of the invitee account IDs
val failures = results.mapNotNull { (id, result) ->
result.exceptionOrNull()?.let { err -> id to err }
}
// if there are failed invites, display a message
// assume job "success" even if we fail, the state of invites is tracked outside of this job
if (failures.isNotEmpty()) {
// show the failure toast
val toaster = MessagingModuleConfiguration.shared.toaster
val (_, firstError) = failures.first()
// Add the rest of the exceptions as suppressed
for ((_, suppressed) in failures.asSequence().drop(1)) {
firstError.addSuppressed(suppressed)
}
Log.w("InviteContactsJob", "Failed to invite contacts", firstError)
GroupInviteException(
isPromotion = false,
inviteeAccountIds = failures.map { it.first },
groupName = groupName.orEmpty(),
underlying = failures.first().second.exceptionOrNull()!!,
underlying = firstError,
).format(MessagingModuleConfiguration.shared.context,
MessagingModuleConfiguration.shared.usernameUtils).let {
withContext(Dispatchers.Main) {

@ -430,7 +430,7 @@ object MessageSender {
// Result Handling
fun handleSuccessfulMessageSend(message: Message, destination: Destination, isSyncMessage: Boolean = false, openGroupSentTimestamp: Long = -1) {
val threadId = message.threadID!!
val threadId by lazy { requireNotNull(message.threadID) { "threadID for the message is null" } }
if (message is VisibleMessage) MessagingModuleConfiguration.shared.lastSentTimestampCache.submitTimestamp(threadId, openGroupSentTimestamp)
val storage = MessagingModuleConfiguration.shared.storage
val userPublicKey = storage.getUserPublicKey()!!
@ -473,9 +473,9 @@ object MessageSender {
}
}
val encoded = GroupUtil.getEncodedOpenGroupID("$server.$room".toByteArray())
val threadID = storage.getThreadId(Address.fromSerialized(encoded))
if (threadID != null && threadID >= 0) {
storage.setOpenGroupServerMessageID(messageID, message.openGroupServerMessageID!!, threadID, !(message as VisibleMessage).isMediaMessage())
val communityThreadID = storage.getThreadId(Address.fromSerialized(encoded))
if (communityThreadID != null && communityThreadID >= 0) {
storage.setOpenGroupServerMessageID(messageID, message.openGroupServerMessageID!!, communityThreadID, !(message as VisibleMessage).isMediaMessage())
}
}

Loading…
Cancel
Save