diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f0b0765605..0a36d74a77 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -26,7 +26,7 @@ configurations.configureEach { exclude(module = "commons-logging") } -val canonicalVersionCode = 427 +val canonicalVersionCode = 429 val canonicalVersionName = "1.30.0" val postFixSize = 10 diff --git a/app/src/main/java/org/thoughtcrime/securesms/attachments/AvatarUploadManager.kt b/app/src/main/java/org/thoughtcrime/securesms/attachments/AvatarUploadManager.kt index bbd7d83918..92a4bd51f2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/attachments/AvatarUploadManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/attachments/AvatarUploadManager.kt @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.attachments import android.app.Application import android.os.FileObserver +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -95,11 +96,17 @@ class AvatarUploadManager @Inject constructor( } Log.d(TAG, "Avatar expired, re-uploading") - uploadAvatar( - pictureData = localEncryptedFileInputStreamFactory.create(localFile) - .use { it.readBytes() }, - isReupload = true, - ) + try { + uploadAvatar( + pictureData = localEncryptedFileInputStreamFactory.create(localFile) + .use { it.readBytes() }, + isReupload = true, + ) + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + Log.w(TAG, "Failed to re-upload avatar", e) + } } } else { emptyFlow() diff --git a/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt b/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt index 15d3a7fede..4fae3a59fb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/configs/ConfigToDatabaseSync.kt @@ -8,6 +8,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.map @@ -58,6 +59,7 @@ import org.thoughtcrime.securesms.util.castAwayType import java.util.EnumSet import java.util.concurrent.TimeUnit import javax.inject.Inject +import kotlin.math.log private const val TAG = "ConfigToDatabaseSync" @@ -93,17 +95,20 @@ class ConfigToDatabaseSync @Inject constructor( // Sync conversations from config -> database scope.launch { preferences.watchLocalNumber() - .filterNotNull() - .take(1) - .flatMapLatest { - combine( - conversationRepository.conversationListAddressesFlow, - configFactory.userConfigsChanged(EnumSet.of(UserConfigType.CONVO_INFO_VOLATILE)) - .castAwayType() - .onStart { emit(Unit) } - .map { _ -> configFactory.withUserConfigs { it.convoInfoVolatile.all() } }, - ::Pair - ) + .map { it != null } + .flatMapLatest { loggedIn -> + if (loggedIn) { + combine( + conversationRepository.conversationListAddressesFlow, + configFactory.userConfigsChanged(EnumSet.of(UserConfigType.CONVO_INFO_VOLATILE)) + .castAwayType() + .onStart { emit(Unit) } + .map { _ -> configFactory.withUserConfigs { it.convoInfoVolatile.all() } }, + ::Pair + ) + } else { + emptyFlow() + } } .distinctUntilChanged() .collectLatest { (conversations, convoInfo) -> 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 f69b716d6c..b10b11d0c4 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 @@ -1809,7 +1809,7 @@ class ConversationActivityV2 : ScreenLockActionBarActivity(), InputBarDelegate, message.reaction = Reaction.from( timestamp = originalMessage.timestamp, - author = originalAuthor.address, + author = originalAuthor.address, emoji = emoji, react = false ) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/BlindMappingRepository.kt b/app/src/main/java/org/thoughtcrime/securesms/database/BlindMappingRepository.kt index 630663cc05..fe1959dc78 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/BlindMappingRepository.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/BlindMappingRepository.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.filterNotNull +import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart @@ -43,21 +43,24 @@ class BlindMappingRepository @Inject constructor( */ @Suppress("OPT_IN_USAGE") val mappings: StateFlow>> = prefs.watchLocalNumber() - .filterNotNull() .flatMapLatest { localAddress -> - configFactory - .userConfigsChanged(setOf(UserConfigType.USER_GROUPS, UserConfigType.CONTACTS)) - .castAwayType() - .onStart { emit(Unit) } - .map { - configFactory.withUserConfigs { configs -> - Pair( - configs.userGroups.allCommunityInfo().map { it.community }, - configs.contacts.all().map { Address.Standard(AccountId(it.id)) } - + Address.Standard(AccountId(localAddress)) - ) + if (localAddress.isNullOrBlank()) { + emptyFlow() + } else { + configFactory + .userConfigsChanged(setOf(UserConfigType.USER_GROUPS, UserConfigType.CONTACTS)) + .castAwayType() + .onStart { emit(Unit) } + .map { + configFactory.withUserConfigs { configs -> + Pair( + configs.userGroups.allCommunityInfo().map { it.community }, + configs.contacts.all().map { Address.Standard(AccountId(it.id)) } + + Address.Standard(AccountId(localAddress)) + ) + } } - } + } } .distinctUntilChanged() .map { (allCommunities, allContacts) -> diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/RecipientRepository.kt b/app/src/main/java/org/thoughtcrime/securesms/database/RecipientRepository.kt index e10d248e0f..a1898ef9ca 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/RecipientRepository.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/RecipientRepository.kt @@ -12,6 +12,7 @@ import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterIsInstance import kotlinx.coroutines.flow.filterNotNull @@ -95,9 +96,13 @@ class RecipientRepository @Inject constructor( fun observeSelf(): Flow { return preferences.watchLocalNumber() - .filterNotNull() - .distinctUntilChanged() - .flatMapLatest { observeRecipient(it.toAddress()) } + .flatMapLatest { + if (it.isNullOrBlank()) { + emptyFlow() + } else { + observeRecipient(it.toAddress()) + } + } } fun getSelf(): Recipient {