diff options
author | Allan Wang <me@allanwang.ca> | 2019-03-07 00:16:22 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-03-07 00:16:22 -0500 |
commit | e96160d7f7cf45cdb8673928ac9e2fbca63002bd (patch) | |
tree | b612663ae348d3ccad3c039c5285a669759aef12 | |
parent | 7f1f2247de1d61354adfd2cec011cc475a20f683 (diff) | |
download | frost-e96160d7f7cf45cdb8673928ac9e2fbca63002bd.tar.gz frost-e96160d7f7cf45cdb8673928ac9e2fbca63002bd.tar.bz2 frost-e96160d7f7cf45cdb8673928ac9e2fbca63002bd.zip |
Do not send notifications if db save fails
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt | 9 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt | 1 |
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) |