mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Remove main-thread usage of Recipient.self.
This commit is contained in:
committed by
Cody Henthorne
parent
83bbcd0618
commit
dac3a332d7
@@ -129,7 +129,7 @@ enum class MainToolbarMode {
|
||||
|
||||
data class MainToolbarState(
|
||||
val toolbarColor: Color? = null,
|
||||
val self: Recipient = Recipient.self(),
|
||||
val self: Recipient = Recipient.UNKNOWN,
|
||||
val mode: MainToolbarMode = MainToolbarMode.FULL,
|
||||
val destination: MainNavigationListLocation = MainNavigationListLocation.CHATS,
|
||||
val chatFilter: ConversationFilter = ConversationFilter.OFF,
|
||||
|
||||
@@ -18,6 +18,8 @@ import kotlinx.coroutines.flow.filterIsInstance
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.rx3.asFlowable
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.signal.core.util.concurrent.SignalDispatchers
|
||||
import org.thoughtcrime.securesms.backup.v2.BackupRepository
|
||||
import org.thoughtcrime.securesms.calls.log.CallLogFilter
|
||||
import org.thoughtcrime.securesms.conversationlist.model.ConversationFilter
|
||||
@@ -31,9 +33,18 @@ class MainToolbarViewModel : ViewModel() {
|
||||
val state: StateFlow<MainToolbarState> = internalStateFlow
|
||||
|
||||
fun refresh() {
|
||||
viewModelScope.launch {
|
||||
val self = withContext(SignalDispatchers.IO) {
|
||||
Recipient.self().resolve()
|
||||
}
|
||||
|
||||
internalStateFlow.update {
|
||||
it.copy(self = self)
|
||||
}
|
||||
}
|
||||
|
||||
internalStateFlow.update {
|
||||
it.copy(
|
||||
self = Recipient.self(),
|
||||
hasFailedBackups = BackupRepository.shouldDisplayBackupFailedIndicator() || BackupRepository.shouldDisplayBackupAlreadyRedeemedIndicator(),
|
||||
hasPassphrase = !SignalStore.settings.passphraseDisabled
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user