Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 800b41ab authored by Rafael Tonholo's avatar Rafael Tonholo
Browse files

refactor(notification): use suspend functions on NotificationCommand and NotificationNotifier

parent 2955b783
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ abstract class NotificationCommand<TNotification : Notification>(
     * Executes the command.
     * @return The result of the execution.
     */
    abstract fun execute(): Outcome<Success<TNotification>, Failure<TNotification>>
    abstract suspend fun execute(): Outcome<Success<TNotification>, Failure<TNotification>>

    /**
     * Represents the outcome of a command's execution.
+15 −1
Original line number Diff line number Diff line
package net.thunderbird.feature.notification.api.receiver

import net.thunderbird.feature.notification.api.NotificationId
import net.thunderbird.feature.notification.api.content.Notification

/**
@@ -10,5 +11,18 @@ import net.thunderbird.feature.notification.api.content.Notification
 * @param TNotification The type of notification to display.
 */
interface NotificationNotifier<in TNotification : Notification> {
    fun show(notification: TNotification)
    /**
     * Shows a notification to the user.
     *
     * @param id The notification id. Mostly used by System Notifications.
     * @param notification The notification to show.
     */
    suspend fun show(id: NotificationId, notification: TNotification)

    /**
     * Disposes of any resources used by the notifier.
     *
     * This should be called when the notifier is no longer needed to prevent memory leaks.
     */
    fun dispose()
}
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ internal class InAppNotificationCommand(
    notification: InAppNotification,
    notifier: NotificationNotifier<InAppNotification>,
) : NotificationCommand<InAppNotification>(notification, notifier) {
    override fun execute(): Outcome<Success<InAppNotification>, Failure<InAppNotification>> {
    override suspend fun execute(): Outcome<Success<InAppNotification>, Failure<InAppNotification>> {
        logger.debug {
            "TODO: Implementation on GitHub Issue #9245. Notification = $notification."
        }
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ internal class SystemNotificationCommand(
    notification: SystemNotification,
    notifier: NotificationNotifier<SystemNotification>,
) : NotificationCommand<SystemNotification>(notification, notifier) {
    override fun execute(): Outcome<Success<SystemNotification>, Failure<SystemNotification>> {
    override suspend fun execute(): Outcome<Success<SystemNotification>, Failure<SystemNotification>> {
        logger.debug {
            "TODO: Implementation on GitHub Issue #9245. Notification = $notification."
        }
+6 −1
Original line number Diff line number Diff line
package net.thunderbird.feature.notification.impl.receiver

import net.thunderbird.feature.notification.api.NotificationId
import net.thunderbird.feature.notification.api.content.InAppNotification
import net.thunderbird.feature.notification.api.receiver.NotificationNotifier

@@ -11,7 +12,11 @@ import net.thunderbird.feature.notification.api.receiver.NotificationNotifier
 * as part of GitHub Issue #9245.
 */
internal class InAppNotificationNotifier : NotificationNotifier<InAppNotification> {
    override fun show(notification: InAppNotification) {
    override suspend fun show(id: NotificationId, notification: InAppNotification) {
        TODO("Implementation on GitHub Issue #9245")
    }

    override fun dispose() {
        TODO("Implementation on GitHub Issue #9245")
    }
}
Loading