📄 Update year in file headers
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / notification / NewSoneHandler.kt
index 83be6fd..eb384c7 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Sone - NewSoneHandler.kt - Copyright © 2019 David ‘Bombe’ Roden
+ * Sone - NewSoneHandler.kt - Copyright © 2019–2020 David ‘Bombe’ Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,18 +22,16 @@ 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.*
+import javax.inject.*
 
 /**
  * Notification handler for “new Sone discovered” events.
  */
-class NewSoneHandler(private val notificationManager: NotificationManager, template: Template) {
-
-       private val notification = ListNotification<Sone>("new-sone-notification", "sones", template, dismissable = false)
+class NewSoneHandler @Inject constructor(private val notificationManager: NotificationManager, @Named("newSone") 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)
                }
@@ -50,6 +48,3 @@ class NewSoneHandler(private val notificationManager: NotificationManager, templ
        }
 
 }
-
-private fun NotificationManager.hasNotification(id: String) =
-               getNotification(id) != null