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<Sone>("new-sone-notification", "", template)
+class NewSoneHandler(private val notificationManager: NotificationManager, private val notification: ListNotification<Sone>) {
@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)
+ }
+
+}