mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
fixes
This commit is contained in:
parent
d39d4de2d4
commit
24b4827e0b
@ -42,8 +42,8 @@ object NotificationHelper {
|
||||
|
||||
val myWorkBuilder = PeriodicWorkRequest.Builder(
|
||||
NotificationWorker::class.java,
|
||||
1,
|
||||
TimeUnit.SECONDS
|
||||
checkingFrequency,
|
||||
TimeUnit.MINUTES
|
||||
)
|
||||
.setConstraints(constraints)
|
||||
|
||||
@ -70,6 +70,7 @@ object NotificationHelper {
|
||||
val task = async {
|
||||
RetrofitInstance.authApi.getFeed(token)
|
||||
}
|
||||
// fetch the users feed
|
||||
val videoFeed = try {
|
||||
task.await()
|
||||
} catch (e: Exception) {
|
||||
@ -87,6 +88,7 @@ object NotificationHelper {
|
||||
newStreamIndex = index
|
||||
}
|
||||
}
|
||||
if (newStreamIndex == -1) return@runBlocking
|
||||
val (title, description) = when (newStreamIndex) {
|
||||
// only one new stream available
|
||||
1 -> {
|
||||
|
@ -4,11 +4,16 @@ import android.content.Context
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
|
||||
/**
|
||||
* The notification worker which checks for new streams in a certain frequency
|
||||
*/
|
||||
class NotificationWorker(appContext: Context, parameters: WorkerParameters) : Worker(appContext, parameters) {
|
||||
private val TAG = "NotificationWorker"
|
||||
|
||||
override fun doWork(): Result {
|
||||
// schedule the next task of the worker
|
||||
NotificationHelper.enqueueWork(applicationContext)
|
||||
// check whether there are new streams and notify if there are some
|
||||
NotificationHelper.checkForNewStreams(applicationContext)
|
||||
return Result.success()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user