File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed
vector/src/main/java/im/vector/app/features/settings/devices/v2 Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package im.vector.app.features.settings.devices.v2.notification
18
18
19
19
import im.vector.app.core.di.ActiveSessionHolder
20
20
import kotlinx.coroutines.flow.Flow
21
+ import kotlinx.coroutines.flow.distinctUntilChanged
21
22
import kotlinx.coroutines.flow.flowOf
22
23
import kotlinx.coroutines.flow.map
23
24
import org.matrix.android.sdk.api.account.LocalNotificationSettingsContent
@@ -43,13 +44,15 @@ class GetNotificationsStatusUseCase @Inject constructor(
43
44
.map { it.filter { pusher -> pusher.deviceId == deviceId } }
44
45
.map { it.takeIf { it.isNotEmpty() }?.any { pusher -> pusher.enabled } }
45
46
.map { if (it == true ) NotificationsStatus .ENABLED else NotificationsStatus .DISABLED }
47
+ .distinctUntilChanged()
46
48
}
47
49
checkIfCanTogglePushNotificationsViaAccountDataUseCase.execute(deviceId) -> {
48
50
session.flow()
49
51
.liveUserAccountData(UserAccountDataTypes .TYPE_LOCAL_NOTIFICATION_SETTINGS + deviceId)
50
52
.unwrap()
51
53
.map { it.content.toModel<LocalNotificationSettingsContent >()?.isSilenced?.not () }
52
54
.map { if (it == true ) NotificationsStatus .ENABLED else NotificationsStatus .DISABLED }
55
+ .distinctUntilChanged()
53
56
}
54
57
else -> flowOf(NotificationsStatus .NOT_SUPPORTED )
55
58
}
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ import im.vector.app.features.auth.PendingAuthHandler
30
30
import im.vector.app.features.settings.devices.v2.RefreshDevicesUseCase
31
31
import im.vector.app.features.settings.devices.v2.VectorSessionsListViewModel
32
32
import im.vector.app.features.settings.devices.v2.notification.GetNotificationsStatusUseCase
33
- import im.vector.app.features.settings.devices.v2.notification.NotificationsStatus
34
33
import im.vector.app.features.settings.devices.v2.notification.TogglePushNotificationUseCase
35
34
import im.vector.app.features.settings.devices.v2.signout.InterceptSignoutFlowResponseUseCase
36
35
import im.vector.app.features.settings.devices.v2.signout.SignoutSessionResult
@@ -220,9 +219,6 @@ class SessionOverviewViewModel @AssistedInject constructor(
220
219
private fun handleTogglePusherAction (action : SessionOverviewAction .TogglePushNotifications ) {
221
220
viewModelScope.launch {
222
221
togglePushNotificationUseCase.execute(action.deviceId, action.enabled)
223
- // TODO should not be needed => test without
224
- val status = if (action.enabled) NotificationsStatus .ENABLED else NotificationsStatus .DISABLED
225
- setState { copy(notificationsStatus = status) }
226
222
}
227
223
}
228
224
}
You can’t perform that action at this time.
0 commit comments