projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
3e2c50e
)
🐛 Don’t show notification for remote posts
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 8 Feb 2020 10:48:49 +0000
(11:48 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 8 Feb 2020 10:48:49 +0000
(11:48 +0100)
src/main/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandler.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
patch
|
blob
|
history
diff --git
a/src/main/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandler.kt
b/src/main/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandler.kt
index
a5153ce
..
cd78dd0
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandler.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandler.kt
@@
-33,9
+33,9
@@
class LocalPostHandler @Inject constructor(private val notificationManager: Noti
fun newPostFound(newPostFoundEvent: NewPostFoundEvent) {
newPostFoundEvent.post.onLocal { post ->
notification.add(post)
fun newPostFound(newPostFoundEvent: NewPostFoundEvent) {
newPostFoundEvent.post.onLocal { post ->
notification.add(post)
- }
- if (!notificationManager.hasFirstStartNotification()) {
- notificationManager.addNotification(notification)
+ if (!notificationManager.hasFirstStartNotification()) {
+ notificationManager.addNotification(notification)
+ }
}
}
}
}
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
index
45be33b
..
1d97ae8
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
@@
-54,15
+54,21
@@
class LocalPostHandlerTest {
}
@Test
}
@Test
- fun `handler
adds notification to manager
`() {
+ fun `handler
does not add notification to manager for post by remote sone
`() {
eventBus.post(NewPostFoundEvent(remotePost))
eventBus.post(NewPostFoundEvent(remotePost))
+ assertThat(notificationManager.notifications, not(hasItem<Notification>(notification)))
+ }
+
+ @Test
+ fun `handler adds notification to manager`() {
+ eventBus.post(NewPostFoundEvent(localPost))
assertThat(notificationManager.notifications, contains<Notification>(notification))
}
@Test
fun `handler does not add notification during first start`() {
notificationManager.firstStart()
assertThat(notificationManager.notifications, contains<Notification>(notification))
}
@Test
fun `handler does not add notification during first start`() {
notificationManager.firstStart()
- eventBus.post(NewPostFoundEvent(
remote
Post))
+ eventBus.post(NewPostFoundEvent(
local
Post))
assertThat(notificationManager.notifications, not(hasItem<Notification>(notification)))
}
assertThat(notificationManager.notifications, not(hasItem<Notification>(notification)))
}