mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-18 20:39:57 +01:00
Update use cases to enable/disable push notifications for the current session
This commit is contained in:
parent
9d684bc021
commit
c56eb331db
@ -34,9 +34,8 @@ class DisableNotificationsForCurrentSessionUseCase @Inject constructor(
|
||||
suspend fun execute() {
|
||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||
val deviceId = session.sessionParams.deviceId ?: return
|
||||
if (checkIfCanTogglePushNotificationsViaPusherUseCase.execute(session)) {
|
||||
togglePushNotificationUseCase.execute(deviceId, enabled = false)
|
||||
} else {
|
||||
togglePushNotificationUseCase.execute(deviceId, enabled = false)
|
||||
if (!checkIfCanTogglePushNotificationsViaPusherUseCase.execute(session)) {
|
||||
unregisterUnifiedPushUseCase.execute(pushersManager)
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ class DisableNotificationsForCurrentSessionUseCaseTest {
|
||||
val fakeSession = fakeActiveSessionHolder.fakeSession
|
||||
fakeSession.givenSessionId(A_SESSION_ID)
|
||||
every { fakeCheckIfCanTogglePushNotificationsViaPusherUseCase.execute(fakeSession) } returns false
|
||||
coJustRun { fakeTogglePushNotificationUseCase.execute(A_SESSION_ID, any()) }
|
||||
coJustRun { fakeUnregisterUnifiedPushUseCase.execute(any()) }
|
||||
|
||||
// When
|
||||
@ -74,6 +75,7 @@ class DisableNotificationsForCurrentSessionUseCaseTest {
|
||||
|
||||
// Then
|
||||
coVerify {
|
||||
fakeTogglePushNotificationUseCase.execute(A_SESSION_ID, false)
|
||||
fakeUnregisterUnifiedPushUseCase.execute(fakePushersManager.instance)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user