Fix issue #342 - set as unique

This commit is contained in:
Thomas 2022-10-07 11:34:20 +02:00
parent 9885aa2235
commit 6032870902
1 changed files with 3 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceManager;
import androidx.work.ExistingPeriodicWorkPolicy;
import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager;
@ -43,6 +44,7 @@ import app.fedilab.android.jobs.NotificationsWorker;
public class PushHelper {
public static void startStreaming(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -113,7 +115,7 @@ public class PushHelper {
PeriodicWorkRequest notificationPeriodic = new PeriodicWorkRequest.Builder(NotificationsWorker.class, Long.parseLong(value), TimeUnit.MINUTES)
.addTag(Helper.WORKER_REFRESH_NOTIFICATION)
.build();
WorkManager.getInstance(context).enqueue(notificationPeriodic);
WorkManager.getInstance(context).enqueueUniquePeriodicWork(Helper.WORKER_REFRESH_NOTIFICATION, ExistingPeriodicWorkPolicy.REPLACE, notificationPeriodic);
}