Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
Expand Down Expand Up @@ -141,7 +140,8 @@ fun NotificationsPreference(
title = annotatedStringResource(R.string.useFastMode),
subtitle = annotatedStringResource(fastModeDescription),
subtitleStyle = LocalType.current.large,
checked = uiState.isPushEnabled,
checked = uiState.fastModeSelected,
enabled = uiState.fastModeEnabled,
qaTag = R.string.qa_preferences_enable_push,
switchQaTag = R.string.qa_preferences_enable_push_toggle,
onCheckedChange = {isEnabled -> sendCommand(TogglePushEnabled(isEnabled)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.notifications.NotificationPreferences.PRIVACY
import org.thoughtcrime.securesms.notifications.NotificationPreferences.PUSH_ENABLED
import org.thoughtcrime.securesms.notifications.NotificationPreferences.SOUND_WHEN_APP_OPEN
import org.thoughtcrime.securesms.notifications.NotificationPrivacy
import org.thoughtcrime.securesms.onboarding.messagenotifications.isFastModeAvailable
import org.thoughtcrime.securesms.preferences.PreferenceStorage
import org.thoughtcrime.securesms.ui.isWhitelistedFromDoze
import javax.inject.Inject
Expand All @@ -32,7 +33,9 @@ class NotificationsPreferenceViewModel @Inject constructor(
private val channels: NotificationChannelManager,
) : ViewModel() {

private val _uiState = MutableStateFlow(UIState())
private val _uiState = MutableStateFlow(UIState(
fastModeEnabled = application.isFastModeAvailable()
))
val uiState: StateFlow<UIState> get() = _uiState

private val _uiEvents = MutableSharedFlow<NotificationPreferenceEvent>()
Expand Down Expand Up @@ -63,7 +66,7 @@ class NotificationsPreferenceViewModel @Inject constructor(
_uiState.update { old ->
old.copy(
// strategy
isPushEnabled = isPushEnabled,
fastModeSelected = isPushEnabled,
checkedDozeWhitelist = notif.checkedDozeWhitelist,

// keep the current doze whitelist status; you refresh it separately
Expand Down Expand Up @@ -204,7 +207,8 @@ class NotificationsPreferenceViewModel @Inject constructor(

data class UIState(
// Strategy
val isPushEnabled: Boolean = false,
val fastModeSelected: Boolean = false,
val fastModeEnabled: Boolean = false,
val isWhitelistedFromDoze: Boolean = false, // run in background
val checkedDozeWhitelist: Boolean = false, // whitelist dialog's first time
// style/behavior
Expand Down
Loading