From b64fd393e96c8feefd80409166feaf403d4de15e Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 3 Feb 2023 17:42:50 +0100 Subject: [PATCH] Fix worker --- .../android/mastodon/jobs/FetchHomeWorker.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java b/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java index 148efed8..e17b6f5a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java +++ b/app/src/main/java/app/fedilab/android/mastodon/jobs/FetchHomeWorker.java @@ -81,8 +81,8 @@ public class FetchHomeWorker extends Worker { WorkManager.getInstance(context).cancelAllWorkByTag(Helper.WORKER_REFRESH_HOME + account.user_id + account.instance); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String value = prefs.getString(context.getString(R.string.SET_FETCH_HOME_DELAY_VALUE) + account.user_id + account.instance, "60"); - PeriodicWorkRequest notificationPeriodic = new PeriodicWorkRequest.Builder(NotificationsWorker.class, Long.parseLong(value), TimeUnit.MINUTES) - .addTag(Helper.WORKER_REFRESH_NOTIFICATION) + PeriodicWorkRequest notificationPeriodic = new PeriodicWorkRequest.Builder(FetchHomeWorker.class, Long.parseLong(value), TimeUnit.MINUTES) + .addTag(Helper.WORKER_REFRESH_HOME) .build(); WorkManager.getInstance(context).enqueueUniquePeriodicWork(Helper.WORKER_REFRESH_HOME + account.user_id + account.instance, ExistingPeriodicWorkPolicy.REPLACE, notificationPeriodic); } @@ -194,7 +194,7 @@ public class FetchHomeWorker extends Worker { } } catch (DBException e) { e.printStackTrace(); - failed++; + failed = -1; } } Pagination pagination = MastodonHelper.getPagination(homeResponse.headers()); @@ -202,13 +202,18 @@ public class FetchHomeWorker extends Worker { max_id = pagination.max_id; } else { canContinue = false; + failed = 4; } } else { + failed = 3; canContinue = false; } } else { canContinue = false; + failed = 2; } + } else { + failed = 1; } //Pause between calls (1 second) try {