Fix edition
This commit is contained in:
parent
bfb6bd9d08
commit
6895f8bcae
4 changed files with 14 additions and 34 deletions
|
|
@ -20,5 +20,5 @@ import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
|||
|
||||
sealed interface RoomNotificationSettingsEvents {
|
||||
data class RoomNotificationModeChanged(val mode: RoomNotificationMode) : RoomNotificationSettingsEvents
|
||||
object DefaultNotificationModeSelected: RoomNotificationSettingsEvents
|
||||
data class SetNotificationMode(val isDefault: Boolean): RoomNotificationSettingsEvents
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,12 +30,9 @@ import io.element.android.libraries.matrix.api.room.MatrixRoom
|
|||
import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
||||
import io.element.android.libraries.matrix.api.room.roomNotificationSettings
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.buffer
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class RoomNotificationSettingsPresenter @Inject constructor(
|
||||
|
|
@ -62,8 +59,14 @@ class RoomNotificationSettingsPresenter @Inject constructor(
|
|||
is RoomNotificationSettingsEvents.RoomNotificationModeChanged -> {
|
||||
localCoroutineScope.setRoomNotificationMode(event.mode)
|
||||
}
|
||||
RoomNotificationSettingsEvents.DefaultNotificationModeSelected -> {
|
||||
localCoroutineScope.restoreDefaultRoomNotificationMode()
|
||||
is RoomNotificationSettingsEvents.SetNotificationMode -> {
|
||||
if (event.isDefault) {
|
||||
localCoroutineScope.restoreDefaultRoomNotificationMode()
|
||||
} else {
|
||||
defaultRoomNotificationMode.value?.let {
|
||||
localCoroutineScope.setRoomNotificationMode(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,9 +79,8 @@ class RoomNotificationSettingsPresenter @Inject constructor(
|
|||
}
|
||||
|
||||
private fun CoroutineScope.observeNotificationSettings() {
|
||||
notificationSettingsService.notificationSettingsChangeFlow.buffer(Channel.UNLIMITED).onEach {
|
||||
//room.updateRoomNotificationSettings()
|
||||
Timber.d("emit is called")
|
||||
notificationSettingsService.notificationSettingsChangeFlow.onEach {
|
||||
room.updateRoomNotificationSettings()
|
||||
}.launchIn(this)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,13 +66,6 @@ fun RoomNotificationSettingsView(
|
|||
.consumeWindowInsets(padding),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
// PreferenceSwitch(
|
||||
// isChecked = state.formState.sendLogs,
|
||||
// onCheckedChange = { eventSink(BugReportEvents.SetSendLog(it)) },
|
||||
// enabled = isFormEnabled,
|
||||
// title = stringResource(id = R.string.screen_bug_report_include_logs),
|
||||
// subtitle = stringResource(id = R.string.screen_bug_report_logs_description),
|
||||
// )
|
||||
val subtitle = when(state.defaultRoomNotificationMode) {
|
||||
RoomNotificationMode.ALL_MESSAGES -> "All messages"
|
||||
RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY -> "Mentions and keywords"
|
||||
|
|
@ -85,7 +78,7 @@ fun RoomNotificationSettingsView(
|
|||
PreferenceSwitch(
|
||||
isChecked = state.roomNotificationSettings?.isDefault.orTrue(),
|
||||
onCheckedChange = {
|
||||
state.eventSink(RoomNotificationSettingsEvents.DefaultNotificationModeSelected)
|
||||
state.eventSink(RoomNotificationSettingsEvents.SetNotificationMode(it))
|
||||
},
|
||||
title = "Match default setting",
|
||||
subtitle = subtitle,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue