aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt12
1 files changed, 7 insertions, 5 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 1c37bc29..4b0e1a82 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
@@ -137,10 +137,17 @@ enum class NotificationType(
validText(notif.title) && validText(notif.text)
}
if (notifContents.isEmpty()) return 0
+
val userId = data.id
// Legacy, remove with dbflow
val prevLatestEpoch = notifDao.latestEpoch(userId, channelId)
L.v { "Notif $name prev epoch $prevLatestEpoch" }
+
+ if (!notifDao.saveNotifications(channelId, notifContents)) {
+ L.d { "Skip notifs for $name as saving failed" }
+ return -1
+ }
+
if (prevLatestEpoch == -1L && !BuildConfig.DEBUG) {
L.d { "Skipping first notification fetch" }
return 0 // do not notify the first time
@@ -155,11 +162,6 @@ enum class NotificationType(
L.d { "${newNotifContents.size} new notifs found for $name" }
- if (!notifDao.saveNotifications(channelId, newNotifContents)) {
- L.d { "Skip notifs for $name as saving failed" }
- return 0
- }
-
val notifs = newNotifContents.map { createNotification(context, it) }
frostEvent("Notifications", "Type" to name, "Count" to notifs.size)