1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-12 14:03:00 +01:00

Do not send notifications if db save fails

This commit is contained in:
Allan Wang 2019-03-07 00:16:22 -05:00
parent 7f1f2247de
commit e96160d7f7
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56
2 changed files with 6 additions and 4 deletions

View File

@ -155,12 +155,15 @@ 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" }
if (!notifDao.saveNotifications(channelId, newNotifContents)) {
L.d { "Skip notifs for $name as saving failed" }
return 0
}
val notifs = newNotifContents.map { createNotification(context, it) }
notifDao.saveNotifications(channelId, newNotifContents)
frostEvent("Notifications", "Type" to name, "Count" to notifs.size)
if (notifs.size > 1)
summaryNotification(context, userId, notifs.size).notify(context)

View File

@ -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)