Rename notification settings objects
This commit is contained in:
parent
40119733b9
commit
1c47983a99
|
@ -107,8 +107,8 @@ import im.vector.app.features.settings.ignored.IgnoredUsersViewModel
|
||||||
import im.vector.app.features.settings.labs.VectorSettingsLabsViewModel
|
import im.vector.app.features.settings.labs.VectorSettingsLabsViewModel
|
||||||
import im.vector.app.features.settings.legals.LegalsViewModel
|
import im.vector.app.features.settings.legals.LegalsViewModel
|
||||||
import im.vector.app.features.settings.locale.LocalePickerViewModel
|
import im.vector.app.features.settings.locale.LocalePickerViewModel
|
||||||
import im.vector.app.features.settings.notifications.VectorSettingsNotificationPreferenceViewModel
|
import im.vector.app.features.settings.notifications.VectorSettingsNotificationViewModel
|
||||||
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationPreferenceViewModel
|
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationViewModel
|
||||||
import im.vector.app.features.settings.push.PushGatewaysViewModel
|
import im.vector.app.features.settings.push.PushGatewaysViewModel
|
||||||
import im.vector.app.features.settings.threepids.ThreePidsSettingsViewModel
|
import im.vector.app.features.settings.threepids.ThreePidsSettingsViewModel
|
||||||
import im.vector.app.features.share.IncomingShareViewModel
|
import im.vector.app.features.share.IncomingShareViewModel
|
||||||
|
@ -690,16 +690,16 @@ interface MavericksViewModelModule {
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoMap
|
@IntoMap
|
||||||
@MavericksViewModelKey(VectorSettingsNotificationPreferenceViewModel::class)
|
@MavericksViewModelKey(VectorSettingsNotificationViewModel::class)
|
||||||
fun vectorSettingsNotificationPreferenceViewModelFactory(
|
fun vectorSettingsNotificationPreferenceViewModelFactory(
|
||||||
factory: VectorSettingsNotificationPreferenceViewModel.Factory
|
factory: VectorSettingsNotificationViewModel.Factory
|
||||||
): MavericksAssistedViewModelFactory<*, *>
|
): MavericksAssistedViewModelFactory<*, *>
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@IntoMap
|
@IntoMap
|
||||||
@MavericksViewModelKey(VectorSettingsPushRuleNotificationPreferenceViewModel::class)
|
@MavericksViewModelKey(VectorSettingsPushRuleNotificationViewModel::class)
|
||||||
fun vectorSettingsPushRuleNotificationPreferenceViewModelFactory(
|
fun vectorSettingsPushRuleNotificationPreferenceViewModelFactory(
|
||||||
factory: VectorSettingsPushRuleNotificationPreferenceViewModel.Factory
|
factory: VectorSettingsPushRuleNotificationViewModel.Factory
|
||||||
): MavericksAssistedViewModelFactory<*, *>
|
): MavericksAssistedViewModelFactory<*, *>
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
|
|
|
@ -32,7 +32,7 @@ import im.vector.app.databinding.ActivityVectorSettingsBinding
|
||||||
import im.vector.app.features.discovery.DiscoverySettingsFragment
|
import im.vector.app.features.discovery.DiscoverySettingsFragment
|
||||||
import im.vector.app.features.navigation.SettingsActivityPayload
|
import im.vector.app.features.navigation.SettingsActivityPayload
|
||||||
import im.vector.app.features.settings.devices.VectorSettingsDevicesFragment
|
import im.vector.app.features.settings.devices.VectorSettingsDevicesFragment
|
||||||
import im.vector.app.features.settings.notifications.VectorSettingsNotificationPreferenceFragment
|
import im.vector.app.features.settings.notifications.VectorSettingsNotificationFragment
|
||||||
import im.vector.app.features.settings.threepids.ThreePidsSettingsFragment
|
import im.vector.app.features.settings.threepids.ThreePidsSettingsFragment
|
||||||
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
|
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
|
||||||
import org.matrix.android.sdk.api.failure.GlobalError
|
import org.matrix.android.sdk.api.failure.GlobalError
|
||||||
|
@ -92,7 +92,7 @@ class VectorSettingsActivity : VectorBaseActivity<ActivityVectorSettingsBinding>
|
||||||
}
|
}
|
||||||
SettingsActivityPayload.Notifications -> {
|
SettingsActivityPayload.Notifications -> {
|
||||||
requestHighlightPreferenceKeyOnResume(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)
|
requestHighlightPreferenceKeyOnResume(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)
|
||||||
replaceFragment(views.vectorSettingsPage, VectorSettingsNotificationPreferenceFragment::class.java, null, FRAGMENT_TAG)
|
replaceFragment(views.vectorSettingsPage, VectorSettingsNotificationFragment::class.java, null, FRAGMENT_TAG)
|
||||||
}
|
}
|
||||||
is SettingsActivityPayload.DiscoverySettings -> {
|
is SettingsActivityPayload.DiscoverySettings -> {
|
||||||
replaceFragment(views.vectorSettingsPage, DiscoverySettingsFragment::class.java, payload, FRAGMENT_TAG)
|
replaceFragment(views.vectorSettingsPage, DiscoverySettingsFragment::class.java, payload, FRAGMENT_TAG)
|
||||||
|
|
|
@ -71,7 +71,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
// Referenced in vector_settings_preferences_root.xml
|
// Referenced in vector_settings_preferences_root.xml
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class VectorSettingsNotificationPreferenceFragment :
|
class VectorSettingsNotificationFragment :
|
||||||
VectorSettingsBaseFragment(),
|
VectorSettingsBaseFragment(),
|
||||||
BackgroundSyncModeChooserDialog.InteractionListener {
|
BackgroundSyncModeChooserDialog.InteractionListener {
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class VectorSettingsNotificationPreferenceFragment :
|
||||||
|
|
||||||
private var interactionListener: VectorSettingsFragmentInteractionListener? = null
|
private var interactionListener: VectorSettingsFragmentInteractionListener? = null
|
||||||
|
|
||||||
private val viewModel: VectorSettingsNotificationPreferenceViewModel by fragmentViewModel()
|
private val viewModel: VectorSettingsNotificationViewModel by fragmentViewModel()
|
||||||
|
|
||||||
private val notificationStartForActivityResult = registerStartForActivityResult { _ ->
|
private val notificationStartForActivityResult = registerStartForActivityResult { _ ->
|
||||||
// No op
|
// No op
|
||||||
|
@ -116,10 +116,10 @@ class VectorSettingsNotificationPreferenceFragment :
|
||||||
private fun observeViewEvents() {
|
private fun observeViewEvents() {
|
||||||
viewModel.observeViewEvents {
|
viewModel.observeViewEvents {
|
||||||
when (it) {
|
when (it) {
|
||||||
VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceEnabled -> onNotificationsForDeviceEnabled()
|
VectorSettingsNotificationViewEvent.NotificationsForDeviceEnabled -> onNotificationsForDeviceEnabled()
|
||||||
VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceDisabled -> onNotificationsForDeviceDisabled()
|
VectorSettingsNotificationViewEvent.NotificationsForDeviceDisabled -> onNotificationsForDeviceDisabled()
|
||||||
is VectorSettingsNotificationPreferenceViewEvent.AskUserForPushDistributor -> askUserToSelectPushDistributor()
|
is VectorSettingsNotificationViewEvent.AskUserForPushDistributor -> askUserToSelectPushDistributor()
|
||||||
VectorSettingsNotificationPreferenceViewEvent.NotificationMethodChanged -> onNotificationMethodChanged()
|
VectorSettingsNotificationViewEvent.NotificationMethodChanged -> onNotificationMethodChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,9 @@ class VectorSettingsNotificationPreferenceFragment :
|
||||||
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)
|
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY)
|
||||||
?.setOnPreferenceChangeListener { _, isChecked ->
|
?.setOnPreferenceChangeListener { _, isChecked ->
|
||||||
val action = if (isChecked as Boolean) {
|
val action = if (isChecked as Boolean) {
|
||||||
VectorSettingsNotificationPreferenceViewAction.EnableNotificationsForDevice(pushDistributor = "")
|
VectorSettingsNotificationViewAction.EnableNotificationsForDevice(pushDistributor = "")
|
||||||
} else {
|
} else {
|
||||||
VectorSettingsNotificationPreferenceViewAction.DisableNotificationsForDevice
|
VectorSettingsNotificationViewAction.DisableNotificationsForDevice
|
||||||
}
|
}
|
||||||
viewModel.handle(action)
|
viewModel.handle(action)
|
||||||
// preference will be updated on ViewEvent reception
|
// preference will be updated on ViewEvent reception
|
||||||
|
@ -231,9 +231,9 @@ class VectorSettingsNotificationPreferenceFragment :
|
||||||
private fun askUserToSelectPushDistributor(withUnregister: Boolean = false) {
|
private fun askUserToSelectPushDistributor(withUnregister: Boolean = false) {
|
||||||
unifiedPushHelper.showSelectDistributorDialog(requireContext()) { selection ->
|
unifiedPushHelper.showSelectDistributorDialog(requireContext()) { selection ->
|
||||||
if (withUnregister) {
|
if (withUnregister) {
|
||||||
viewModel.handle(VectorSettingsNotificationPreferenceViewAction.RegisterPushDistributor(selection))
|
viewModel.handle(VectorSettingsNotificationViewAction.RegisterPushDistributor(selection))
|
||||||
} else {
|
} else {
|
||||||
viewModel.handle(VectorSettingsNotificationPreferenceViewAction.EnableNotificationsForDevice(selection))
|
viewModel.handle(VectorSettingsNotificationViewAction.EnableNotificationsForDevice(selection))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,8 +18,8 @@ package im.vector.app.features.settings.notifications
|
||||||
|
|
||||||
import im.vector.app.core.platform.VectorViewModelAction
|
import im.vector.app.core.platform.VectorViewModelAction
|
||||||
|
|
||||||
sealed interface VectorSettingsNotificationPreferenceViewAction : VectorViewModelAction {
|
sealed interface VectorSettingsNotificationViewAction : VectorViewModelAction {
|
||||||
data class EnableNotificationsForDevice(val pushDistributor: String) : VectorSettingsNotificationPreferenceViewAction
|
data class EnableNotificationsForDevice(val pushDistributor: String) : VectorSettingsNotificationViewAction
|
||||||
object DisableNotificationsForDevice : VectorSettingsNotificationPreferenceViewAction
|
object DisableNotificationsForDevice : VectorSettingsNotificationViewAction
|
||||||
data class RegisterPushDistributor(val pushDistributor: String) : VectorSettingsNotificationPreferenceViewAction
|
data class RegisterPushDistributor(val pushDistributor: String) : VectorSettingsNotificationViewAction
|
||||||
}
|
}
|
|
@ -18,9 +18,9 @@ package im.vector.app.features.settings.notifications
|
||||||
|
|
||||||
import im.vector.app.core.platform.VectorViewEvents
|
import im.vector.app.core.platform.VectorViewEvents
|
||||||
|
|
||||||
sealed interface VectorSettingsNotificationPreferenceViewEvent : VectorViewEvents {
|
sealed interface VectorSettingsNotificationViewEvent : VectorViewEvents {
|
||||||
object NotificationsForDeviceEnabled : VectorSettingsNotificationPreferenceViewEvent
|
object NotificationsForDeviceEnabled : VectorSettingsNotificationViewEvent
|
||||||
object NotificationsForDeviceDisabled : VectorSettingsNotificationPreferenceViewEvent
|
object NotificationsForDeviceDisabled : VectorSettingsNotificationViewEvent
|
||||||
object AskUserForPushDistributor : VectorSettingsNotificationPreferenceViewEvent
|
object AskUserForPushDistributor : VectorSettingsNotificationViewEvent
|
||||||
object NotificationMethodChanged : VectorSettingsNotificationPreferenceViewEvent
|
object NotificationMethodChanged : VectorSettingsNotificationViewEvent
|
||||||
}
|
}
|
|
@ -36,7 +36,7 @@ import im.vector.app.features.settings.notifications.usecase.EnableNotifications
|
||||||
import im.vector.app.features.settings.notifications.usecase.ToggleNotificationsForCurrentSessionUseCase
|
import im.vector.app.features.settings.notifications.usecase.ToggleNotificationsForCurrentSessionUseCase
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class VectorSettingsNotificationPreferenceViewModel @AssistedInject constructor(
|
class VectorSettingsNotificationViewModel @AssistedInject constructor(
|
||||||
@Assisted initialState: VectorDummyViewState,
|
@Assisted initialState: VectorDummyViewState,
|
||||||
private val pushersManager: PushersManager,
|
private val pushersManager: PushersManager,
|
||||||
private val vectorPreferences: VectorPreferences,
|
private val vectorPreferences: VectorPreferences,
|
||||||
|
@ -46,23 +46,23 @@ class VectorSettingsNotificationPreferenceViewModel @AssistedInject constructor(
|
||||||
private val registerUnifiedPushUseCase: RegisterUnifiedPushUseCase,
|
private val registerUnifiedPushUseCase: RegisterUnifiedPushUseCase,
|
||||||
private val ensureFcmTokenIsRetrievedUseCase: EnsureFcmTokenIsRetrievedUseCase,
|
private val ensureFcmTokenIsRetrievedUseCase: EnsureFcmTokenIsRetrievedUseCase,
|
||||||
private val toggleNotificationsForCurrentSessionUseCase: ToggleNotificationsForCurrentSessionUseCase,
|
private val toggleNotificationsForCurrentSessionUseCase: ToggleNotificationsForCurrentSessionUseCase,
|
||||||
) : VectorViewModel<VectorDummyViewState, VectorSettingsNotificationPreferenceViewAction, VectorSettingsNotificationPreferenceViewEvent>(initialState) {
|
) : VectorViewModel<VectorDummyViewState, VectorSettingsNotificationViewAction, VectorSettingsNotificationViewEvent>(initialState) {
|
||||||
|
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory : MavericksAssistedViewModelFactory<VectorSettingsNotificationPreferenceViewModel, VectorDummyViewState> {
|
interface Factory : MavericksAssistedViewModelFactory<VectorSettingsNotificationViewModel, VectorDummyViewState> {
|
||||||
override fun create(initialState: VectorDummyViewState): VectorSettingsNotificationPreferenceViewModel
|
override fun create(initialState: VectorDummyViewState): VectorSettingsNotificationViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : MavericksViewModelFactory<VectorSettingsNotificationPreferenceViewModel, VectorDummyViewState> by hiltMavericksViewModelFactory()
|
companion object : MavericksViewModelFactory<VectorSettingsNotificationViewModel, VectorDummyViewState> by hiltMavericksViewModelFactory()
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
val notificationsPreferenceListener: SharedPreferences.OnSharedPreferenceChangeListener =
|
val notificationsPreferenceListener: SharedPreferences.OnSharedPreferenceChangeListener =
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||||
if (key == VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY) {
|
if (key == VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY) {
|
||||||
if (vectorPreferences.areNotificationEnabledForDevice()) {
|
if (vectorPreferences.areNotificationEnabledForDevice()) {
|
||||||
_viewEvents.post(VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceEnabled)
|
_viewEvents.post(VectorSettingsNotificationViewEvent.NotificationsForDeviceEnabled)
|
||||||
} else {
|
} else {
|
||||||
_viewEvents.post(VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceDisabled)
|
_viewEvents.post(VectorSettingsNotificationViewEvent.NotificationsForDeviceDisabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,18 +80,18 @@ class VectorSettingsNotificationPreferenceViewModel @AssistedInject constructor(
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handle(action: VectorSettingsNotificationPreferenceViewAction) {
|
override fun handle(action: VectorSettingsNotificationViewAction) {
|
||||||
when (action) {
|
when (action) {
|
||||||
VectorSettingsNotificationPreferenceViewAction.DisableNotificationsForDevice -> handleDisableNotificationsForDevice()
|
VectorSettingsNotificationViewAction.DisableNotificationsForDevice -> handleDisableNotificationsForDevice()
|
||||||
is VectorSettingsNotificationPreferenceViewAction.EnableNotificationsForDevice -> handleEnableNotificationsForDevice(action.pushDistributor)
|
is VectorSettingsNotificationViewAction.EnableNotificationsForDevice -> handleEnableNotificationsForDevice(action.pushDistributor)
|
||||||
is VectorSettingsNotificationPreferenceViewAction.RegisterPushDistributor -> handleRegisterPushDistributor(action.pushDistributor)
|
is VectorSettingsNotificationViewAction.RegisterPushDistributor -> handleRegisterPushDistributor(action.pushDistributor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleDisableNotificationsForDevice() {
|
private fun handleDisableNotificationsForDevice() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
disableNotificationsForCurrentSessionUseCase.execute()
|
disableNotificationsForCurrentSessionUseCase.execute()
|
||||||
_viewEvents.post(VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceDisabled)
|
_viewEvents.post(VectorSettingsNotificationViewEvent.NotificationsForDeviceDisabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +99,10 @@ class VectorSettingsNotificationPreferenceViewModel @AssistedInject constructor(
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
when (enableNotificationsForCurrentSessionUseCase.execute(distributor)) {
|
when (enableNotificationsForCurrentSessionUseCase.execute(distributor)) {
|
||||||
is EnableNotificationsForCurrentSessionUseCase.EnableNotificationsResult.NeedToAskUserForDistributor -> {
|
is EnableNotificationsForCurrentSessionUseCase.EnableNotificationsResult.NeedToAskUserForDistributor -> {
|
||||||
_viewEvents.post(VectorSettingsNotificationPreferenceViewEvent.AskUserForPushDistributor)
|
_viewEvents.post(VectorSettingsNotificationViewEvent.AskUserForPushDistributor)
|
||||||
}
|
}
|
||||||
EnableNotificationsForCurrentSessionUseCase.EnableNotificationsResult.Success -> {
|
EnableNotificationsForCurrentSessionUseCase.EnableNotificationsResult.Success -> {
|
||||||
_viewEvents.post(VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceEnabled)
|
_viewEvents.post(VectorSettingsNotificationViewEvent.NotificationsForDeviceEnabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,13 +113,13 @@ class VectorSettingsNotificationPreferenceViewModel @AssistedInject constructor(
|
||||||
unregisterUnifiedPushUseCase.execute(pushersManager)
|
unregisterUnifiedPushUseCase.execute(pushersManager)
|
||||||
when (registerUnifiedPushUseCase.execute(distributor)) {
|
when (registerUnifiedPushUseCase.execute(distributor)) {
|
||||||
RegisterUnifiedPushUseCase.RegisterUnifiedPushResult.NeedToAskUserForDistributor -> {
|
RegisterUnifiedPushUseCase.RegisterUnifiedPushResult.NeedToAskUserForDistributor -> {
|
||||||
_viewEvents.post(VectorSettingsNotificationPreferenceViewEvent.AskUserForPushDistributor)
|
_viewEvents.post(VectorSettingsNotificationViewEvent.AskUserForPushDistributor)
|
||||||
}
|
}
|
||||||
RegisterUnifiedPushUseCase.RegisterUnifiedPushResult.Success -> {
|
RegisterUnifiedPushUseCase.RegisterUnifiedPushResult.Success -> {
|
||||||
val areNotificationsEnabled = vectorPreferences.areNotificationEnabledForDevice()
|
val areNotificationsEnabled = vectorPreferences.areNotificationEnabledForDevice()
|
||||||
ensureFcmTokenIsRetrievedUseCase.execute(pushersManager, registerPusher = areNotificationsEnabled)
|
ensureFcmTokenIsRetrievedUseCase.execute(pushersManager, registerPusher = areNotificationsEnabled)
|
||||||
toggleNotificationsForCurrentSessionUseCase.execute(enabled = areNotificationsEnabled)
|
toggleNotificationsForCurrentSessionUseCase.execute(enabled = areNotificationsEnabled)
|
||||||
_viewEvents.post(VectorSettingsNotificationPreferenceViewEvent.NotificationMethodChanged)
|
_viewEvents.post(VectorSettingsNotificationViewEvent.NotificationMethodChanged)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,10 +25,10 @@ import im.vector.app.core.preference.VectorCheckboxPreference
|
||||||
import im.vector.app.features.settings.VectorSettingsBaseFragment
|
import im.vector.app.features.settings.VectorSettingsBaseFragment
|
||||||
import org.matrix.android.sdk.api.session.pushrules.rest.PushRuleAndKind
|
import org.matrix.android.sdk.api.session.pushrules.rest.PushRuleAndKind
|
||||||
|
|
||||||
abstract class VectorSettingsPushRuleNotificationPreferenceFragment :
|
abstract class VectorSettingsPushRuleNotificationFragment :
|
||||||
VectorSettingsBaseFragment() {
|
VectorSettingsBaseFragment() {
|
||||||
|
|
||||||
private val viewModel: VectorSettingsPushRuleNotificationPreferenceViewModel by fragmentViewModel()
|
private val viewModel: VectorSettingsPushRuleNotificationViewModel by fragmentViewModel()
|
||||||
|
|
||||||
abstract val prefKeyToPushRuleId: Map<String, String>
|
abstract val prefKeyToPushRuleId: Map<String, String>
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ abstract class VectorSettingsPushRuleNotificationPreferenceFragment :
|
||||||
private fun observeViewEvents() {
|
private fun observeViewEvents() {
|
||||||
viewModel.observeViewEvents {
|
viewModel.observeViewEvents {
|
||||||
when (it) {
|
when (it) {
|
||||||
is VectorSettingsPushRuleNotificationPreferenceViewEvent.Failure -> refreshDisplay()
|
is VectorSettingsPushRuleNotificationViewEvent.Failure -> refreshDisplay()
|
||||||
is VectorSettingsPushRuleNotificationPreferenceViewEvent.PushRuleUpdated -> updatePreference(it.ruleId, it.enabled)
|
is VectorSettingsPushRuleNotificationViewEvent.PushRuleUpdated -> updatePreference(it.ruleId, it.enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ abstract class VectorSettingsPushRuleNotificationPreferenceFragment :
|
||||||
val initialIndex = ruleAndKind.pushRule.notificationIndex
|
val initialIndex = ruleAndKind.pushRule.notificationIndex
|
||||||
preference.isChecked = initialIndex != NotificationIndex.OFF
|
preference.isChecked = initialIndex != NotificationIndex.OFF
|
||||||
preference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
preference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
viewModel.handle(VectorSettingsPushRuleNotificationPreferenceViewAction.UpdatePushRule(ruleAndKind, newValue as Boolean))
|
viewModel.handle(VectorSettingsPushRuleNotificationViewAction.UpdatePushRule(ruleAndKind, newValue as Boolean))
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,6 +19,6 @@ package im.vector.app.features.settings.notifications
|
||||||
import im.vector.app.core.platform.VectorViewModelAction
|
import im.vector.app.core.platform.VectorViewModelAction
|
||||||
import org.matrix.android.sdk.api.session.pushrules.rest.PushRuleAndKind
|
import org.matrix.android.sdk.api.session.pushrules.rest.PushRuleAndKind
|
||||||
|
|
||||||
sealed interface VectorSettingsPushRuleNotificationPreferenceViewAction : VectorViewModelAction {
|
sealed interface VectorSettingsPushRuleNotificationViewAction : VectorViewModelAction {
|
||||||
data class UpdatePushRule(val pushRuleAndKind: PushRuleAndKind, val checked: Boolean) : VectorSettingsPushRuleNotificationPreferenceViewAction
|
data class UpdatePushRule(val pushRuleAndKind: PushRuleAndKind, val checked: Boolean) : VectorSettingsPushRuleNotificationViewAction
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ package im.vector.app.features.settings.notifications
|
||||||
|
|
||||||
import im.vector.app.core.platform.VectorViewEvents
|
import im.vector.app.core.platform.VectorViewEvents
|
||||||
|
|
||||||
sealed interface VectorSettingsPushRuleNotificationPreferenceViewEvent : VectorViewEvents {
|
sealed interface VectorSettingsPushRuleNotificationViewEvent : VectorViewEvents {
|
||||||
data class PushRuleUpdated(val ruleId: String, val enabled: Boolean) : VectorSettingsPushRuleNotificationPreferenceViewEvent
|
data class PushRuleUpdated(val ruleId: String, val enabled: Boolean) : VectorSettingsPushRuleNotificationViewEvent
|
||||||
data class Failure(val throwable: Throwable) : VectorSettingsPushRuleNotificationPreferenceViewEvent
|
data class Failure(val throwable: Throwable) : VectorSettingsPushRuleNotificationViewEvent
|
||||||
}
|
}
|
|
@ -24,26 +24,31 @@ import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||||
import im.vector.app.core.platform.VectorViewModel
|
import im.vector.app.core.platform.VectorViewModel
|
||||||
|
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationViewEvent.Failure
|
||||||
|
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationViewEvent.PushRuleUpdated
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.pushrules.rest.PushRuleAndKind
|
import org.matrix.android.sdk.api.session.pushrules.rest.PushRuleAndKind
|
||||||
|
|
||||||
class VectorSettingsPushRuleNotificationPreferenceViewModel @AssistedInject constructor(
|
private typealias ViewModel = VectorSettingsPushRuleNotificationViewModel
|
||||||
@Assisted initialState: VectorSettingsPushRuleNotificationPreferenceViewState,
|
private typealias ViewState = VectorSettingsPushRuleNotificationViewState
|
||||||
|
|
||||||
|
class VectorSettingsPushRuleNotificationViewModel @AssistedInject constructor(
|
||||||
|
@Assisted initialState: ViewState,
|
||||||
private val activeSessionHolder: ActiveSessionHolder,
|
private val activeSessionHolder: ActiveSessionHolder,
|
||||||
) : VectorViewModel<VectorSettingsPushRuleNotificationPreferenceViewState,
|
) : VectorViewModel<VectorSettingsPushRuleNotificationViewState,
|
||||||
VectorSettingsPushRuleNotificationPreferenceViewAction,
|
VectorSettingsPushRuleNotificationViewAction,
|
||||||
VectorSettingsPushRuleNotificationPreferenceViewEvent>(initialState) {
|
VectorSettingsPushRuleNotificationViewEvent>(initialState) {
|
||||||
|
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory : MavericksAssistedViewModelFactory<VectorSettingsPushRuleNotificationPreferenceViewModel, VectorSettingsPushRuleNotificationPreferenceViewState> {
|
interface Factory : MavericksAssistedViewModelFactory<ViewModel, ViewState> {
|
||||||
override fun create(initialState: VectorSettingsPushRuleNotificationPreferenceViewState): VectorSettingsPushRuleNotificationPreferenceViewModel
|
override fun create(initialState: ViewState): ViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : MavericksViewModelFactory<VectorSettingsPushRuleNotificationPreferenceViewModel, VectorSettingsPushRuleNotificationPreferenceViewState> by hiltMavericksViewModelFactory()
|
companion object : MavericksViewModelFactory<ViewModel, ViewState> by hiltMavericksViewModelFactory()
|
||||||
|
|
||||||
override fun handle(action: VectorSettingsPushRuleNotificationPreferenceViewAction) {
|
override fun handle(action: VectorSettingsPushRuleNotificationViewAction) {
|
||||||
when (action) {
|
when (action) {
|
||||||
is VectorSettingsPushRuleNotificationPreferenceViewAction.UpdatePushRule -> handleUpdatePushRule(action.pushRuleAndKind, action.checked)
|
is VectorSettingsPushRuleNotificationViewAction.UpdatePushRule -> handleUpdatePushRule(action.pushRuleAndKind, action.checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +72,11 @@ class VectorSettingsPushRuleNotificationPreferenceViewModel @AssistedInject cons
|
||||||
}.fold(
|
}.fold(
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
setState { copy(isLoading = false) }
|
setState { copy(isLoading = false) }
|
||||||
_viewEvents.post(VectorSettingsPushRuleNotificationPreferenceViewEvent.PushRuleUpdated(ruleId, checked))
|
_viewEvents.post(PushRuleUpdated(ruleId, checked))
|
||||||
},
|
},
|
||||||
onFailure = { failure ->
|
onFailure = { failure ->
|
||||||
setState { copy(isLoading = false) }
|
setState { copy(isLoading = false) }
|
||||||
_viewEvents.post(VectorSettingsPushRuleNotificationPreferenceViewEvent.Failure(failure))
|
_viewEvents.post(Failure(failure))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -18,6 +18,6 @@ package im.vector.app.features.settings.notifications
|
||||||
|
|
||||||
import com.airbnb.mvrx.MavericksState
|
import com.airbnb.mvrx.MavericksState
|
||||||
|
|
||||||
data class VectorSettingsPushRuleNotificationPreferenceViewState(
|
data class VectorSettingsPushRuleNotificationViewState(
|
||||||
val isLoading: Boolean = false,
|
val isLoading: Boolean = false,
|
||||||
): MavericksState
|
): MavericksState
|
|
@ -20,11 +20,11 @@ import android.os.Bundle
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.preference.VectorPreferenceCategory
|
import im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
import im.vector.app.features.analytics.plan.MobileScreen
|
import im.vector.app.features.analytics.plan.MobileScreen
|
||||||
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationPreferenceFragment
|
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationFragment
|
||||||
import org.matrix.android.sdk.api.session.pushrules.RuleIds
|
import org.matrix.android.sdk.api.session.pushrules.RuleIds
|
||||||
|
|
||||||
class VectorSettingsDefaultNotificationPreferenceFragment :
|
class VectorSettingsDefaultNotificationFragment :
|
||||||
VectorSettingsPushRuleNotificationPreferenceFragment() {
|
VectorSettingsPushRuleNotificationFragment() {
|
||||||
|
|
||||||
override var titleRes: Int = R.string.settings_notification_default
|
override var titleRes: Int = R.string.settings_notification_default
|
||||||
|
|
|
@ -28,7 +28,7 @@ import im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
import im.vector.app.features.analytics.plan.MobileScreen
|
import im.vector.app.features.analytics.plan.MobileScreen
|
||||||
import im.vector.app.features.settings.notifications.NotificationIndex
|
import im.vector.app.features.settings.notifications.NotificationIndex
|
||||||
import im.vector.app.features.settings.notifications.StandardActions
|
import im.vector.app.features.settings.notifications.StandardActions
|
||||||
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationPreferenceFragment
|
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationFragment
|
||||||
import im.vector.app.features.settings.notifications.getStandardAction
|
import im.vector.app.features.settings.notifications.getStandardAction
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
@ -38,8 +38,8 @@ import org.matrix.android.sdk.api.session.pushrules.RuleKind
|
||||||
import org.matrix.android.sdk.api.session.pushrules.rest.PushRule
|
import org.matrix.android.sdk.api.session.pushrules.rest.PushRule
|
||||||
import org.matrix.android.sdk.api.session.pushrules.toJson
|
import org.matrix.android.sdk.api.session.pushrules.toJson
|
||||||
|
|
||||||
class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment :
|
class VectorSettingsKeywordAndMentionsNotificationFragment :
|
||||||
VectorSettingsPushRuleNotificationPreferenceFragment() {
|
VectorSettingsPushRuleNotificationFragment() {
|
||||||
|
|
||||||
override var titleRes: Int = R.string.settings_notification_mentions_and_keywords
|
override var titleRes: Int = R.string.settings_notification_mentions_and_keywords
|
||||||
|
|
|
@ -18,11 +18,11 @@ package im.vector.app.features.settings.notifications.other
|
||||||
|
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.preference.VectorPreferenceCategory
|
import im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationPreferenceFragment
|
import im.vector.app.features.settings.notifications.VectorSettingsPushRuleNotificationFragment
|
||||||
import org.matrix.android.sdk.api.session.pushrules.RuleIds
|
import org.matrix.android.sdk.api.session.pushrules.RuleIds
|
||||||
|
|
||||||
class VectorSettingsOtherNotificationPreferenceFragment :
|
class VectorSettingsOtherNotificationFragment :
|
||||||
VectorSettingsPushRuleNotificationPreferenceFragment() {
|
VectorSettingsPushRuleNotificationFragment() {
|
||||||
|
|
||||||
override var titleRes: Int = R.string.settings_notification_other
|
override var titleRes: Int = R.string.settings_notification_other
|
||||||
|
|
|
@ -25,21 +25,21 @@
|
||||||
android:key="SETTINGS_NOTIFICATION_DEFAULT_PREFERENCE_KEY"
|
android:key="SETTINGS_NOTIFICATION_DEFAULT_PREFERENCE_KEY"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/settings_notification_default"
|
android:title="@string/settings_notification_default"
|
||||||
app:fragment="im.vector.app.features.settings.notifications.defaults.VectorSettingsDefaultNotificationPreferenceFragment" />
|
app:fragment="im.vector.app.features.settings.notifications.defaults.VectorSettingsDefaultNotificationFragment" />
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreference
|
<im.vector.app.core.preference.VectorPreference
|
||||||
android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"
|
android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"
|
||||||
android:key="SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY"
|
android:key="SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/settings_notification_mentions_and_keywords"
|
android:title="@string/settings_notification_mentions_and_keywords"
|
||||||
app:fragment="im.vector.app.features.settings.notifications.keywordandmentions.VectorSettingsKeywordAndMentionsNotificationPreferenceFragment" />
|
app:fragment="im.vector.app.features.settings.notifications.keywordandmentions.VectorSettingsKeywordAndMentionsNotificationFragment" />
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreference
|
<im.vector.app.core.preference.VectorPreference
|
||||||
android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"
|
android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"
|
||||||
android:key="SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY"
|
android:key="SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/settings_notification_other"
|
android:title="@string/settings_notification_other"
|
||||||
app:fragment="im.vector.app.features.settings.notifications.other.VectorSettingsOtherNotificationPreferenceFragment" />
|
app:fragment="im.vector.app.features.settings.notifications.other.VectorSettingsOtherNotificationFragment" />
|
||||||
|
|
||||||
</im.vector.app.core.preference.VectorPreferenceCategory>
|
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<im.vector.app.core.preference.VectorPreference
|
<im.vector.app.core.preference.VectorPreference
|
||||||
android:icon="@drawable/ic_settings_root_notification"
|
android:icon="@drawable/ic_settings_root_notification"
|
||||||
android:title="@string/settings_notifications"
|
android:title="@string/settings_notifications"
|
||||||
app:fragment="im.vector.app.features.settings.notifications.VectorSettingsNotificationPreferenceFragment"
|
app:fragment="im.vector.app.features.settings.notifications.VectorSettingsNotificationFragment"
|
||||||
app:isPreferenceVisible="@bool/settings_root_notification_visible" />
|
app:isPreferenceVisible="@bool/settings_root_notification_visible" />
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorPreference
|
<im.vector.app.core.preference.VectorPreference
|
||||||
|
|
|
@ -38,7 +38,7 @@ import io.mockk.mockk
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class VectorSettingsNotificationPreferenceViewModelTest {
|
class VectorSettingsNotificationViewModelTest {
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
val mavericksTestRule = MavericksTestRule(testDispatcher = testDispatcher)
|
val mavericksTestRule = MavericksTestRule(testDispatcher = testDispatcher)
|
||||||
|
@ -52,7 +52,7 @@ class VectorSettingsNotificationPreferenceViewModelTest {
|
||||||
private val fakeEnsureFcmTokenIsRetrievedUseCase = mockk<EnsureFcmTokenIsRetrievedUseCase>()
|
private val fakeEnsureFcmTokenIsRetrievedUseCase = mockk<EnsureFcmTokenIsRetrievedUseCase>()
|
||||||
private val fakeToggleNotificationsForCurrentSessionUseCase = mockk<ToggleNotificationsForCurrentSessionUseCase>()
|
private val fakeToggleNotificationsForCurrentSessionUseCase = mockk<ToggleNotificationsForCurrentSessionUseCase>()
|
||||||
|
|
||||||
private fun createViewModel() = VectorSettingsNotificationPreferenceViewModel(
|
private fun createViewModel() = VectorSettingsNotificationViewModel(
|
||||||
initialState = VectorDummyViewState(),
|
initialState = VectorDummyViewState(),
|
||||||
pushersManager = fakePushersManager.instance,
|
pushersManager = fakePushersManager.instance,
|
||||||
vectorPreferences = fakeVectorPreferences.instance,
|
vectorPreferences = fakeVectorPreferences.instance,
|
||||||
|
@ -68,7 +68,7 @@ class VectorSettingsNotificationPreferenceViewModelTest {
|
||||||
fun `given view model init when notifications are enabled in preferences then view event is posted`() {
|
fun `given view model init when notifications are enabled in preferences then view event is posted`() {
|
||||||
// Given
|
// Given
|
||||||
fakeVectorPreferences.givenAreNotificationsEnabledForDevice(true)
|
fakeVectorPreferences.givenAreNotificationsEnabledForDevice(true)
|
||||||
val expectedEvent = VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceEnabled
|
val expectedEvent = VectorSettingsNotificationViewEvent.NotificationsForDeviceEnabled
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
|
|
||||||
// When
|
// When
|
||||||
|
@ -85,7 +85,7 @@ class VectorSettingsNotificationPreferenceViewModelTest {
|
||||||
fun `given view model init when notifications are disabled in preferences then view event is posted`() {
|
fun `given view model init when notifications are disabled in preferences then view event is posted`() {
|
||||||
// Given
|
// Given
|
||||||
fakeVectorPreferences.givenAreNotificationsEnabledForDevice(false)
|
fakeVectorPreferences.givenAreNotificationsEnabledForDevice(false)
|
||||||
val expectedEvent = VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceDisabled
|
val expectedEvent = VectorSettingsNotificationViewEvent.NotificationsForDeviceDisabled
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
|
|
||||||
// When
|
// When
|
||||||
|
@ -102,9 +102,9 @@ class VectorSettingsNotificationPreferenceViewModelTest {
|
||||||
fun `given DisableNotificationsForDevice action when handling action then disable use case is called`() {
|
fun `given DisableNotificationsForDevice action when handling action then disable use case is called`() {
|
||||||
// Given
|
// Given
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
val action = VectorSettingsNotificationPreferenceViewAction.DisableNotificationsForDevice
|
val action = VectorSettingsNotificationViewAction.DisableNotificationsForDevice
|
||||||
coJustRun { fakeDisableNotificationsForCurrentSessionUseCase.execute() }
|
coJustRun { fakeDisableNotificationsForCurrentSessionUseCase.execute() }
|
||||||
val expectedEvent = VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceDisabled
|
val expectedEvent = VectorSettingsNotificationViewEvent.NotificationsForDeviceDisabled
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val viewModelTest = viewModel.test()
|
val viewModelTest = viewModel.test()
|
||||||
|
@ -124,10 +124,10 @@ class VectorSettingsNotificationPreferenceViewModelTest {
|
||||||
// Given
|
// Given
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
val aDistributor = "aDistributor"
|
val aDistributor = "aDistributor"
|
||||||
val action = VectorSettingsNotificationPreferenceViewAction.EnableNotificationsForDevice(aDistributor)
|
val action = VectorSettingsNotificationViewAction.EnableNotificationsForDevice(aDistributor)
|
||||||
coEvery { fakeEnableNotificationsForCurrentSessionUseCase.execute(any()) } returns
|
coEvery { fakeEnableNotificationsForCurrentSessionUseCase.execute(any()) } returns
|
||||||
EnableNotificationsForCurrentSessionUseCase.EnableNotificationsResult.Success
|
EnableNotificationsForCurrentSessionUseCase.EnableNotificationsResult.Success
|
||||||
val expectedEvent = VectorSettingsNotificationPreferenceViewEvent.NotificationsForDeviceEnabled
|
val expectedEvent = VectorSettingsNotificationViewEvent.NotificationsForDeviceEnabled
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val viewModelTest = viewModel.test()
|
val viewModelTest = viewModel.test()
|
||||||
|
@ -147,10 +147,10 @@ class VectorSettingsNotificationPreferenceViewModelTest {
|
||||||
// Given
|
// Given
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
val aDistributor = "aDistributor"
|
val aDistributor = "aDistributor"
|
||||||
val action = VectorSettingsNotificationPreferenceViewAction.EnableNotificationsForDevice(aDistributor)
|
val action = VectorSettingsNotificationViewAction.EnableNotificationsForDevice(aDistributor)
|
||||||
coEvery { fakeEnableNotificationsForCurrentSessionUseCase.execute(any()) } returns
|
coEvery { fakeEnableNotificationsForCurrentSessionUseCase.execute(any()) } returns
|
||||||
EnableNotificationsForCurrentSessionUseCase.EnableNotificationsResult.NeedToAskUserForDistributor
|
EnableNotificationsForCurrentSessionUseCase.EnableNotificationsResult.NeedToAskUserForDistributor
|
||||||
val expectedEvent = VectorSettingsNotificationPreferenceViewEvent.AskUserForPushDistributor
|
val expectedEvent = VectorSettingsNotificationViewEvent.AskUserForPushDistributor
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val viewModelTest = viewModel.test()
|
val viewModelTest = viewModel.test()
|
||||||
|
@ -170,14 +170,14 @@ class VectorSettingsNotificationPreferenceViewModelTest {
|
||||||
// Given
|
// Given
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
val aDistributor = "aDistributor"
|
val aDistributor = "aDistributor"
|
||||||
val action = VectorSettingsNotificationPreferenceViewAction.RegisterPushDistributor(aDistributor)
|
val action = VectorSettingsNotificationViewAction.RegisterPushDistributor(aDistributor)
|
||||||
coEvery { fakeRegisterUnifiedPushUseCase.execute(any()) } returns RegisterUnifiedPushUseCase.RegisterUnifiedPushResult.Success
|
coEvery { fakeRegisterUnifiedPushUseCase.execute(any()) } returns RegisterUnifiedPushUseCase.RegisterUnifiedPushResult.Success
|
||||||
coJustRun { fakeUnregisterUnifiedPushUseCase.execute(any()) }
|
coJustRun { fakeUnregisterUnifiedPushUseCase.execute(any()) }
|
||||||
val areNotificationsEnabled = true
|
val areNotificationsEnabled = true
|
||||||
fakeVectorPreferences.givenAreNotificationsEnabledForDevice(areNotificationsEnabled)
|
fakeVectorPreferences.givenAreNotificationsEnabledForDevice(areNotificationsEnabled)
|
||||||
coJustRun { fakeToggleNotificationsForCurrentSessionUseCase.execute(any()) }
|
coJustRun { fakeToggleNotificationsForCurrentSessionUseCase.execute(any()) }
|
||||||
justRun { fakeEnsureFcmTokenIsRetrievedUseCase.execute(any(), any()) }
|
justRun { fakeEnsureFcmTokenIsRetrievedUseCase.execute(any(), any()) }
|
||||||
val expectedEvent = VectorSettingsNotificationPreferenceViewEvent.NotificationMethodChanged
|
val expectedEvent = VectorSettingsNotificationViewEvent.NotificationMethodChanged
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val viewModelTest = viewModel.test()
|
val viewModelTest = viewModel.test()
|
||||||
|
@ -200,10 +200,10 @@ class VectorSettingsNotificationPreferenceViewModelTest {
|
||||||
// Given
|
// Given
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
val aDistributor = "aDistributor"
|
val aDistributor = "aDistributor"
|
||||||
val action = VectorSettingsNotificationPreferenceViewAction.RegisterPushDistributor(aDistributor)
|
val action = VectorSettingsNotificationViewAction.RegisterPushDistributor(aDistributor)
|
||||||
coEvery { fakeRegisterUnifiedPushUseCase.execute(any()) } returns RegisterUnifiedPushUseCase.RegisterUnifiedPushResult.NeedToAskUserForDistributor
|
coEvery { fakeRegisterUnifiedPushUseCase.execute(any()) } returns RegisterUnifiedPushUseCase.RegisterUnifiedPushResult.NeedToAskUserForDistributor
|
||||||
coJustRun { fakeUnregisterUnifiedPushUseCase.execute(any()) }
|
coJustRun { fakeUnregisterUnifiedPushUseCase.execute(any()) }
|
||||||
val expectedEvent = VectorSettingsNotificationPreferenceViewEvent.AskUserForPushDistributor
|
val expectedEvent = VectorSettingsNotificationViewEvent.AskUserForPushDistributor
|
||||||
|
|
||||||
// When
|
// When
|
||||||
val viewModelTest = viewModel.test()
|
val viewModelTest = viewModel.test()
|
Loading…
Reference in New Issue