mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-14 23:18:43 +00:00
Ensure that notification heuristics are calculated in the background.
This commit is contained in:
@@ -5,9 +5,12 @@ import android.net.Uri
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||||
import org.thoughtcrime.securesms.notifications.DeviceSpecificNotificationConfig
|
import org.thoughtcrime.securesms.notifications.DeviceSpecificNotificationConfig
|
||||||
@@ -28,7 +31,11 @@ class NotificationsSettingsViewModel(private val sharedPreferences: SharedPrefer
|
|||||||
SignalStore.settings.isMessageVibrateEnabled = NotificationChannels.getInstance().messageVibrate
|
SignalStore.settings.isMessageVibrateEnabled = NotificationChannels.getInstance().messageVibrate
|
||||||
}
|
}
|
||||||
|
|
||||||
store.update { getState(calculateSlowNotifications = true) }
|
// 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) {
|
||||||
|
store.update { getState(calculateSlowNotifications = true) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refresh() {
|
fun refresh() {
|
||||||
|
|||||||
Reference in New Issue
Block a user