1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-09-20 07:31:40 +02:00

Fix notif debug

This commit is contained in:
Allan Wang 2018-09-27 23:26:20 -04:00
parent 857fe0a28c
commit 7e1b590c03
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56
2 changed files with 7 additions and 4 deletions

View File

@ -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)
}
}
/**

View File

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