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,7 +11,12 @@ class SubscriptionNotificationWorker(appContext: Context, workerParams: WorkerPa
override suspend fun doWork(): Result {
Logger.log("SubscriptionNotificationWorker: doWork")
return if (AnilistNotificationTask().execute(applicationContext)) {
if (System.currentTimeMillis() - lastCheck < 60000) {
Logger.log("SubscriptionNotificationWorker: doWork skipped")
return Result.success()
}
lastCheck = System.currentTimeMillis()
return if (SubscriptionNotificationTask().execute(applicationContext)) {
Result.success()
} else {
Logger.log("SubscriptionNotificationWorker: doWork failed")
@@ -23,5 +28,6 @@ class SubscriptionNotificationWorker(appContext: Context, workerParams: WorkerPa
val checkIntervals = arrayOf(0L, 480, 720, 1440)
const val WORK_NAME =
"ani.dantotsu.notifications.subscription.SubscriptionNotificationWorker"
private var lastCheck = 0L
}
}