fix: notification check on app launch
This commit is contained in:
parent
dca6ffdbbe
commit
a189802061
7 changed files with 50 additions and 4 deletions
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue