From 50190b1431cba3cd9c961a9c8aca8252ad7d8b6a Mon Sep 17 00:00:00 2001 From: Igor Kravchenko Date: Wed, 13 Sep 2023 23:26:58 +0300 Subject: [PATCH] fixup! Fix visitor-on-hold and unread message count in bubble-view Add comments. --- GliaWidgets/Sources/Component/Bubble/BubbleView.swift | 7 +++++-- GliaWidgets/Sources/Component/Bubble/BubbleWindow.swift | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/GliaWidgets/Sources/Component/Bubble/BubbleView.swift b/GliaWidgets/Sources/Component/Bubble/BubbleView.swift index 6eccc7bc9..1f5d4bf27 100644 --- a/GliaWidgets/Sources/Component/Bubble/BubbleView.swift +++ b/GliaWidgets/Sources/Component/Bubble/BubbleView.swift @@ -64,7 +64,8 @@ class BubbleView: BaseView { func showOnHoldView() { onHoldView.removeFromSuperview() - + // In case of badge-view being shown + // place on-hold view under it. if let badgeView { insertSubview(onHoldView, belowSubview: badgeView) } else { @@ -147,7 +148,9 @@ class BubbleView: BaseView { private func setView(_ view: UIView) { subviews.first?.removeFromSuperview() view.isUserInteractionEnabled = false - + // Insert view at the zero index + // to be under other views, like on-hold + // and unread-count views. insertSubview(view, at: 0) view.layoutInSuperview().activate() } diff --git a/GliaWidgets/Sources/Component/Bubble/BubbleWindow.swift b/GliaWidgets/Sources/Component/Bubble/BubbleWindow.swift index 56c9fcf45..4848ece7f 100644 --- a/GliaWidgets/Sources/Component/Bubble/BubbleWindow.swift +++ b/GliaWidgets/Sources/Component/Bubble/BubbleWindow.swift @@ -107,6 +107,10 @@ private class BubbleViewController: UIViewController { right: edgeInset ) ) + // Once `bubbleView` is added to view hierarchy, + // we re-render it's `isVisitorOnHold` state, + // to properly display it. Otherwise it may + // not show up due to invalid ('zero') size. let isOnHold = bubbleView.isVisitorOnHold bubbleView.isVisitorOnHold = isOnHold }