Skip to content

Commit 4de499b

Browse files
author
Isaac
committed
Update
1 parent 5f1eafa commit 4de499b

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContentLiveChatComponent.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ final class StoryContentLiveChatComponent: Component {
128128
private let pinnedBar = ComponentView<Empty>()
129129

130130
private let listState = AsyncListComponent.ExternalState()
131+
private var isScrollToBottomScheduled: Bool = false
131132
private let list = ComponentView<Empty>()
132133
private let listShadowView: UIView
133134

@@ -536,6 +537,10 @@ final class StoryContentLiveChatComponent: Component {
536537
}
537538
}
538539

540+
func scheduleScrollLiveChatToBottom() {
541+
self.isScrollToBottomScheduled = true
542+
}
543+
539544
func update(component: StoryContentLiveChatComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
540545
self.isUpdating = true
541546
defer {
@@ -727,6 +732,13 @@ final class StoryContentLiveChatComponent: Component {
727732
listTransition = listTransition.withAnimation(.none)
728733
}
729734

735+
if self.isScrollToBottomScheduled {
736+
self.isScrollToBottomScheduled = false
737+
if let firstItem = listItems.first {
738+
self.listState.resetScrolling(id: firstItem.id)
739+
}
740+
}
741+
730742
let _ = self.list.update(
731743
transition: listTransition,
732744
component: AnyComponent(AsyncListComponent(

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ final class StoryItemContentComponent: Component {
3737
let baseRate: Double
3838
let isVideoBuffering: Bool
3939
let isCurrent: Bool
40+
let isUIHidden: Bool
4041
let preferHighQuality: Bool
4142
let isEmbeddedInCamera: Bool
4243
let activateReaction: (UIView, MessageReaction.Reaction) -> Void
4344
let controller: () -> ViewController?
4445

45-
init(context: AccountContext, strings: PresentationStrings, peer: EnginePeer, item: EngineStoryItem, availableReactions: StoryAvailableReactions?, entityFiles: [MediaId: TelegramMediaFile], audioMode: StoryContentItem.AudioMode, baseRate: Double, isVideoBuffering: Bool, isCurrent: Bool, preferHighQuality: Bool, isEmbeddedInCamera: Bool, activateReaction: @escaping (UIView, MessageReaction.Reaction) -> Void, controller: @escaping () -> ViewController?) {
46+
init(context: AccountContext, strings: PresentationStrings, peer: EnginePeer, item: EngineStoryItem, availableReactions: StoryAvailableReactions?, entityFiles: [MediaId: TelegramMediaFile], audioMode: StoryContentItem.AudioMode, baseRate: Double, isVideoBuffering: Bool, isCurrent: Bool, isUIHidden: Bool, preferHighQuality: Bool, isEmbeddedInCamera: Bool, activateReaction: @escaping (UIView, MessageReaction.Reaction) -> Void, controller: @escaping () -> ViewController?) {
4647
self.context = context
4748
self.strings = strings
4849
self.peer = peer
@@ -53,6 +54,7 @@ final class StoryItemContentComponent: Component {
5354
self.baseRate = baseRate
5455
self.isVideoBuffering = isVideoBuffering
5556
self.isCurrent = isCurrent
57+
self.isUIHidden = isUIHidden
5658
self.preferHighQuality = preferHighQuality
5759
self.isEmbeddedInCamera = isEmbeddedInCamera
5860
self.activateReaction = activateReaction
@@ -87,6 +89,9 @@ final class StoryItemContentComponent: Component {
8789
if lhs.isCurrent != rhs.isCurrent {
8890
return false
8991
}
92+
if lhs.isUIHidden != rhs.isUIHidden {
93+
return false
94+
}
9095
if lhs.isEmbeddedInCamera != rhs.isEmbeddedInCamera {
9196
return false
9297
}
@@ -805,6 +810,13 @@ final class StoryItemContentComponent: Component {
805810
restorePictureInPictureImpl = dismissController()
806811
})
807812
}
813+
814+
func scheduleScrollLiveChatToBottom() {
815+
guard let liveChatView = self.liveChat?.view as? StoryContentLiveChatComponent.View else {
816+
return
817+
}
818+
liveChatView.scheduleScrollLiveChatToBottom()
819+
}
808820

809821
func update(component: StoryItemContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<StoryContentItem.Environment>, transition: ComponentTransition) -> CGSize {
810822
self.isUpdating = true
@@ -1018,9 +1030,11 @@ final class StoryItemContentComponent: Component {
10181030
if let liveChatView = liveChat.view {
10191031
if liveChatView.superview == nil {
10201032
liveChat.parentState = state
1033+
liveChatView.layer.allowsGroupOpacity = true
10211034
self.insertSubview(liveChatView, aboveSubview: self.imageView)
10221035
}
10231036
mediaStreamTransition.setFrame(view: liveChatView, frame: liveChatFrame)
1037+
mediaStreamTransition.setAlpha(view: liveChatView, alpha: component.isUIHidden ? 0.0 : 1.0)
10241038
}
10251039

10261040
if case .rtc = liveStream.kind, component.isEmbeddedInCamera {

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,7 @@ public final class StoryItemSetContainerComponent: Component {
16441644
baseRate: component.storyItemSharedState.baseRate,
16451645
isVideoBuffering: visibleItem.isBuffering,
16461646
isCurrent: index == centralIndex,
1647+
isUIHidden: component.hideUI,
16471648
preferHighQuality: component.slice.additionalPeerData.preferHighQualityStories,
16481649
isEmbeddedInCamera: component.isEmbeddedInCamera,
16491650
activateReaction: { [weak self] reactionView, reaction in

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ final class StoryItemSetContainerSendMessage: @unchecked(Sendable) {
764764
if !(visibleItemView.liveChatState?.isExpanded ?? true) {
765765
visibleItemView.toggleLiveChatExpanded()
766766
}
767+
visibleItemView.scheduleScrollLiveChatToBottom()
767768
}
768769

769770
let entities = generateChatInputTextEntities(text)

0 commit comments

Comments
 (0)