aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-03-07 00:16:22 -0500
committerAllan Wang <me@allanwang.ca>2019-03-07 00:16:22 -0500
commite96160d7f7cf45cdb8673928ac9e2fbca63002bd (patch)
treeb612663ae348d3ccad3c039c5285a669759aef12 /app/src/main/kotlin/com/pitchedapps
parent7f1f2247de1d61354adfd2cec011cc475a20f683 (diff)
downloadfrost-e96160d7f7cf45cdb8673928ac9e2fbca63002bd.tar.gz
frost-e96160d7f7cf45cdb8673928ac9e2fbca63002bd.tar.bz2
frost-e96160d7f7cf45cdb8673928ac9e2fbca63002bd.zip
Do not send notifications if db save fails
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt9
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt1
2 files changed, 6 insertions, 4 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
index eb81ff04..14b6ec39 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
@@ -155,11 +155,14 @@ enum class NotificationType(
return 0
}
- L.d { "Notif $name new epoch ${newNotifContents.map { it.timestamp }.max()}" }
+ L.d { "${newNotifContents.size} new notifs found for $name" }
- val notifs = newNotifContents.map { createNotification(context, it) }
+ if (!notifDao.saveNotifications(channelId, newNotifContents)) {
+ L.d { "Skip notifs for $name as saving failed" }
+ return 0
+ }
- notifDao.saveNotifications(channelId, newNotifContents)
+ val notifs = newNotifContents.map { createNotification(context, it) }
frostEvent("Notifications", "Type" to name, "Count" to notifs.size)
if (notifs.size > 1)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
index e1db5fa6..8b100c19 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -45,7 +45,6 @@ import org.koin.android.ext.android.inject
class NotificationService : BaseJobService() {
val cookieDao: CookieDao by inject()
- val notifDao: NotificationDao by inject()
override fun onStopJob(params: JobParameters?): Boolean {
super.onStopJob(params)