Check if there are any widgets before connecting to websocket (#2079)

This commit is contained in:
Joris Pelgröm 2021-12-27 02:56:20 +01:00 committed by GitHub
parent 99a7ca1e56
commit b7d0ae7b2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,7 +13,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import javax.inject.Inject
@ -75,9 +74,11 @@ abstract class BaseWidgetProvider : AppWidgetProvider() {
return@launch
}
updateAllWidgets(context)
entityUpdates = integrationUseCase.getEntityUpdates()
entityUpdates!!.collect {
updateAllWidgets(context)
if (getAllWidgetIds(context).isNotEmpty()) {
entityUpdates = integrationUseCase.getEntityUpdates()
entityUpdates!!.collect {
updateAllWidgets(context)
}
}
}
}