From: David ‘Bombe’ Roden Date: Tue, 10 Dec 2019 15:55:07 +0000 (+0100) Subject: 🐛 Fix sone-locked handler X-Git-Tag: v81^2~5^2~66 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6d770b3aa761b4432517b4789a980c4ba75ed9fa;p=Sone.git 🐛 Fix sone-locked handler --- 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()