Hide the advance setting section if there is no error and their is only one available push distributor.
This commit is contained in:
parent
eacc591824
commit
f5b495d9ff
3 changed files with 56 additions and 43 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"))),
|
||||
|
|
|
|||
|
|
@ -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?) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue