mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 10:32:34 +00:00
Hide the advance setting section if there is no error and their is only one available push distributor.
This commit is contained in:
committed by
Benoit Marty
parent
300ca40af4
commit
05b3337e6f
+6
@@ -50,4 +50,10 @@ data class NotificationSettingsState(
|
||||
val systemNotificationsEnabled: Boolean,
|
||||
val appNotificationsEnabled: Boolean,
|
||||
)
|
||||
|
||||
/**
|
||||
* Whether the advanced settings should be shown.
|
||||
* This is true if the current push distributor is in a failure state or if there are multiple push distributors available.
|
||||
*/
|
||||
val showAdvancedSettings: Boolean = currentPushDistributor.isFailure() || availablePushDistributors.size > 1
|
||||
}
|
||||
|
||||
+6
-1
@@ -25,10 +25,15 @@ import kotlinx.collections.immutable.toImmutableList
|
||||
open class NotificationSettingsStateProvider : PreviewParameterProvider<NotificationSettingsState> {
|
||||
override val values: Sequence<NotificationSettingsState>
|
||||
get() = sequenceOf(
|
||||
aValidNotificationSettingsState(),
|
||||
aValidNotificationSettingsState(systemNotificationsEnabled = false),
|
||||
aValidNotificationSettingsState(),
|
||||
aValidNotificationSettingsState(changeNotificationSettingAction = AsyncAction.Loading),
|
||||
aValidNotificationSettingsState(changeNotificationSettingAction = AsyncAction.Failure(Throwable("error"))),
|
||||
aValidNotificationSettingsState(
|
||||
availablePushDistributors = listOf("Firebase"),
|
||||
changeNotificationSettingAction = AsyncAction.Failure(Throwable("error")),
|
||||
),
|
||||
aValidNotificationSettingsState(availablePushDistributors = listOf("Firebase")),
|
||||
aValidNotificationSettingsState(showChangePushProviderDialog = true),
|
||||
aValidNotificationSettingsState(currentPushDistributor = AsyncAction.Loading),
|
||||
aValidNotificationSettingsState(currentPushDistributor = AsyncAction.Failure(Exception("Failed to change distributor"))),
|
||||
|
||||
+2
@@ -181,6 +181,7 @@ private fun NotificationSettingsContentView(
|
||||
onClick = onTroubleshootNotificationsClicked
|
||||
)
|
||||
}
|
||||
if (state.showAdvancedSettings) {
|
||||
PreferenceCategory(title = stringResource(id = CommonStrings.common_advanced_settings)) {
|
||||
ListItem(
|
||||
headlineContent = {
|
||||
@@ -228,6 +229,7 @@ private fun NotificationSettingsContentView(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun getTitleForRoomNotificationMode(mode: RoomNotificationMode?) =
|
||||
|
||||
Reference in New Issue
Block a user