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

index 1127fea..0c2368a 100644 (file)
@@ -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<Post>) {
+class NewRemotePostHandler @Inject constructor(private val notificationManager: NotificationManager, @Named("newRemotePost") private val notification: ListNotification<Post>) {
 
        @Subscribe
        fun newPostFound(newPostFoundEvent: NewPostFoundEvent) {
index 522e983..c75cbc1 100644 (file)
@@ -39,6 +39,7 @@ class NotificationHandlerModule : AbstractModule() {
                bind<MarkPostKnownDuringFirstStartHandler>().asSingleton()
                bind<SoneLockedOnStartupHandler>().asSingleton()
                bind<NewSoneHandler>().asSingleton()
+               bind<NewRemotePostHandler>().asSingleton()
        }
 
        @Provides
@@ -57,11 +58,6 @@ class NotificationHandlerModule : AbstractModule() {
 
        @Provides
        @Singleton
-       fun getNewRemotePostHandler(notificationManager: NotificationManager, @Named("newRemotePost") newPostNotification: ListNotification<Post>) =
-                       NewRemotePostHandler(notificationManager, newPostNotification)
-
-       @Provides
-       @Singleton
        @Named("newRemotePost")
        fun getNewPostNotification(loaders: Loaders) =
                        ListNotification<Post>("new-post-notification", "posts", loaders.loadTemplate("/templates/notify/newPostNotification.html"), dismissable = false)