Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay

This commit is contained in:
Kelvin 2024-09-04 20:02:55 +02:00
commit e8007082a7
2 changed files with 26 additions and 18 deletions

View file

@ -235,6 +235,7 @@ class SettingsDev : FragmentedStorageFileJson() {
R.string.test_background_worker_description, 4)
fun triggerBackgroundUpdate() {
val act = SettingsActivity.getActivity()!!;
try {
UIDialogs.toast(SettingsActivity.getActivity()!!, "Starting test background worker");
val wm = WorkManager.getInstance(act);
@ -242,6 +243,9 @@ class SettingsDev : FragmentedStorageFileJson() {
.setInputData(Data.Builder().putBoolean("bypassMainCheck", true).build())
.build();
wm.enqueue(req);
} catch (e: Throwable) {
UIDialogs.showGeneralErrorDialog(act, "Failed to trigger background update", e)
}
}
@FormField(R.string.clear_channel_cache, FieldForm.BUTTON,
R.string.test_background_worker_description, 4)

View file

@ -627,6 +627,7 @@ class StateApp {
fun scheduleBackgroundWork(context: Context, active: Boolean = true, intervalMinutes: Int = 60 * 12) {
try {
val wm = WorkManager.getInstance(context);
if(active) {
@ -642,6 +643,9 @@ class StateApp {
}
else
wm.cancelAllWork();
} catch (e: Throwable) {
Logger.e(TAG, "Failed to schedule background subscription updates.", e)
}
}