X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fnotification%2FNewRemotePostHandler.kt;h=6efff854334cd8bdd085ba035b268a2c845be286;hp=1127feafb82e6ef0ecbeb3119388787fecc02e92;hb=5aaa1e1dc761fa0c8b6745b7b022c0a19d248c68;hpb=b9320b57631d90d344edeb2a86c61db00ac50911 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/notification/NewRemotePostHandler.kt b/src/main/kotlin/net/pterodactylus/sone/web/notification/NewRemotePostHandler.kt index 1127fea..6efff85 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/NewRemotePostHandler.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/NewRemotePostHandler.kt @@ -22,12 +22,13 @@ import net.pterodactylus.sone.core.event.* import net.pterodactylus.sone.data.* import net.pterodactylus.sone.notify.* import net.pterodactylus.util.notify.* +import javax.inject.* /** * Handler for [NewPostFoundEvent]s that adds the new post to the “new posts” notification and * displays the notification if the “first start” notification is not being shown. */ -class NewRemotePostHandler(private val notificationManager: NotificationManager, private val notification: ListNotification) { +class NewRemotePostHandler @Inject constructor(private val notificationManager: NotificationManager, @Named("newRemotePost") private val notification: ListNotification) { @Subscribe fun newPostFound(newPostFoundEvent: NewPostFoundEvent) { @@ -39,4 +40,14 @@ class NewRemotePostHandler(private val notificationManager: NotificationManager, } } + @Subscribe + fun postRemoved(event: PostRemovedEvent) { + notification.remove(event.post) + } + + @Subscribe + fun postMarkedKnown(event: MarkPostKnownEvent) { + notification.remove(event.post) + } + }