fix: notification check on app launch

This commit is contained in:
rebelonion 2024-03-22 22:34:21 -05:00
parent dca6ffdbbe
commit a189802061
7 changed files with 50 additions and 4 deletions

View file

@ -11,6 +11,11 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
CoroutineWorker(appContext, workerParams) {
override suspend fun doWork(): Result {
Logger.log("CommentNotificationWorker: doWork")
if (System.currentTimeMillis() - lastCheck < 60000) {
Logger.log("CommentNotificationWorker: doWork skipped")
return Result.success()
}
lastCheck = System.currentTimeMillis()
return if (CommentNotificationTask().execute(applicationContext)) {
Result.success()
} else {
@ -30,5 +35,6 @@ class CommentNotificationWorker(appContext: Context, workerParams: WorkerParamet
companion object {
val checkIntervals = arrayOf(0L, 480, 720, 1440)
const val WORK_NAME = "ani.dantotsu.notifications.comment.CommentNotificationWorker"
private var lastCheck = 0L
}
}