mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-07 05:48:09 +01:00
Move some usages of Dispatchers.IO to Dispatchers.Default.
This commit is contained in:
@@ -50,7 +50,7 @@ object ArchiveUploadProgress {
|
||||
|
||||
private val TAG = Log.tag(ArchiveUploadProgress::class)
|
||||
|
||||
private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
private val scope = CoroutineScope(Dispatchers.Default + SupervisorJob())
|
||||
|
||||
private val _progress: MutableSharedFlow<Unit> = MutableSharedFlow(replay = 1)
|
||||
|
||||
@@ -119,7 +119,7 @@ object ArchiveUploadProgress {
|
||||
updateState(notify = false) { updated }
|
||||
}
|
||||
.onStart { emit(uploadProgress) }
|
||||
.flowOn(Dispatchers.IO)
|
||||
.flowOn(Dispatchers.Default)
|
||||
.shareIn(scope, SharingStarted.Eagerly, replay = 1)
|
||||
|
||||
init {
|
||||
|
||||
@@ -82,7 +82,7 @@ object ArchiveRestoreProgress {
|
||||
val stateFlow: Flow<ArchiveRestoreProgressState> = store
|
||||
.throttleLatest(1.seconds)
|
||||
.distinctUntilChanged()
|
||||
.flowOn(Dispatchers.IO)
|
||||
.flowOn(Dispatchers.Default)
|
||||
|
||||
init {
|
||||
SignalExecutors.BOUNDED.execute { update() }
|
||||
|
||||
@@ -646,7 +646,7 @@ object BackupRepository {
|
||||
val state = SignalStore.backup.backupDownloadNotifierState ?: return null
|
||||
val nextSheetDisplayTime = state.lastSheetDisplaySeconds.seconds + state.intervalSeconds.seconds
|
||||
|
||||
val remainingAttachmentSize = withContext(SignalDispatchers.IO) {
|
||||
val remainingAttachmentSize = withContext(SignalDispatchers.Default) {
|
||||
SignalDatabase.attachments.getRemainingRestorableAttachmentSize()
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ object BackupAlertDelegate {
|
||||
}
|
||||
|
||||
private suspend fun displayBackupDownloadNotifier(fragmentManager: FragmentManager) {
|
||||
val downloadYourBackupToday = withContext(SignalDispatchers.IO) { BackupRepository.getDownloadYourBackupData() }
|
||||
val downloadYourBackupToday = withContext(SignalDispatchers.Default) { BackupRepository.getDownloadYourBackupData() }
|
||||
when (downloadYourBackupToday?.type) {
|
||||
BackupDownloadNotifierState.Type.SHEET -> {
|
||||
Log.d(TAG, "Displaying 'Download your backup today' sheet.")
|
||||
|
||||
+2
-2
@@ -145,7 +145,7 @@ class MessageBackupsFlowViewModel(
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.d(TAG, "Failed to handle purchase.", e)
|
||||
withContext(SignalDispatchers.IO) {
|
||||
withContext(SignalDispatchers.Default) {
|
||||
InAppPaymentsRepository.handlePipelineError(
|
||||
inAppPaymentId = id,
|
||||
error = e
|
||||
@@ -297,7 +297,7 @@ class MessageBackupsFlowViewModel(
|
||||
private fun validateTypeAndUpdateState(state: MessageBackupsFlowState): MessageBackupsFlowState {
|
||||
return when (state.selectedMessageBackupTier!!) {
|
||||
MessageBackupTier.FREE -> {
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
viewModelScope.launch(SignalDispatchers.Default) {
|
||||
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ class MonthlyDonationCanceledViewModel(
|
||||
|
||||
private fun initializeFromInAppPaymentId(inAppPaymentId: InAppPaymentTable.InAppPaymentId) {
|
||||
viewModelScope.launch {
|
||||
val inAppPayment = withContext(Dispatchers.IO) {
|
||||
val inAppPayment = withContext(Dispatchers.Default) {
|
||||
SignalDatabase.inAppPayments.getById(inAppPaymentId)
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class NewCallViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
private suspend fun resolveAndStartCall(id: RecipientId) {
|
||||
val recipient = withContext(Dispatchers.IO) {
|
||||
val recipient = withContext(Dispatchers.Default) {
|
||||
Recipient.resolved(id)
|
||||
}
|
||||
openCall(recipient)
|
||||
|
||||
+1
-1
@@ -180,7 +180,7 @@ class AppSettingsFragment : ComposeFragment(), Callbacks {
|
||||
@StringRes toastSuccessStringRes: Int
|
||||
) {
|
||||
lifecycleScope.launch {
|
||||
val subscriber = withContext(Dispatchers.IO) {
|
||||
val subscriber = withContext(Dispatchers.Default) {
|
||||
InAppPaymentsRepository.getSubscriber(subscriberType)
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -58,7 +58,7 @@ class BackupStateObserver(
|
||||
companion object {
|
||||
private val TAG = Log.tag(BackupStateObserver::class)
|
||||
|
||||
private val staticScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
private val staticScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
private val backupTierChangedNotifier = MutableSharedFlow<Unit>()
|
||||
|
||||
/**
|
||||
@@ -107,13 +107,13 @@ class BackupStateObserver(
|
||||
}
|
||||
}
|
||||
|
||||
scope.launch(SignalDispatchers.IO) {
|
||||
scope.launch(SignalDispatchers.Default) {
|
||||
backupTierChangedNotifier.collect {
|
||||
requestBackupStateRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
scope.launch(SignalDispatchers.IO) {
|
||||
scope.launch(SignalDispatchers.Default) {
|
||||
InternetConnectionObserver.observe().asFlow()
|
||||
.collect {
|
||||
if (backupState.value is BackupState.Error) {
|
||||
@@ -122,19 +122,19 @@ class BackupStateObserver(
|
||||
}
|
||||
}
|
||||
|
||||
scope.launch(SignalDispatchers.IO) {
|
||||
scope.launch(SignalDispatchers.Default) {
|
||||
InAppPaymentsRepository.observeLatestBackupPayment().collect {
|
||||
requestBackupStateRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
scope.launch(SignalDispatchers.IO) {
|
||||
scope.launch(SignalDispatchers.Default) {
|
||||
SignalStore.backup.subscriptionStateMismatchDetectedFlow.collect {
|
||||
requestBackupStateRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
scope.launch(SignalDispatchers.IO) {
|
||||
scope.launch(SignalDispatchers.Default) {
|
||||
SignalStore.backup.deletionStateFlow.collect {
|
||||
requestBackupStateRefresh()
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ class BackupsSettingsViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
SignalStore.backup.lastBackupTimeFlow
|
||||
.collect { lastBackupTime ->
|
||||
internalStateFlow.update {
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ class BackupKeyDisplayViewModel : ViewModel(), BackupKeyCredentialManagerHandler
|
||||
viewModelScope.launch {
|
||||
internalUiState.update { it.copy(rotationState = BackupKeyRotationState.GENERATING_KEY) }
|
||||
|
||||
val stagedKeyRotations = withContext(SignalDispatchers.IO) {
|
||||
val stagedKeyRotations = withContext(SignalDispatchers.Default) {
|
||||
BackupRepository.stageBackupKeyRotations()
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -143,7 +143,7 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
var optimizedRemainingBytes = 0L
|
||||
while (isActive) {
|
||||
if (ArchiveRestoreProgress.state.let { it.restoreState.isMediaRestoreOperation || it.restoreStatus == RestoreStatus.FINISHED }) {
|
||||
@@ -194,7 +194,7 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
BackupRepository.maybeFixAnyDanglingUploadProgress()
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -24,7 +24,7 @@ class ChatFoldersViewModel : ViewModel() {
|
||||
val state = internalState.asStateFlow()
|
||||
|
||||
fun loadCurrentFolders(context: Context) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val folders = ChatFoldersRepository.getCurrentFolders()
|
||||
val suggestedFolders = getSuggestedFolders(context, folders)
|
||||
|
||||
@@ -93,7 +93,7 @@ class ChatFoldersViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun setCurrentFolder(folder: ChatFolderRecord) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val includedRecipients = folder.includedChats.mapNotNull { threadId ->
|
||||
SignalDatabase.threads.getRecipientForThreadId(threadId)
|
||||
}
|
||||
@@ -150,7 +150,7 @@ class ChatFoldersViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun deleteFolder(context: Context) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
ChatFoldersRepository.deleteFolder(internalState.value.originalFolder.folderRecord)
|
||||
|
||||
loadCurrentFolders(context)
|
||||
@@ -167,7 +167,7 @@ class ChatFoldersViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun createFolder(context: Context, folder: ChatFolderRecord? = null) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val currentFolder = if (folder != null) ChatFolder(folder) else internalState.value.currentFolder
|
||||
ChatFoldersRepository.createFolder(currentFolder.folderRecord, currentFolder.includedRecipients, currentFolder.excludedRecipients)
|
||||
loadCurrentFolders(context)
|
||||
@@ -192,13 +192,13 @@ class ChatFoldersViewModel : ViewModel() {
|
||||
val updatedFolders = state.value.folders.mapIndexed { index, chatFolderRecord ->
|
||||
chatFolderRecord.copy(position = index)
|
||||
}
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
ChatFoldersRepository.updatePositions(updatedFolders)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateFolder(context: Context) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val currentFolder = internalState.value.currentFolder
|
||||
ChatFoldersRepository.updateFolder(currentFolder.folderRecord, currentFolder.includedRecipients, currentFolder.excludedRecipients)
|
||||
loadCurrentFolders(context)
|
||||
@@ -210,7 +210,7 @@ class ChatFoldersViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun setPendingChats() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val currentFolder = internalState.value.currentFolder
|
||||
val includedChats = currentFolder.includedRecipients.map { recipient -> recipient.id }.toMutableSet()
|
||||
val excludedChats = currentFolder.excludedRecipients.map { recipient -> recipient.id }.toMutableSet()
|
||||
@@ -304,7 +304,7 @@ class ChatFoldersViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun savePendingChats() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val updatedFolder = internalState.value.currentFolder
|
||||
val includedChatIds = internalState.value.pendingIncludedRecipients
|
||||
val excludedChatIds = internalState.value.pendingExcludedRecipients
|
||||
@@ -346,7 +346,7 @@ class ChatFoldersViewModel : ViewModel() {
|
||||
|
||||
fun setCurrentFolderId(folderId: Long) {
|
||||
if (folderId != -1L) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val folder = ChatFoldersRepository.getFolder(folderId)
|
||||
setCurrentFolder(folder)
|
||||
}
|
||||
|
||||
+2
-2
@@ -352,7 +352,7 @@ class InternalBackupPlaygroundViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun loadStats() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
launch {
|
||||
var stats = SignalDatabase.attachments.debugGetAttachmentStats()
|
||||
|
||||
@@ -398,7 +398,7 @@ class InternalBackupPlaygroundViewModel : ViewModel() {
|
||||
return@withContext false
|
||||
}
|
||||
|
||||
suspend fun clearLocalMediaBackupState() = withContext(Dispatchers.IO) {
|
||||
suspend fun clearLocalMediaBackupState() = withContext(Dispatchers.Default) {
|
||||
SignalDatabase.attachments.clearAllArchiveData()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ class DataSeedingPlaygroundViewModel(application: Application) : AndroidViewMode
|
||||
val state: StateFlow<DataSeedingPlaygroundState> = _state.asStateFlow()
|
||||
|
||||
fun loadThreads() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
try {
|
||||
val threads = mutableListOf<ThreadWithRecipient>()
|
||||
val cursor: Cursor = SignalDatabase.threads.getRecentConversationList(
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ class InternalIssuesViewModel(application: Application) : AndroidViewModel(appli
|
||||
|
||||
private fun load() {
|
||||
viewModelScope.launch {
|
||||
allIssues = withContext(Dispatchers.IO) { issues.getRecent() }
|
||||
allIssues = withContext(Dispatchers.Default) { issues.getRecent() }
|
||||
_state.update { it.copy(loading = false, notificationPriority = SignalStore.internal.issueNotificationPriority).withVisibleIssues() }
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class InternalIssuesViewModel(application: Application) : AndroidViewModel(appli
|
||||
|
||||
private fun clearAll() {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) { issues.clear() }
|
||||
withContext(Dispatchers.Default) { issues.clear() }
|
||||
allIssues = emptyList()
|
||||
_state.update { it.copy(nameFilter = null, expandedIds = emptySet()).withVisibleIssues() }
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ class InternalSqlitePlaygroundViewModel : ViewModel() {
|
||||
get() = _queryResults
|
||||
|
||||
fun onQuerySubmitted(query: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
_queryResults.value = null
|
||||
|
||||
val startTime = System.nanoTime()
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer
|
||||
|
||||
// Calculating slow notification stuff isn't thread-safe, so we do it without to start off so we have most state populated, then fetch it in the background.
|
||||
store.update { getState(calculateSlowNotifications = false) }
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
store.update { getState(calculateSlowNotifications = true) }
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ class AdvancedPrivacySettingsViewModel(
|
||||
fun setAllowAutomaticVerification(enabled: Boolean) {
|
||||
SignalStore.settings.automaticVerificationEnabled = enabled
|
||||
refresh()
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
viewModelScope.launch(SignalDispatchers.Default) {
|
||||
if (!enabled) {
|
||||
SignalDatabase.recipients.clearAllKeyTransparencyData()
|
||||
SignalStore.account.distinguishedHead = null
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ class PhoneNumberPrivacySettingsViewModel : ViewModel() {
|
||||
val state: State<PhoneNumberPrivacySettingsState> = _state
|
||||
|
||||
init {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
while (isActive) {
|
||||
refresh()
|
||||
delay(5.seconds)
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ class ManageStorageSettingsViewModel : ViewModel() {
|
||||
val state = store.asStateFlow()
|
||||
|
||||
init {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
InAppPaymentsRepository.observeLatestBackupPayment()
|
||||
.collectLatest { payment ->
|
||||
store.update { it.copy(isPaidTierPending = payment.state == InAppPaymentTable.State.PENDING) }
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ class DonationPendingBottomSheetViewModel(
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
val inAppPayment = withContext(SignalDispatchers.IO) {
|
||||
val inAppPayment = withContext(SignalDispatchers.Default) {
|
||||
SignalDatabase.inAppPayments.getById(inAppPaymentId)!!
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ class InAppPaymentCheckoutDelegate(
|
||||
callback.onSubscriptionCancelled(InAppPaymentType.RECURRING_DONATION)
|
||||
} else {
|
||||
fragment.lifecycleScope.launch {
|
||||
val inAppPayment = withContext(SignalDispatchers.IO) {
|
||||
val inAppPayment = withContext(SignalDispatchers.Default) {
|
||||
SignalDatabase.inAppPayments.getById(result.inAppPaymentId!!)!!
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class CreditCardViewModel(
|
||||
val calendar = Calendar.getInstance()
|
||||
|
||||
viewModelScope.launch {
|
||||
val inAppPayment = withContext(Dispatchers.IO) {
|
||||
val inAppPayment = withContext(Dispatchers.Default) {
|
||||
SignalDatabase.inAppPayments.getById(inAppPaymentId)!!
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ object GatewaySelectorRepository {
|
||||
}
|
||||
|
||||
suspend fun setInAppPaymentMethodType(inAppPayment: InAppPaymentTable.InAppPayment, paymentMethodType: InAppPaymentData.PaymentMethodType): InAppPaymentTable.InAppPayment {
|
||||
return withContext(Dispatchers.IO) {
|
||||
return withContext(Dispatchers.Default) {
|
||||
SignalDatabase.inAppPayments.update(
|
||||
inAppPayment.copy(
|
||||
data = inAppPayment.data.copy(
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class PayPalCompleteOrderBottomSheet : DSLSettingsBottomSheetFragment() {
|
||||
PayPalCompleteOrderPaymentItem.register(adapter)
|
||||
|
||||
lifecycleScope.launch {
|
||||
val inAppPayment = withContext(SignalDispatchers.IO) {
|
||||
val inAppPayment = withContext(SignalDispatchers.Default) {
|
||||
SignalDatabase.inAppPayments.getById(args.inAppPaymentId)!!
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ class Stripe3DSDialogFragment : DialogFragment(R.layout.donation_webview_fragmen
|
||||
val progress = ProgressCardDialogFragment.create()
|
||||
progress.show(parentFragmentManager, null)
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
withContext(Dispatchers.Default) {
|
||||
SignalDatabase.inAppPayments.update(args.waitingForAuthPayment)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class IdealTransferDetailsViewModel(inAppPaymentId: InAppPaymentTable.InAppPayme
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
val inAppPayment = withContext(Dispatchers.IO) {
|
||||
val inAppPayment = withContext(Dispatchers.Default) {
|
||||
SignalDatabase.inAppPayments.getById(inAppPaymentId)!!
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ class BankTransferMandateViewModel(
|
||||
}
|
||||
|
||||
suspend fun getPaymentMethodType(): InAppPaymentData.PaymentMethodType {
|
||||
return withContext(SignalDispatchers.IO) {
|
||||
return withContext(SignalDispatchers.Default) {
|
||||
SignalDatabase.inAppPayments.getById(inAppPaymentId)!!.data.paymentMethodType
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ class ManageDonationsViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
InAppPaymentsRepository.observeInAppPaymentRedemption(InAppPaymentType.RECURRING_DONATION)
|
||||
.asFlow()
|
||||
.collect { redemptionStatus ->
|
||||
@@ -71,7 +71,7 @@ class ManageDonationsViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
InAppPaymentsRepository.observeInAppPaymentRedemption(InAppPaymentType.ONE_TIME_DONATION)
|
||||
.asFlow()
|
||||
.collect { redemptionStatus ->
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class ConversationSettingsNavHostFragment : NavHostFragment(), FragmentBackPress
|
||||
|
||||
companion object {
|
||||
suspend fun createArgs(recipientId: RecipientId): Bundle {
|
||||
val recipient = withContext(Dispatchers.IO) { Recipient.resolved(recipientId) }
|
||||
val recipient = withContext(Dispatchers.Default) { Recipient.resolved(recipientId) }
|
||||
|
||||
val args = if (recipient.isGroup) {
|
||||
ConversationSettingsFragmentArgs.Builder(null, recipient.requireGroupId(), null)
|
||||
|
||||
+3
-3
@@ -157,7 +157,7 @@ sealed class ConversationSettingsViewModel(
|
||||
if (state.threadId > 0) {
|
||||
val newArchived = !state.isArchived
|
||||
store.update { it.copy(isArchived = newArchived) }
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
viewModelScope.launch(SignalDispatchers.Default) {
|
||||
repository.setArchived(state.threadId, newArchived)
|
||||
}
|
||||
}
|
||||
@@ -548,7 +548,7 @@ sealed class ConversationSettingsViewModel(
|
||||
repository.unblock(groupId)
|
||||
}
|
||||
|
||||
private fun loadMemberLabels(v2GroupId: GroupId.V2, groupMembers: List<GroupMemberEntry.FullMember>) = viewModelScope.launch(SignalDispatchers.IO) {
|
||||
private fun loadMemberLabels(v2GroupId: GroupId.V2, groupMembers: List<GroupMemberEntry.FullMember>) = viewModelScope.launch(SignalDispatchers.Default) {
|
||||
val labelsByRecipientId = MemberLabelRepository.instance
|
||||
.getLabels(v2GroupId, groupMembers.map { it.member })
|
||||
|
||||
@@ -561,7 +561,7 @@ sealed class ConversationSettingsViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadCanSetMemberLabel(groupId: GroupId.V2) = viewModelScope.launch(SignalDispatchers.IO) {
|
||||
private fun loadCanSetMemberLabel(groupId: GroupId.V2) = viewModelScope.launch(SignalDispatchers.Default) {
|
||||
val canSetLabel = MemberLabelRepository.instance.canSetLabel(groupId, Recipient.self())
|
||||
store.update {
|
||||
it.copy(
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ class InternalConversationSettingsFragment : ComposeFragment(), InternalConversa
|
||||
}
|
||||
|
||||
override fun add1000Messages(recipientId: RecipientId) {
|
||||
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
|
||||
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Default) {
|
||||
val recipient = Recipient.live(recipientId).get()
|
||||
val messageCount = 1000
|
||||
val startTime = System.currentTimeMillis() - messageCount
|
||||
|
||||
+4
-4
@@ -71,25 +71,25 @@ class SoundsAndNotificationsSettingsViewModel2(
|
||||
}
|
||||
|
||||
private fun applySetMuteUntil(muteUntil: Long) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
SignalDatabase.recipients.setMuted(recipientId, muteUntil)
|
||||
}
|
||||
}
|
||||
|
||||
private fun applySetMentionSetting(setting: NotificationSetting) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
SignalDatabase.recipients.setMentionSetting(recipientId, setting)
|
||||
}
|
||||
}
|
||||
|
||||
private fun applySetCallNotificationSetting(setting: NotificationSetting) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
SignalDatabase.recipients.setCallNotificationSetting(recipientId, setting)
|
||||
}
|
||||
}
|
||||
|
||||
private fun applySetReplyNotificationSetting(setting: NotificationSetting) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
SignalDatabase.recipients.setReplyNotificationSetting(recipientId, setting)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -41,13 +41,13 @@ class CallPeerRepository(
|
||||
private val recipient: Flow<Recipient> = liveRecipient.flatMapLatest { it.observable().asFlow() }
|
||||
private val groupRecipient = recipient.filter { it.isActiveGroup }
|
||||
private val groupRecord: Flow<GroupRecord> = groupRecipient.mapLatest {
|
||||
withContext(Dispatchers.IO) {
|
||||
withContext(Dispatchers.Default) {
|
||||
SignalDatabase.groups.getGroup(it.requireGroupId()).get()
|
||||
}
|
||||
}
|
||||
|
||||
val groupMembers: Flow<List<GroupMemberEntry.FullMember>> = groupRecord.mapLatest { record ->
|
||||
withContext(Dispatchers.IO) {
|
||||
withContext(Dispatchers.Default) {
|
||||
record.members.map { Recipient.resolved(it) }.map { GroupMemberEntry.FullMember(it, record.isAdmin(it)) }
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -157,7 +157,7 @@ class ContactSearchViewModel(
|
||||
suspend fun setConfiguration(contactSearchConfiguration: ContactSearchConfiguration) {
|
||||
internalSearchInProgress.value = true
|
||||
try {
|
||||
val (pagedDataSource, size) = withContext(Dispatchers.IO) {
|
||||
val (pagedDataSource, size) = withContext(Dispatchers.Default) {
|
||||
val source = ContactSearchPagedDataSource(
|
||||
contactSearchConfiguration,
|
||||
arbitraryRepository = arbitraryRepository,
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ class PinnedMessagesViewModel(
|
||||
}
|
||||
|
||||
fun unpinMessage() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
repository.getPinnedMessageRecords(threadId).map {
|
||||
val unpinJob = UnpinMessageJob.create(messageId = it.id)
|
||||
if (unpinJob != null) {
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ class PollVotesViewModel(pollId: Long) : ViewModel() {
|
||||
}
|
||||
|
||||
private fun loadPollInfo(pollId: Long) {
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
viewModelScope.launch(SignalDispatchers.Default) {
|
||||
val poll = SignalDatabase.polls.getPollFromId(pollId)!!
|
||||
val mostVotes = poll.pollOptions.maxByOrNull { option -> option.voters.size }?.voters?.size
|
||||
_state.update {
|
||||
|
||||
+1
-1
@@ -1247,7 +1247,7 @@ class ConversationFragment :
|
||||
|
||||
viewLifecycleOwner.lifecycle.addObserver(LastScrolledPositionUpdater(adapter, layoutManager, viewModel))
|
||||
|
||||
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
|
||||
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Default) {
|
||||
var wasTerminated: Boolean? = null
|
||||
viewModel
|
||||
.groupRecordFlow
|
||||
|
||||
+7
-7
@@ -349,7 +349,7 @@ class ConversationViewModel(
|
||||
}
|
||||
|
||||
fun onAvatarDownloadFailed() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val recipient = recipientSnapshot
|
||||
if (recipient != null) {
|
||||
recipients.manuallyUpdateShowAvatar(recipient.id, false)
|
||||
@@ -359,7 +359,7 @@ class ConversationViewModel(
|
||||
}
|
||||
|
||||
private fun getPinnedMessages() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val threadRecipient = SignalDatabase.threads.getRecipientForThreadId(threadId)
|
||||
internalPinnedMessages.value = repository.getPinnedMessages(threadId).map {
|
||||
ConversationMessage.ConversationMessageFactory.createWithUnresolvedData(AppDependencies.application, it, threadRecipient!!)
|
||||
@@ -436,18 +436,18 @@ class ConversationViewModel(
|
||||
),
|
||||
transform = { it.toList() }
|
||||
)
|
||||
.flowOn(Dispatchers.IO)
|
||||
.flowOn(Dispatchers.Default)
|
||||
}
|
||||
|
||||
fun onCollapseEvents(messageId: Long) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
repository.collapseEvents(messageId)
|
||||
pagingController.onDataInvalidated()
|
||||
}
|
||||
}
|
||||
|
||||
fun onExpandEvents(messageId: Long) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
repository.expandEvents(messageId)
|
||||
pagingController.onDataInvalidated()
|
||||
}
|
||||
@@ -743,7 +743,7 @@ class ConversationViewModel(
|
||||
}
|
||||
|
||||
fun toggleVote(poll: PollRecord, pollOption: PollOption, isChecked: Boolean) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val voteCount = if (isChecked) {
|
||||
SignalDatabase.polls.insertVote(poll, pollOption)
|
||||
} else {
|
||||
@@ -825,7 +825,7 @@ class ConversationViewModel(
|
||||
}
|
||||
|
||||
fun collapseAllEvents() {
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
viewModelScope.launch(SignalDispatchers.Default) {
|
||||
repository.collapseAllEvents()
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -215,7 +215,7 @@ sealed class ConversationListViewModel(
|
||||
}
|
||||
|
||||
private fun loadCurrentFolders() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val folders = ChatFoldersRepository.getCurrentFolders()
|
||||
|
||||
val unreadCountAndEmptyAndMutedStatus: Map<Long, Triple<Int, Boolean, Boolean>> = if (folders.size > 1) {
|
||||
@@ -263,7 +263,7 @@ sealed class ConversationListViewModel(
|
||||
}
|
||||
|
||||
fun onUpdateMute(chatFolder: ChatFolderRecord, until: Long) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val ids = SignalDatabase.threads.getRecipientIdsByChatFolder(chatFolder)
|
||||
val recipientIds: List<RecipientId> = ids.filter { id ->
|
||||
Recipient.resolved(id).muteUntil != until
|
||||
@@ -284,14 +284,14 @@ sealed class ConversationListViewModel(
|
||||
}
|
||||
|
||||
fun removeChatFromFolder(threadId: Long) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
SignalDatabase.chatFolders.removeFromFolder(currentFolder.id, threadId)
|
||||
scheduleChatFolderSync(currentFolder.id)
|
||||
}
|
||||
}
|
||||
|
||||
fun addToFolder(folderId: Long, threadIds: List<Long>) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val includedChats = folders.find { it.chatFolder.id == folderId }?.chatFolder?.includedChats
|
||||
val threadIdsNotIncluded = threadIds.filterNot { threadId ->
|
||||
includedChats?.contains(threadId) ?: false
|
||||
|
||||
@@ -33,7 +33,7 @@ object GroupsInCommonRepository {
|
||||
getGroupsInCommonCount(recipientId)
|
||||
}
|
||||
|
||||
suspend fun getGroupsInCommonCount(recipientId: RecipientId): Int = withContext(Dispatchers.IO) {
|
||||
suspend fun getGroupsInCommonCount(recipientId: RecipientId): Int = withContext(Dispatchers.Default) {
|
||||
SignalDatabase.groups
|
||||
.getPushGroupsContainingMember(recipientId)
|
||||
.count { it.members.contains(Recipient.self().id) }
|
||||
@@ -56,7 +56,7 @@ object GroupsInCommonRepository {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun getGroupsContainingRecipient(context: Context, recipientId: RecipientId): List<Recipient> = withContext(Dispatchers.IO) {
|
||||
private suspend fun getGroupsContainingRecipient(context: Context, recipientId: RecipientId): List<Recipient> = withContext(Dispatchers.Default) {
|
||||
SignalDatabase.groups
|
||||
.getPushGroupsContainingMember(recipientId)
|
||||
.asSequence()
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class MemberLabelEducationViewModel(
|
||||
val uiState: StateFlow<UiState> = _uiState.asStateFlow()
|
||||
|
||||
init {
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
viewModelScope.launch(SignalDispatchers.Default) {
|
||||
val self = Recipient.self()
|
||||
val selfMemberLabel = repository.getLabel(groupId, self.id)
|
||||
val selfCanSetLabel = repository.canSetLabel(groupId, self)
|
||||
|
||||
+6
-6
@@ -40,7 +40,7 @@ class MemberLabelRepository private constructor(
|
||||
val instance: MemberLabelRepository by lazy { MemberLabelRepository() }
|
||||
}
|
||||
|
||||
suspend fun getRecipient(recipientId: RecipientId): Recipient = withContext(Dispatchers.IO) {
|
||||
suspend fun getRecipient(recipientId: RecipientId): Recipient = withContext(Dispatchers.Default) {
|
||||
Recipient.resolved(recipientId)
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class MemberLabelRepository private constructor(
|
||||
/**
|
||||
* Gets the member label for a specific recipient in the group.
|
||||
*/
|
||||
suspend fun getLabel(groupId: GroupId.V2, recipient: Recipient): MemberLabel? = withContext(Dispatchers.IO) {
|
||||
suspend fun getLabel(groupId: GroupId.V2, recipient: Recipient): MemberLabel? = withContext(Dispatchers.Default) {
|
||||
getLabelSync(groupId, recipient)
|
||||
}
|
||||
|
||||
@@ -92,14 +92,14 @@ class MemberLabelRepository private constructor(
|
||||
*
|
||||
* Returns a map of [RecipientId] to [MemberLabel] for members that have labels.
|
||||
*/
|
||||
suspend fun getLabels(groupId: GroupId.V2, recipients: List<Recipient>): Map<RecipientId, MemberLabel> = withContext(Dispatchers.IO) {
|
||||
suspend fun getLabels(groupId: GroupId.V2, recipients: List<Recipient>): Map<RecipientId, MemberLabel> = withContext(Dispatchers.Default) {
|
||||
getLabelsSync(groupId, recipients)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether [recipient] has permission to set their member label in the given group.
|
||||
*/
|
||||
suspend fun canSetLabel(groupId: GroupId.V2, recipient: Recipient): Boolean = withContext(Dispatchers.IO) {
|
||||
suspend fun canSetLabel(groupId: GroupId.V2, recipient: Recipient): Boolean = withContext(Dispatchers.Default) {
|
||||
val groupRecord = groupsTable.getGroup(groupId).orNull() ?: return@withContext false
|
||||
|
||||
if (!isSelfAnActiveGroupMember(groupRecord)) return@withContext false
|
||||
@@ -116,7 +116,7 @@ class MemberLabelRepository private constructor(
|
||||
/**
|
||||
* Computes the sender [NameColor] for a recipient as seen by other group members.
|
||||
*/
|
||||
suspend fun getSenderNameColor(groupId: GroupId.V2, recipient: Recipient): NameColor = withContext(Dispatchers.IO) {
|
||||
suspend fun getSenderNameColor(groupId: GroupId.V2, recipient: Recipient): NameColor = withContext(Dispatchers.Default) {
|
||||
val groupMemberIds = groupsTable
|
||||
.getGroupMembers(groupId, GroupTable.MemberSet.FULL_MEMBERS_INCLUDING_SELF)
|
||||
.mapNotNull { it.serviceId.orNull() }
|
||||
@@ -127,7 +127,7 @@ class MemberLabelRepository private constructor(
|
||||
/**
|
||||
* Returns all group members who have labels set for the given group.
|
||||
*/
|
||||
suspend fun getMembersWithLabels(groupId: GroupId.V2): List<GroupMemberWithLabel> = withContext(Dispatchers.IO) {
|
||||
suspend fun getMembersWithLabels(groupId: GroupId.V2): List<GroupMemberWithLabel> = withContext(Dispatchers.Default) {
|
||||
val groupRecord = groupsTable.getGroup(groupId).orNull() ?: return@withContext emptyList()
|
||||
if (!isSelfAnActiveGroupMember(groupRecord)) return@withContext emptyList()
|
||||
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class MemberLabelViewModel(
|
||||
}
|
||||
|
||||
private fun loadInitialState() {
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
viewModelScope.launch(SignalDispatchers.Default) {
|
||||
val recipient = memberLabelRepo.getRecipient(recipientId)
|
||||
val memberLabel = memberLabelRepo.getLabel(groupId, recipient)
|
||||
originalLabelEmoji = memberLabel?.emoji.orEmpty()
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ class AddMembersViewModel(
|
||||
|
||||
suspend fun shouldAllowSelection(selection: RecipientSelection): Boolean {
|
||||
val recipientHasE164 = selection is RecipientSelection.HasId &&
|
||||
withContext(Dispatchers.IO) { Recipient.resolved(selection.id) }.hasE164
|
||||
withContext(Dispatchers.Default) { Recipient.resolved(selection.id) }.hasE164
|
||||
|
||||
return when {
|
||||
groupId.isV1 && !recipientHasE164 -> {
|
||||
@@ -101,7 +101,7 @@ class AddMembersViewModel(
|
||||
val confirmAddMessage = if (uiState.value.newSelections.size == 1) {
|
||||
UserMessage.ConfirmAddMember(
|
||||
group = group,
|
||||
recipient = withContext(Dispatchers.IO) {
|
||||
recipient = withContext(Dispatchers.Default) {
|
||||
Recipient.resolved(uiState.value.newSelections.single().orCreateRecipientId)
|
||||
}
|
||||
)
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ class AddToGroupsViewModel(
|
||||
|
||||
private fun confirmAddToGroup(groupRecipientId: RecipientId) {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
withContext(Dispatchers.Default) {
|
||||
if (!existingGroupMemberships.contains(groupRecipientId)) {
|
||||
internalUiState.update {
|
||||
it.copy(
|
||||
|
||||
@@ -77,7 +77,7 @@ object AttachmentBackfill {
|
||||
|
||||
/** The scope the response timeouts run on. Overridable so tests can drive the timeout with virtual time. */
|
||||
@VisibleForTesting
|
||||
internal var timeoutScope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
internal var timeoutScope: CoroutineScope = CoroutineScope(Dispatchers.Default + SupervisorJob())
|
||||
|
||||
/**
|
||||
* Considers a backfill request for [messageId] after a permanent download failure. The attachment is flagged
|
||||
|
||||
@@ -34,7 +34,7 @@ class MainToolbarViewModel : ViewModel() {
|
||||
|
||||
fun refresh() {
|
||||
viewModelScope.launch {
|
||||
val self = withContext(SignalDispatchers.IO) {
|
||||
val self = withContext(SignalDispatchers.Default) {
|
||||
Recipient.self().resolve()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ class AddMessageViewModel(initialMessage: CharSequence?) : ViewModel() {
|
||||
iterator.setText(it)
|
||||
AddMessageCharacterCount(iterator.countBreaks())
|
||||
}
|
||||
.flowOn(Dispatchers.IO)
|
||||
.flowOn(Dispatchers.Default)
|
||||
}
|
||||
|
||||
fun updateAddAMessageCount(input: CharSequence?) {
|
||||
|
||||
@@ -150,7 +150,7 @@ object MediaSendV3Repository : MediaSendRepository {
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun checkUntrustedIdentities(contactIds: Set<Long>, since: Long): List<Long> = withContext(Dispatchers.IO) {
|
||||
override suspend fun checkUntrustedIdentities(contactIds: Set<Long>, since: Long): List<Long> = withContext(Dispatchers.Default) {
|
||||
if (contactIds.isEmpty()) return@withContext emptyList<Long>()
|
||||
|
||||
val recipients: List<Recipient> = contactIds
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ class InternalMessageDetailsViewModel(val messageId: Long) : ViewModel() {
|
||||
val state: State<ViewState?> = _state
|
||||
|
||||
init {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
val messageRecord = SignalDatabase.messages.getMessageRecord(messageId)
|
||||
val attachments = SignalDatabase.attachments.getAttachmentsForMessage(messageId)
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class NicknameViewModel(
|
||||
viewModelScope.launch {
|
||||
internalState.value = state.value.copy(formState = NicknameState.FormState.SAVING)
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
withContext(Dispatchers.Default) {
|
||||
SignalDatabase.recipients.setNicknameAndNote(
|
||||
recipientId,
|
||||
ProfileName.EMPTY,
|
||||
@@ -115,7 +115,7 @@ class NicknameViewModel(
|
||||
val stateSnapshot = state.value.copy(formState = NicknameState.FormState.SAVING)
|
||||
internalState.value = stateSnapshot
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
withContext(Dispatchers.Default) {
|
||||
SignalDatabase.recipients.setNicknameAndNote(
|
||||
recipientId,
|
||||
ProfileName.fromParts(stateSnapshot.firstName, stateSnapshot.lastName),
|
||||
|
||||
@@ -38,7 +38,7 @@ private fun <T> rememberRecipientField(recipientId: RecipientId, initialData: Re
|
||||
var recipientAndCounter by remember(recipientId) { mutableStateOf(initialData to 0L) }
|
||||
|
||||
LaunchedEffect(recipientId) {
|
||||
withContext(SignalDispatchers.IO) {
|
||||
withContext(SignalDispatchers.Default) {
|
||||
Recipient.observable(recipientId)
|
||||
.asFlow()
|
||||
.collect {
|
||||
|
||||
@@ -312,7 +312,7 @@ private suspend fun showItemContextMenu(
|
||||
callbacks: RecipientPickerCallbacks.ContextMenu
|
||||
) {
|
||||
val context = anchorView.context
|
||||
val recipient = withContext(Dispatchers.IO) {
|
||||
val recipient = withContext(Dispatchers.Default) {
|
||||
Recipient.resolved(contactSearchKey.requireRecipientSearchKey().recipientId)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ object RegistrationRepository {
|
||||
* Queries, and creates if needed, the local profile key.
|
||||
*/
|
||||
@JvmStatic
|
||||
suspend fun getProfileKey(e164: String): ProfileKey = withContext(Dispatchers.IO) {
|
||||
suspend fun getProfileKey(e164: String): ProfileKey = withContext(Dispatchers.Default) {
|
||||
// TODO [regv2]: make creation more explicit instead of hiding it in this getter
|
||||
val recipientTable = SignalDatabase.recipients
|
||||
val recipient = recipientTable.getByE164(e164)
|
||||
|
||||
+2
-2
@@ -82,7 +82,7 @@ class AppRegistrationStorageController(private val context: Context) : StorageCo
|
||||
private val LEGACY_BACKUP_PATTERN = Regex("^signal-(\\d{4})-(\\d{2})-(\\d{2})-(\\d{2})-(\\d{2})-(\\d{2})\\.backup$")
|
||||
}
|
||||
|
||||
override suspend fun getPreExistingRegistrationData(): PreExistingRegistrationData? = withContext(Dispatchers.IO) {
|
||||
override suspend fun getPreExistingRegistrationData(): PreExistingRegistrationData? = withContext(Dispatchers.Default) {
|
||||
if (!SignalStore.account.isRegistered) {
|
||||
return@withContext null
|
||||
}
|
||||
@@ -277,7 +277,7 @@ class AppRegistrationStorageController(private val context: Context) : StorageCo
|
||||
RegistrationUtil.maybeMarkRegistrationComplete()
|
||||
}
|
||||
|
||||
override suspend fun setRestoreDecision(decision: RestoreDecision) = withContext(Dispatchers.IO) {
|
||||
override suspend fun setRestoreDecision(decision: RestoreDecision) = withContext(Dispatchers.Default) {
|
||||
if (!SignalStore.registration.restoreDecisionState.isDecisionPending) {
|
||||
return@withContext
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ class AttachmentProgressService : SafeForegroundService() {
|
||||
}
|
||||
|
||||
class Controller(private val context: Context, title: String) : AutoCloseable {
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.Default)
|
||||
private val progressFlow = MutableSharedFlow<Float>(replay = 0, extraBufferCapacity = 1)
|
||||
|
||||
init {
|
||||
|
||||
@@ -129,7 +129,7 @@ class StarredMessagesActivity : PassphraseRequiredActivity() {
|
||||
|
||||
private fun navigateToMessage(messageRecord: MessageRecord) {
|
||||
lifecycleScope.launch {
|
||||
val (threadRecipient, startingPosition) = withContext(Dispatchers.IO) {
|
||||
val (threadRecipient, startingPosition) = withContext(Dispatchers.Default) {
|
||||
val position = SignalDatabase.messages.getMessagePositionInConversation(messageRecord.threadId, messageRecord.dateReceived)
|
||||
val recipient = SignalDatabase.threads.getRecipientForThreadId(messageRecord.threadId)
|
||||
Pair(recipient, maxOf(0, position))
|
||||
|
||||
@@ -45,11 +45,11 @@ class StarredMessagesViewModel(
|
||||
}
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
.flowOn(Dispatchers.IO)
|
||||
.flowOn(Dispatchers.Default)
|
||||
}
|
||||
|
||||
suspend fun unstarMessage(messageId: Long) {
|
||||
withContext(Dispatchers.IO) {
|
||||
withContext(Dispatchers.Default) {
|
||||
SignalDatabase.messages.setStarred(messageId, false)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -37,7 +37,7 @@ object StickerManagementRepository {
|
||||
private val databaseObserver: DatabaseObserver = AppDependencies.databaseObserver
|
||||
private val stickersDbTable: StickerTable = SignalDatabase.stickers
|
||||
private val attachmentsDbTable: AttachmentTable = SignalDatabase.attachments
|
||||
private val coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
private val coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||
|
||||
/**
|
||||
* Emits the sticker packs along with any updates.
|
||||
@@ -58,7 +58,7 @@ object StickerManagementRepository {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun loadStickerPacks(): StickerPacksResult = withContext(Dispatchers.IO) {
|
||||
private suspend fun loadStickerPacks(): StickerPacksResult = withContext(Dispatchers.Default) {
|
||||
StickerPackRecordReader(stickersDbTable.getAllStickerPacks()).use { reader ->
|
||||
val installedPacks = mutableListOf<StickerPackRecord>()
|
||||
val availablePacks = mutableListOf<StickerPackRecord>()
|
||||
@@ -83,7 +83,7 @@ object StickerManagementRepository {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deleteOrphanedStickerPacks() = withContext(Dispatchers.IO) {
|
||||
suspend fun deleteOrphanedStickerPacks() = withContext(Dispatchers.Default) {
|
||||
stickersDbTable.deleteOrphanedPacks()
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ object StickerManagementRepository {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun installStickerPack(packId: StickerPackId, packKey: StickerPackKey, notify: Boolean) = withContext(Dispatchers.IO) {
|
||||
suspend fun installStickerPack(packId: StickerPackId, packKey: StickerPackKey, notify: Boolean) = withContext(Dispatchers.Default) {
|
||||
if (stickersDbTable.isPackAvailableAsReference(packId.value)) {
|
||||
stickersDbTable.markPackAsInstalled(packId.value, notify)
|
||||
}
|
||||
@@ -123,7 +123,7 @@ object StickerManagementRepository {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun uninstallStickerPacks(packKeysById: Map<StickerPackId, StickerPackKey>) = withContext(Dispatchers.IO) {
|
||||
suspend fun uninstallStickerPacks(packKeysById: Map<StickerPackId, StickerPackKey>) = withContext(Dispatchers.Default) {
|
||||
stickersDbTable.uninstallPacks(packIds = packKeysById.keys)
|
||||
|
||||
if (SignalStore.account.isMultiDevice) {
|
||||
@@ -133,7 +133,7 @@ object StickerManagementRepository {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun setStickerPacksOrder(packsInOrder: List<StickerPackRecord>) = withContext(Dispatchers.IO) {
|
||||
suspend fun setStickerPacksOrder(packsInOrder: List<StickerPackRecord>) = withContext(Dispatchers.Default) {
|
||||
stickersDbTable.updatePackOrder(packsInOrder)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ class StoryArchiveViewModel : ViewModel() {
|
||||
|
||||
pagedDataJob?.cancel()
|
||||
pagedDataJob = viewModelScope.launch {
|
||||
val size = withContext(Dispatchers.IO) { dataSource.size() }
|
||||
val size = withContext(Dispatchers.Default) { dataSource.size() }
|
||||
if (size == 0) {
|
||||
_state.value = _state.value.copy(stories = emptyList(), isLoading = false)
|
||||
return@launch
|
||||
|
||||
Reference in New Issue
Block a user