Loading feature/debug-settings/src/debug/kotlin/net/thunderbird/feature/debug/settings/SecretDebugSettingsScreenPreview.kt +7 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark import app.k9mail.core.ui.compose.common.koin.koinPreview import app.k9mail.core.ui.compose.designsystem.PreviewWithThemesLightDark import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.flowOf import net.thunderbird.core.common.resources.StringsResourceManager import net.thunderbird.core.outcome.Outcome Loading @@ -16,6 +17,8 @@ import net.thunderbird.feature.mail.account.api.BaseAccount import net.thunderbird.feature.notification.api.command.NotificationCommand.Failure import net.thunderbird.feature.notification.api.command.NotificationCommand.Success import net.thunderbird.feature.notification.api.content.Notification import net.thunderbird.feature.notification.api.receiver.InAppNotificationEvent import net.thunderbird.feature.notification.api.receiver.InAppNotificationReceiver import net.thunderbird.feature.notification.api.sender.NotificationSender @PreviewLightDark Loading Loading @@ -47,6 +50,10 @@ private fun SecretDebugSettingsScreenPreview() { ): Flow<Outcome<Success<Notification>, Failure<Notification>>> = error("not implemented") }, notificationReceiver = object : InAppNotificationReceiver { override val events: SharedFlow<InAppNotificationEvent> get() = error("not implemented") }, ) } } WithContent { Loading feature/debug-settings/src/debug/kotlin/net/thunderbird/feature/debug/settings/inject/FeatureDebugSettingsModule.kt +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ val featureDebugSettingsModule = module { stringsResourceManager = get(), accountManager = get(), notificationSender = get(), notificationReceiver = get(), ) } } feature/debug-settings/src/main/kotlin/net/thunderbird/feature/debug/settings/notification/DebugNotificationSectionViewModel.kt +15 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toPersistentList import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import net.thunderbird.core.common.resources.StringsResourceManager Loading @@ -27,12 +28,14 @@ import net.thunderbird.feature.notification.api.content.MailNotification import net.thunderbird.feature.notification.api.content.Notification import net.thunderbird.feature.notification.api.content.PushServiceNotification import net.thunderbird.feature.notification.api.content.SystemNotification import net.thunderbird.feature.notification.api.receiver.InAppNotificationReceiver import net.thunderbird.feature.notification.api.sender.NotificationSender internal class DebugNotificationSectionViewModel( private val stringsResourceManager: StringsResourceManager, private val accountManager: AccountManager<BaseAccount>, private val notificationSender: NotificationSender, private val notificationReceiver: InAppNotificationReceiver, private val mainDispatcher: CoroutineDispatcher = Dispatchers.Main, ioDispatcher: CoroutineDispatcher = Dispatchers.IO, ) : BaseViewModel<State, Event, Effect>(initialState = State()), DebugNotificationSectionContract.ViewModel { Loading Loading @@ -76,6 +79,18 @@ internal class DebugNotificationSectionViewModel( } } } viewModelScope.launch { notificationReceiver .events .collectLatest { event -> updateState { state -> state.copy( notificationStatusLog = state.notificationStatusLog + " In-app notification event: $event", ) } } } } override fun event(event: Event) { Loading feature/notification/api/build.gradle.kts +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.internal.config.LanguageFeature plugins { id(ThunderbirdPlugins.Library.kmpCompose) alias(libs.plugins.dev.mokkery) } kotlin { Loading feature/notification/api/src/commonMain/kotlin/net/thunderbird/feature/notification/api/receiver/InAppNotificationReceiver.kt 0 → 100644 +19 −0 Original line number Diff line number Diff line package net.thunderbird.feature.notification.api.receiver import kotlinx.coroutines.flow.SharedFlow import net.thunderbird.feature.notification.api.content.InAppNotification /** * Interface for receiving in-app notification events. * * This interface provides a [SharedFlow] of [InAppNotificationEvent]s that can be observed * by UI components or other parts of the application to react to in-app notifications. */ interface InAppNotificationReceiver { val events: SharedFlow<InAppNotificationEvent> } sealed interface InAppNotificationEvent { data class Show(val notification: InAppNotification) : InAppNotificationEvent data class Dismiss(val notification: InAppNotification) : InAppNotificationEvent } Loading
feature/debug-settings/src/debug/kotlin/net/thunderbird/feature/debug/settings/SecretDebugSettingsScreenPreview.kt +7 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import androidx.compose.ui.tooling.preview.PreviewLightDark import app.k9mail.core.ui.compose.common.koin.koinPreview import app.k9mail.core.ui.compose.designsystem.PreviewWithThemesLightDark import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.flowOf import net.thunderbird.core.common.resources.StringsResourceManager import net.thunderbird.core.outcome.Outcome Loading @@ -16,6 +17,8 @@ import net.thunderbird.feature.mail.account.api.BaseAccount import net.thunderbird.feature.notification.api.command.NotificationCommand.Failure import net.thunderbird.feature.notification.api.command.NotificationCommand.Success import net.thunderbird.feature.notification.api.content.Notification import net.thunderbird.feature.notification.api.receiver.InAppNotificationEvent import net.thunderbird.feature.notification.api.receiver.InAppNotificationReceiver import net.thunderbird.feature.notification.api.sender.NotificationSender @PreviewLightDark Loading Loading @@ -47,6 +50,10 @@ private fun SecretDebugSettingsScreenPreview() { ): Flow<Outcome<Success<Notification>, Failure<Notification>>> = error("not implemented") }, notificationReceiver = object : InAppNotificationReceiver { override val events: SharedFlow<InAppNotificationEvent> get() = error("not implemented") }, ) } } WithContent { Loading
feature/debug-settings/src/debug/kotlin/net/thunderbird/feature/debug/settings/inject/FeatureDebugSettingsModule.kt +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ val featureDebugSettingsModule = module { stringsResourceManager = get(), accountManager = get(), notificationSender = get(), notificationReceiver = get(), ) } }
feature/debug-settings/src/main/kotlin/net/thunderbird/feature/debug/settings/notification/DebugNotificationSectionViewModel.kt +15 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toPersistentList import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import net.thunderbird.core.common.resources.StringsResourceManager Loading @@ -27,12 +28,14 @@ import net.thunderbird.feature.notification.api.content.MailNotification import net.thunderbird.feature.notification.api.content.Notification import net.thunderbird.feature.notification.api.content.PushServiceNotification import net.thunderbird.feature.notification.api.content.SystemNotification import net.thunderbird.feature.notification.api.receiver.InAppNotificationReceiver import net.thunderbird.feature.notification.api.sender.NotificationSender internal class DebugNotificationSectionViewModel( private val stringsResourceManager: StringsResourceManager, private val accountManager: AccountManager<BaseAccount>, private val notificationSender: NotificationSender, private val notificationReceiver: InAppNotificationReceiver, private val mainDispatcher: CoroutineDispatcher = Dispatchers.Main, ioDispatcher: CoroutineDispatcher = Dispatchers.IO, ) : BaseViewModel<State, Event, Effect>(initialState = State()), DebugNotificationSectionContract.ViewModel { Loading Loading @@ -76,6 +79,18 @@ internal class DebugNotificationSectionViewModel( } } } viewModelScope.launch { notificationReceiver .events .collectLatest { event -> updateState { state -> state.copy( notificationStatusLog = state.notificationStatusLog + " In-app notification event: $event", ) } } } } override fun event(event: Event) { Loading
feature/notification/api/build.gradle.kts +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.internal.config.LanguageFeature plugins { id(ThunderbirdPlugins.Library.kmpCompose) alias(libs.plugins.dev.mokkery) } kotlin { Loading
feature/notification/api/src/commonMain/kotlin/net/thunderbird/feature/notification/api/receiver/InAppNotificationReceiver.kt 0 → 100644 +19 −0 Original line number Diff line number Diff line package net.thunderbird.feature.notification.api.receiver import kotlinx.coroutines.flow.SharedFlow import net.thunderbird.feature.notification.api.content.InAppNotification /** * Interface for receiving in-app notification events. * * This interface provides a [SharedFlow] of [InAppNotificationEvent]s that can be observed * by UI components or other parts of the application to react to in-app notifications. */ interface InAppNotificationReceiver { val events: SharedFlow<InAppNotificationEvent> } sealed interface InAppNotificationEvent { data class Show(val notification: InAppNotification) : InAppNotificationEvent data class Dismiss(val notification: InAppNotification) : InAppNotificationEvent }