From 6d770b3aa761b4432517b4789a980c4ba75ed9fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 10 Dec 2019 16:55:07 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=90=9B=20Fix=20sone-locked=20handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sone/web/notification/NotificationHandlerModule.kt | 7 +++---- .../net/pterodactylus/sone/web/notification/SoneLockedHandler.kt | 6 +++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt b/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt index c75cbc1..7918758 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt @@ -23,7 +23,6 @@ import net.pterodactylus.sone.core.* import net.pterodactylus.sone.data.* import net.pterodactylus.sone.main.* import net.pterodactylus.sone.notify.* -import net.pterodactylus.util.notify.* import java.util.concurrent.Executors.* import java.util.function.* import javax.inject.* @@ -40,6 +39,7 @@ class NotificationHandlerModule : AbstractModule() { bind().asSingleton() bind().asSingleton() bind().asSingleton() + bind().asSingleton() } @Provides @@ -69,9 +69,8 @@ class NotificationHandlerModule : AbstractModule() { ListNotification("sones-locked-notification", "sones", loaders.loadTemplate("/templates/notify/lockedSonesNotification.html"), dismissable = true) @Provides - @Singleton - fun getSoneLockedHandler(notificationManager: NotificationManager, @Named("soneLocked") soneLockedNotification: ListNotification) = - SoneLockedHandler(notificationManager, soneLockedNotification, newScheduledThreadPool(1)) + fun getScheduledExecutorService() = + newScheduledThreadPool(1) private inline fun bind(): AnnotatedBindingBuilder = bind(T::class.java) private fun ScopedBindingBuilder.asSingleton() = `in`(Singleton::class.java) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandler.kt b/src/main/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandler.kt index 8bfbda4..583601b 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandler.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandler.kt @@ -24,12 +24,16 @@ import net.pterodactylus.sone.notify.* import net.pterodactylus.util.notify.* import java.util.concurrent.* import java.util.concurrent.atomic.* +import javax.inject.* /** * Handler for [SoneLockedEvent]s and [SoneUnlockedEvent]s that can schedule notifications after * a certain timeout. */ -class SoneLockedHandler(private val notificationManager: NotificationManager, private val notification: ListNotification, private val executor: ScheduledExecutorService) { +class SoneLockedHandler @Inject constructor( + private val notificationManager: NotificationManager, + @Named("soneLocked") private val notification: ListNotification, + private val executor: ScheduledExecutorService) { private val future: AtomicReference> = AtomicReference() -- 2.7.4