fix: importing backup doesn't immediately cancel/update notification worker

This commit is contained in:
Bnyro 2024-03-20 19:06:30 +01:00
parent 2fbc1361b2
commit fc894f5f63
2 changed files with 9 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import android.net.Uri
import android.util.Log
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import androidx.work.ExistingPeriodicWorkPolicy
import com.github.libretube.api.JsonHelper
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.db.DatabaseHolder.Database
@ -113,5 +114,8 @@ object BackupHelper {
}
}
}
// re-schedule the notification worker as some settings related to it might have changed
NotificationHelper.enqueueWork(context, ExistingPeriodicWorkPolicy.UPDATE)
}
}

View File

@ -24,11 +24,6 @@ object NotificationHelper {
true
)
val checkingFrequency = PreferenceHelper.getString(
PreferenceKeys.CHECKING_FREQUENCY,
"60"
).toLong()
// schedule the work manager request if logged in and notifications enabled
if (!notificationsEnabled) {
// cancel the work if notifications are disabled or the user is not logged in
@ -37,6 +32,11 @@ object NotificationHelper {
return
}
val checkingFrequency = PreferenceHelper.getString(
PreferenceKeys.CHECKING_FREQUENCY,
"60"
).toLong()
// required network type for the work
val networkType = when (
PreferenceHelper.getString(PreferenceKeys.REQUIRED_NETWORK, "all")