Fix custom sticker url loading (#8290)

This commit is contained in:
Yoan Pintas 2023-03-30 11:34:42 +02:00 committed by GitHub
parent ed121c051b
commit 93cd197c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

1
changelog.d/8026.bugfix Normal file
View File

@ -0,0 +1 @@
Maunium sticker picker loads indefinitely on new update

View File

@ -218,7 +218,7 @@ class WidgetFragment :
override fun invalidate() = withState(viewModel) { state -> override fun invalidate() = withState(viewModel) { state ->
Timber.v("Invalidate state: $state") Timber.v("Invalidate state: $state")
when (state.formattedURL) { when (val formattedUrl = state.formattedURL) {
Uninitialized, Uninitialized,
is Loading -> { is Loading -> {
setStateError(null) setStateError(null)
@ -227,6 +227,9 @@ class WidgetFragment :
views.widgetProgressBar.isVisible = true views.widgetProgressBar.isVisible = true
} }
is Success -> { is Success -> {
if (views.widgetWebView.url == null) {
loadFormattedUrl(formattedUrl())
}
setStateError(null) setStateError(null)
when (state.webviewLoadedUrl) { when (state.webviewLoadedUrl) {
Uninitialized -> { Uninitialized -> {
@ -253,7 +256,7 @@ class WidgetFragment :
// we need to show Error // we need to show Error
views.widgetWebView.isInvisible = true views.widgetWebView.isInvisible = true
views.widgetProgressBar.isVisible = false views.widgetProgressBar.isVisible = false
setStateError(state.formattedURL.error.message) setStateError(formattedUrl.error.message)
} }
} }
} }
@ -323,8 +326,12 @@ class WidgetFragment :
} }
private fun loadFormattedUrl(event: WidgetViewEvents.OnURLFormatted) { private fun loadFormattedUrl(event: WidgetViewEvents.OnURLFormatted) {
loadFormattedUrl(event.formattedURL)
}
private fun loadFormattedUrl(formattedUrl: String) {
views.widgetWebView.clearHistory() views.widgetWebView.clearHistory()
views.widgetWebView.loadUrl(event.formattedURL) views.widgetWebView.loadUrl(formattedUrl)
} }
private fun setStateError(message: String?) { private fun setStateError(message: String?) {