🐛 Fix new-sone handler
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 10 Dec 2019 15:50:49 +0000 (16:50 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 11 Dec 2019 15:59:15 +0000 (16:59 +0100)
src/main/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandler.kt
src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt

index a420f14..f47d456 100644 (file)
@@ -22,11 +22,12 @@ import net.pterodactylus.sone.core.event.*
 import net.pterodactylus.sone.data.*
 import net.pterodactylus.sone.notify.*
 import net.pterodactylus.util.notify.*
+import javax.inject.*
 
 /**
  * Notification handler for “new Sone discovered” events.
  */
-class NewSoneHandler(private val notificationManager: NotificationManager, private val notification: ListNotification<Sone>) {
+class NewSoneHandler @Inject constructor(private val notificationManager: NotificationManager, @Named("newSone") private val notification: ListNotification<Sone>) {
 
        @Subscribe
        fun newSoneFound(newSoneFoundEvent: NewSoneFoundEvent) {
index a9e4ae8..522e983 100644 (file)
@@ -38,6 +38,7 @@ class NotificationHandlerModule : AbstractModule() {
                bind(NotificationHandler::class.java).`in`(Singleton::class.java)
                bind<MarkPostKnownDuringFirstStartHandler>().asSingleton()
                bind<SoneLockedOnStartupHandler>().asSingleton()
+               bind<NewSoneHandler>().asSingleton()
        }
 
        @Provides
@@ -50,11 +51,6 @@ class NotificationHandlerModule : AbstractModule() {
                        ListNotification<Sone>("sone-locked-on-startup", "sones", loaders.loadTemplate("/templates/notify/soneLockedOnStartupNotification.html"))
 
        @Provides
-       @Singleton
-       fun getNewSoneHandler(notificationManager: NotificationManager, @Named("newSone") notification: ListNotification<Sone>) =
-                       NewSoneHandler(notificationManager, notification)
-
-       @Provides
        @Named("newSone")
        fun getNewSoneNotification(loaders: Loaders) =
                        ListNotification<Sone>("new-sone-notification", "sones", loaders.loadTemplate("/templates/notify/newSoneNotification.html"), dismissable = false)