aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)