Fixing wrong notification status when no registered pusher for the session
This commit is contained in:
parent
b78de15228
commit
e09b9a2ce0
|
@ -51,7 +51,13 @@ class GetNotificationsStatusUseCase @Inject constructor(
|
||||||
.livePushers()
|
.livePushers()
|
||||||
.map { it.filter { pusher -> pusher.deviceId == deviceId } }
|
.map { it.filter { pusher -> pusher.deviceId == deviceId } }
|
||||||
.map { it.takeIf { it.isNotEmpty() }?.any { pusher -> pusher.enabled } }
|
.map { it.takeIf { it.isNotEmpty() }?.any { pusher -> pusher.enabled } }
|
||||||
.map { if (it == true) NotificationsStatus.ENABLED else NotificationsStatus.DISABLED }
|
.map {
|
||||||
|
when (it) {
|
||||||
|
true -> NotificationsStatus.ENABLED
|
||||||
|
false -> NotificationsStatus.DISABLED
|
||||||
|
else -> NotificationsStatus.NOT_SUPPORTED
|
||||||
|
}
|
||||||
|
}
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
} else {
|
} else {
|
||||||
flowOf(NotificationsStatus.NOT_SUPPORTED)
|
flowOf(NotificationsStatus.NOT_SUPPORTED)
|
||||||
|
|
|
@ -105,6 +105,20 @@ class GetNotificationsStatusUseCaseTest {
|
||||||
result.firstOrNull() shouldBeEqualTo NotificationsStatus.ENABLED
|
result.firstOrNull() shouldBeEqualTo NotificationsStatus.ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `given toggle via pusher is supported and no registered pusher when execute then resulting flow contains NOT_SUPPORTED value`() = runTest {
|
||||||
|
// Given
|
||||||
|
fakeSession.pushersService().givenPushersLive(emptyList())
|
||||||
|
every { fakeCheckIfCanToggleNotificationsViaAccountDataUseCase.execute(fakeSession, A_DEVICE_ID) } returns false
|
||||||
|
every { fakeCanToggleNotificationsViaPusherUseCase.execute(fakeSession) } returns flowOf(true)
|
||||||
|
|
||||||
|
// When
|
||||||
|
val result = getNotificationsStatusUseCase.execute(fakeSession, A_DEVICE_ID)
|
||||||
|
|
||||||
|
// Then
|
||||||
|
result.firstOrNull() shouldBeEqualTo NotificationsStatus.NOT_SUPPORTED
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given current session and toggle via account data is supported when execute then resulting flow contains status based on settings value`() = runTest {
|
fun `given current session and toggle via account data is supported when execute then resulting flow contains status based on settings value`() = runTest {
|
||||||
// Given
|
// Given
|
||||||
|
|
Loading…
Reference in New Issue