projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
♻️ Move image-insert notifications into handler
[Sone.git]
/
src
/
main
/
kotlin
/
net
/
pterodactylus
/
sone
/
web
/
notification
/
NewSoneHandler.kt
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandler.kt
b/src/main/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandler.kt
index
9ac6c28
..
f47d456
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandler.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandler.kt
@@
-22,24
+22,29
@@
import net.pterodactylus.sone.core.event.*
import net.pterodactylus.sone.data.*
import net.pterodactylus.sone.notify.*
import net.pterodactylus.util.notify.*
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.
*/
/**
* Notification handler for “new Sone discovered” events.
*/
-class NewSoneHandler(private val notificationManager: NotificationManager, template: Template) {
-
- private val notification = ListNotification<Sone>("new-sone-notification", "", template)
+class NewSoneHandler @Inject constructor(private val notificationManager: NotificationManager, @Named("newSone") private val notification: ListNotification<Sone>) {
@Subscribe
fun newSoneFound(newSoneFoundEvent: NewSoneFoundEvent) {
@Subscribe
fun newSoneFound(newSoneFoundEvent: NewSoneFoundEvent) {
- if (!notificationManager.has
Notification("first-start-notification"
)) {
+ if (!notificationManager.has
FirstStartNotification(
)) {
notification.add(newSoneFoundEvent.sone)
notificationManager.addNotification(notification)
}
}
notification.add(newSoneFoundEvent.sone)
notificationManager.addNotification(notification)
}
}
-}
+ @Subscribe
+ fun markedSoneKnown(markSoneKnownEvent: MarkSoneKnownEvent) {
+ notification.remove(markSoneKnownEvent.sone)
+ }
-private fun NotificationManager.hasNotification(id: String) =
- getNotification(id) != null
+ @Subscribe
+ fun soneRemoved(soneRemovedEvent: SoneRemovedEvent) {
+ notification.remove(soneRemovedEvent.sone)
+ }
+
+}