mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 03:06:14 +00:00
NotificationsOptInEvents -> NotificationsOptInEvent
This commit is contained in:
+3
-3
@@ -8,7 +8,7 @@
|
||||
|
||||
package io.element.android.features.ftue.impl.notifications
|
||||
|
||||
sealed interface NotificationsOptInEvents {
|
||||
data object ContinueClicked : NotificationsOptInEvents
|
||||
data object NotNowClicked : NotificationsOptInEvents
|
||||
sealed interface NotificationsOptInEvent {
|
||||
data object ContinueClicked : NotificationsOptInEvent
|
||||
data object NotNowClicked : NotificationsOptInEvent
|
||||
}
|
||||
+3
-3
@@ -52,16 +52,16 @@ class NotificationsOptInPresenter(
|
||||
override fun present(): NotificationsOptInState {
|
||||
val notificationsPermissionsState = postNotificationPermissionsPresenter.present()
|
||||
|
||||
fun handleEvent(event: NotificationsOptInEvents) {
|
||||
fun handleEvent(event: NotificationsOptInEvent) {
|
||||
when (event) {
|
||||
NotificationsOptInEvents.ContinueClicked -> {
|
||||
NotificationsOptInEvent.ContinueClicked -> {
|
||||
if (notificationsPermissionsState.permissionGranted) {
|
||||
callback.onNotificationsOptInFinished()
|
||||
} else {
|
||||
notificationsPermissionsState.eventSink(PermissionsEvent.RequestPermissions)
|
||||
}
|
||||
}
|
||||
NotificationsOptInEvents.NotNowClicked -> {
|
||||
NotificationsOptInEvent.NotNowClicked -> {
|
||||
if (buildVersionSdkIntProvider.isAtLeast(Build.VERSION_CODES.TIRAMISU)) {
|
||||
appCoroutineScope.setPermissionDenied()
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,5 +12,5 @@ import io.element.android.libraries.permissions.api.PermissionsState
|
||||
|
||||
data class NotificationsOptInState(
|
||||
val notificationsPermissionState: PermissionsState,
|
||||
val eventSink: (NotificationsOptInEvents) -> Unit
|
||||
val eventSink: (NotificationsOptInEvent) -> Unit
|
||||
)
|
||||
|
||||
+2
-2
@@ -86,14 +86,14 @@ private fun NotificationsOptInFooter(state: NotificationsOptInState) {
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(CommonStrings.action_ok),
|
||||
onClick = {
|
||||
state.eventSink(NotificationsOptInEvents.ContinueClicked)
|
||||
state.eventSink(NotificationsOptInEvent.ContinueClicked)
|
||||
}
|
||||
)
|
||||
TextButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(CommonStrings.action_not_now),
|
||||
onClick = {
|
||||
state.eventSink(NotificationsOptInEvents.NotNowClicked)
|
||||
state.eventSink(NotificationsOptInEvent.NotNowClicked)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
+4
-4
@@ -55,7 +55,7 @@ class NotificationsOptInPresenterTest {
|
||||
presenter.present()
|
||||
}.test {
|
||||
val initialState = awaitItem()
|
||||
initialState.eventSink(NotificationsOptInEvents.ContinueClicked)
|
||||
initialState.eventSink(NotificationsOptInEvent.ContinueClicked)
|
||||
assertThat(awaitItem().notificationsPermissionState.showDialog).isTrue()
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class NotificationsOptInPresenterTest {
|
||||
presenter.present()
|
||||
}.test {
|
||||
val initialState = awaitItem()
|
||||
initialState.eventSink(NotificationsOptInEvents.ContinueClicked)
|
||||
initialState.eventSink(NotificationsOptInEvent.ContinueClicked)
|
||||
assertThat(isFinished).isTrue()
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class NotificationsOptInPresenterTest {
|
||||
presenter.present()
|
||||
}.test {
|
||||
val initialState = awaitItem()
|
||||
initialState.eventSink(NotificationsOptInEvents.NotNowClicked)
|
||||
initialState.eventSink(NotificationsOptInEvent.NotNowClicked)
|
||||
assertThat(isFinished).isTrue()
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class NotificationsOptInPresenterTest {
|
||||
presenter.present()
|
||||
}.test {
|
||||
val initialState = awaitItem()
|
||||
initialState.eventSink(NotificationsOptInEvents.NotNowClicked)
|
||||
initialState.eventSink(NotificationsOptInEvent.NotNowClicked)
|
||||
|
||||
// Allow background coroutines to run
|
||||
runCurrent()
|
||||
|
||||
Reference in New Issue
Block a user