fun setPreferences()

in apps/chat-android/app/src/main/java/com/amazonaws/services/chime/sdkdemo/ui/messaging/presentation/NotificationSettingsViewModel.kt [78:107]


    fun setPreferences(type: String, channelArn: String?) {
        _viewState.value = Loading()
        if (channelArn != null) {
            if ("FULL" == type) {
                val prefs = ChannelMembershipPreferences()
                    .withPushNotifications(
                        PushNotificationPreferences()
                            .withAllowNotifications("ALL")
                    )
                invokeAPI(channelArn, prefs)
            } else if ("MUTE" == type) {
                val prefs = ChannelMembershipPreferences()
                    .withPushNotifications(
                        PushNotificationPreferences()
                            .withAllowNotifications("NONE")
                    )
                invokeAPI(channelArn, prefs)
            } else if ("MENTIONS" == type) {
                val prefs = ChannelMembershipPreferences()
                    .withPushNotifications(
                        PushNotificationPreferences()
                            .withAllowNotifications("FILTERED")
                            .withFilterRule("{\"mention\":[\"@${currentUser.chimeDisplayName}\"]}")
                    )
                invokeAPI(channelArn, prefs)
            }
        } else {
            _viewState.value = Error(RuntimeException("Channel has not been selected yet."))
        }
    }