aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-09-27 23:26:20 -0400
committerAllan Wang <me@allanwang.ca>2018-09-27 23:26:20 -0400
commit7e1b590c0381bee76b8ce5481c4d4640741b6b9e (patch)
tree00aadf5d5426419f40ae09870e89d9446ce15e7d /app/src/main/kotlin
parent857fe0a28ccb5b8f7f3caef4ecd477596fe2468c (diff)
downloadfrost-7e1b590c0381bee76b8ce5481c4d4640741b6b9e.tar.gz
frost-7e1b590c0381bee76b8ce5481c4d4640741b6b9e.tar.bz2
frost-7e1b590c0381bee76b8ce5481c4d4640741b6b9e.zip
Fix notif debug
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt1
2 files changed, 7 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 6d73b1c6..8a6b4a3f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
@@ -12,6 +12,7 @@ import android.support.v4.app.NotificationCompat
import android.support.v4.app.NotificationManagerCompat
import ca.allanwang.kau.utils.dpToPx
import ca.allanwang.kau.utils.string
+import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.FrostWebActivity
import com.pitchedapps.frost.dbflow.CookieModel
@@ -120,8 +121,10 @@ enum class NotificationType(
if (newLatestEpoch > prevLatestEpoch)
putTime(prevNotifTime, newLatestEpoch).save()
L.d { "Notif $name new epoch ${getTime(lastNotificationTime(userId))}" }
- if (prevLatestEpoch == -1L)
+ if (prevLatestEpoch == -1L && !BuildConfig.DEBUG) {
+ L.d { "Skipping first notification fetch" }
return 0 // do not notify the first time
+ }
frostEvent("Notifications", "Type" to name, "Count" to notifs.size)
if (notifs.size > 1)
summaryNotification(context, userId, notifs.size).notify(context)
@@ -146,7 +149,7 @@ enum class NotificationType(
/**
* Create and submit a new notification with the given [content]
*/
- private fun createNotification(context: Context, content: NotificationContent): FrostNotification {
+ private fun createNotification(context: Context, content: NotificationContent): FrostNotification =
with(content) {
val intent = Intent(context, FrostWebActivity::class.java)
intent.data = Uri.parse(href)
@@ -181,9 +184,8 @@ enum class NotificationType(
}
}
- return FrostNotification(group, notifId, notifBuilder)
+ FrostNotification(group, notifId, notifBuilder)
}
- }
/**
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 35dd9571..845ddc5a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -69,6 +69,7 @@ class NotificationService : JobService() {
notifCount += fetch(jobId, NotificationType.MESSAGE, it)
}
+ L.v { "Sent $notifCount notifications" }
if (notifCount == 0 && jobId == NOTIFICATION_JOB_NOW)
generalNotification(665, R.string.no_new_notifications, BuildConfig.DEBUG)