aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/db
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-05-09 20:15:04 +0800
committerAllan Wang <me@allanwang.ca>2019-05-09 20:15:04 +0800
commit971214bd5e2d770d44306dc9ec6ab78182762ba5 (patch)
tree18ffb48c3bd45687a97aab92b9301e5e10283859 /app/src/main/kotlin/com/pitchedapps/frost/db
parenta5a19290a876faca91c6c865c50350689f72c080 (diff)
downloadfrost-971214bd5e2d770d44306dc9ec6ab78182762ba5.tar.gz
frost-971214bd5e2d770d44306dc9ec6ab78182762ba5.tar.bz2
frost-971214bd5e2d770d44306dc9ec6ab78182762ba5.zip
Ensure notifications are always saved
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/db')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/db/NotificationDb.kt17
1 files changed, 7 insertions, 10 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/NotificationDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/NotificationDb.kt
index d4b51c1e..813c39a3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/db/NotificationDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/db/NotificationDb.kt
@@ -147,16 +147,13 @@ suspend fun NotificationDao.selectNotifications(userId: Long, type: String): Lis
/**
* Returns true if successful, given that there are constraints to the insertion
*/
-suspend fun NotificationDao.saveNotifications(type: String, notifs: List<NotificationContent>): Boolean {
- if (notifs.isEmpty()) return true
- return dao {
- try {
- _saveNotifications(type, notifs)
- true
- } catch (e: Exception) {
- L.e(e) { "Notif save failed for $type" }
- false
- }
+suspend fun NotificationDao.saveNotifications(type: String, notifs: List<NotificationContent>): Boolean = dao {
+ try {
+ _saveNotifications(type, notifs)
+ true
+ } catch (e: Exception) {
+ L.e(e) { "Notif save failed for $type" }
+ false
}
}