From c47b9ee64d1d760703ade0e5612dfb2c817fd58e Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Fri, 27 Jan 2023 10:12:18 +0100 Subject: [PATCH] [TMP] Get widgets / stickers working again Change-Id: If24a0b93dc1d689ee68315ba068f0711c43979df --- .../im/vector/app/core/platform/VectorBaseFragment.kt | 11 +++++++++++ .../im/vector/app/features/widgets/WidgetFragment.kt | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt index 0c41673dd4..a74f480810 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt @@ -291,6 +291,17 @@ abstract class VectorBaseFragment : Fragment(), MavericksView } } + // SC-TODO: this is the pre-v1.5.18 implementation of observeViewEvents, to fix custom widgets. Revert me once upstream implements a fix. + protected fun VectorViewModel<*, *, T>.oldObserveViewEvents(observer: (T) -> Unit) { + val tag = this@VectorBaseFragment::class.simpleName.toString() + viewEvents + .stream(tag) + .onEach { + observer(it) + } + .launchIn(viewLifecycleOwner.lifecycleScope) + } + /* ========================================================================================== * Views * ========================================================================================== */ diff --git a/vector/src/main/java/im/vector/app/features/widgets/WidgetFragment.kt b/vector/src/main/java/im/vector/app/features/widgets/WidgetFragment.kt index 944ee627d7..b68daa8635 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/WidgetFragment.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/WidgetFragment.kt @@ -92,7 +92,7 @@ class WidgetFragment : if (fragmentArgs.kind.isAdmin()) { viewModel.getPostAPIMediator().setWebView(views.widgetWebView) } - viewModel.observeViewEvents { + viewModel.oldObserveViewEvents { Timber.v("Observed view events: $it") when (it) { is WidgetViewEvents.DisplayTerms -> displayTerms(it)