@@ -28,6 +28,7 @@ import org.session.libsession.utilities.TextSecurePreferences.Companion.LINK_PRE
2828import org.session.libsession.utilities.observeBooleanKey
2929import org.session.libsession.utilities.withMutableUserConfigs
3030import org.thoughtcrime.securesms.dependencies.ConfigFactory
31+ import org.thoughtcrime.securesms.notifications.NotificationPreferences.PUSH_ENABLED
3132import org.thoughtcrime.securesms.preferences.CommunicationPreferences
3233import org.thoughtcrime.securesms.preferences.PreferenceStorage
3334import org.thoughtcrime.securesms.preferences.compose.PrivacySettingsPreferenceViewModel.Commands.ShowCallsWarningDialog
@@ -41,7 +42,7 @@ class PrivacySettingsPreferenceViewModel @Inject constructor(
4142 private val configFactory : ConfigFactory ,
4243 private val app : Application ,
4344 private val typingStatusRepository : TypingStatusRepository ,
44- private val notificationManager : NotificationManagerCompat ,
45+ private val notificationManager : NotificationManagerCompat
4546) : ViewModel() {
4647
4748 private val keyguardSecure = MutableStateFlow (true )
@@ -129,11 +130,6 @@ class PrivacySettingsPreferenceViewModel @Inject constructor(
129130 typingIndicators = prefState.typingIndicators,
130131 linkPreviewEnabled = prefState.linkPreviewEnabled,
131132 incognitoKeyboardEnabled = prefState.incognitoKeyboardEnabled,
132-
133- // keep these as-is (not derived from prefs flow)
134- allowCommunityMessageRequests = current.allowCommunityMessageRequests,
135- showCallsWarningDialog = current.showCallsWarningDialog,
136- showCallsNotificationDialog = current.showCallsNotificationDialog,
137133 )
138134 }
139135 }
@@ -190,6 +186,8 @@ class PrivacySettingsPreferenceViewModel @Inject constructor(
190186 _scrollAction .value = ScrollAction ()
191187 }
192188
189+ fun fastModeEnabled () = prefStorage[PUSH_ENABLED ]
190+
193191 fun onCommand (command : Commands ) {
194192 when (command) {
195193 is Commands .ToggleCallsNotification -> {
@@ -241,9 +239,15 @@ class PrivacySettingsPreferenceViewModel @Inject constructor(
241239 }
242240 }
243241
244- Commands .NavigateToAppNotificationsSettings -> {
242+ Commands .NavigateToSystemNotificationsSettings -> {
245243 viewModelScope.launch {
246- _uiEvents .emit(PrivacySettingsPreferenceEvent .OpenAppNotificationSettings )
244+ _uiEvents .emit(PrivacySettingsPreferenceEvent .OpenSystemNotificationSettings )
245+ }
246+ }
247+
248+ Commands .NavigateToNotificationsSettings -> {
249+ viewModelScope.launch {
250+ _uiEvents .emit(PrivacySettingsPreferenceEvent .OpenNotificationsSettings )
247251 }
248252 }
249253
@@ -255,10 +259,37 @@ class PrivacySettingsPreferenceViewModel @Inject constructor(
255259 }
256260 }
257261
262+ Commands .HideSlowModeCallsWarningDialog -> {
263+ _uiState .update {
264+ it.copy(
265+ showSlowModeCallsWarningDialog = false
266+ )
267+ }
268+ }
269+
258270 ShowCallsWarningDialog -> {
271+ // There are two warnings
272+ // 1. The first one is shown only once, in case the user is using slow mode
273+ // which doesn't work well with calls
274+ if (! prefs.hasSeenSlowModeCallWarning() && ! fastModeEnabled()) {
275+ _uiState .update {
276+ it.copy(
277+ showSlowModeCallsWarningDialog = true ,
278+ showCallsWarningDialog = false
279+ )
280+ }
281+
282+ // mark warning as seen
283+ prefs.setHasSeenSlowModeCallWarning(true )
284+
285+ return
286+ }
287+
288+ // 2. The second is the "always shown" warning regarding calls
259289 _uiState .update {
260290 it.copy(
261- showCallsWarningDialog = true
291+ showCallsWarningDialog = true ,
292+ showSlowModeCallsWarningDialog = false
262293 )
263294 }
264295 }
@@ -291,9 +322,11 @@ class PrivacySettingsPreferenceViewModel @Inject constructor(
291322 data class ToggleIncognitoKeyboard (val isEnabled : Boolean ) : Commands
292323
293324 data object AskMicPermission : Commands
294- data object NavigateToAppNotificationsSettings : Commands
325+ data object NavigateToSystemNotificationsSettings : Commands
326+ data object NavigateToNotificationsSettings : Commands
295327
296328 // Dialog for Calls warning
329+ data object HideSlowModeCallsWarningDialog : Commands
297330 data object HideCallsWarningDialog : Commands
298331 data object ShowCallsWarningDialog : Commands
299332
@@ -304,8 +337,9 @@ class PrivacySettingsPreferenceViewModel @Inject constructor(
304337
305338 sealed interface PrivacySettingsPreferenceEvent {
306339 data object StartLockToggledService : PrivacySettingsPreferenceEvent
307- data object OpenAppNotificationSettings : PrivacySettingsPreferenceEvent
340+ data object OpenSystemNotificationSettings : PrivacySettingsPreferenceEvent
308341 data object AskMicrophonePermission : PrivacySettingsPreferenceEvent
342+ data object OpenNotificationsSettings : PrivacySettingsPreferenceEvent
309343
310344 data class ScrollToIndex (val index : Int ) : PrivacySettingsPreferenceEvent
311345 }
@@ -324,6 +358,7 @@ class PrivacySettingsPreferenceViewModel @Inject constructor(
324358 val allowCommunityMessageRequests : Boolean = false , // Get from userConfigs
325359
326360 val showCallsWarningDialog : Boolean = false ,
361+ val showSlowModeCallsWarningDialog : Boolean = false ,
327362 val showCallsNotificationDialog : Boolean = false
328363 )
329364
0 commit comments