Fix template widgets that render null in websocket subscription (#2866)

Fix widgets that return null in websocket subscription

 - Just like in the preview, null is a valid result and should be handled by the app
This commit is contained in:
Joris Pelgröm 2022-09-10 21:18:10 +02:00 committed by GitHub
parent a31afb3455
commit 6756e21112
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View file

@ -286,7 +286,7 @@ class TemplateWidget : AppWidgetProvider() {
}
}
private fun onTemplateChanged(context: Context, appWidgetId: Int, template: String) {
private fun onTemplateChanged(context: Context, appWidgetId: Int, template: String?) {
widgetScope?.launch {
val views = getWidgetRemoteViews(context, appWidgetId, template)
AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, views)

View file

@ -15,7 +15,7 @@ interface IntegrationRepository {
suspend fun getNotificationRateLimits(): RateLimitResponse
suspend fun renderTemplate(template: String, variables: Map<String, String>): String?
suspend fun getTemplateUpdates(template: String): Flow<String>?
suspend fun getTemplateUpdates(template: String): Flow<String?>?
suspend fun updateLocation(updateLocation: UpdateLocation)

View file

@ -179,7 +179,7 @@ class IntegrationRepositoryImpl @Inject constructor(
else throw IntegrationException("Error calling integration request render_template")
}
override suspend fun getTemplateUpdates(template: String): Flow<String>? {
override suspend fun getTemplateUpdates(template: String): Flow<String?>? {
return webSocketRepository.getTemplateUpdates(template)
?.map {
it.result

View file

@ -4,6 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
@JsonIgnoreProperties(ignoreUnknown = true)
data class TemplateUpdatedEvent(
val result: String,
val result: String?,
val listeners: Map<String, Any>
)