X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fnotification%2FNewSoneHandler.kt;h=a420f14cbf7c380aa5584ac4cf7115d2f080fc90;hb=eb828bec5212bba8b9745f45defdc47711968ce6;hp=9ac6c28000a0f140fb38361d27a6799cde970530;hpb=188857148a7b035bfc6033b1fd40d774bd1fac65;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandler.kt b/src/main/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandler.kt index 9ac6c28..a420f14 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandler.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandler.kt @@ -22,24 +22,28 @@ import net.pterodactylus.sone.core.event.* import net.pterodactylus.sone.data.* import net.pterodactylus.sone.notify.* import net.pterodactylus.util.notify.* -import net.pterodactylus.util.template.* /** * Notification handler for “new Sone discovered” events. */ -class NewSoneHandler(private val notificationManager: NotificationManager, template: Template) { - - private val notification = ListNotification("new-sone-notification", "", template) +class NewSoneHandler(private val notificationManager: NotificationManager, private val notification: ListNotification) { @Subscribe fun newSoneFound(newSoneFoundEvent: NewSoneFoundEvent) { - if (!notificationManager.hasNotification("first-start-notification")) { + if (!notificationManager.hasFirstStartNotification()) { notification.add(newSoneFoundEvent.sone) notificationManager.addNotification(notification) } } -} + @Subscribe + fun markedSoneKnown(markSoneKnownEvent: MarkSoneKnownEvent) { + notification.remove(markSoneKnownEvent.sone) + } -private fun NotificationManager.hasNotification(id: String) = - getNotification(id) != null + @Subscribe + fun soneRemoved(soneRemovedEvent: SoneRemovedEvent) { + notification.remove(soneRemovedEvent.sone) + } + +}