diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index 9132cd168f..9af17c1444 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -1246,6 +1246,8 @@ public final class ChatListNode: ListView { self.animationRenderer = animationRenderer self.autoSetReady = autoSetReady + let isMainTab = chatListFilter == nil && location == .chatList(groupId: .root) + var isSelecting = false if case .peers(_, true, _, _, _, _) = mode { isSelecting = true @@ -1933,7 +1935,7 @@ public final class ChatListNode: ListView { notice = nil } - let (rawEntries, isLoading) = chatListNodeEntriesForView(view: update.list, state: state, savedMessagesPeer: savedMessagesPeer, foundPeers: state.foundPeers, hideArchivedFolderByDefault: hideArchivedFolderByDefault, displayArchiveIntro: displayArchiveIntro, notice: notice, mode: mode, chatListLocation: location, contacts: contacts, accountPeerId: accountPeerId) + let (rawEntries, isLoading) = chatListNodeEntriesForView(view: update.list, state: state, savedMessagesPeer: savedMessagesPeer, foundPeers: state.foundPeers, hideArchivedFolderByDefault: hideArchivedFolderByDefault, displayArchiveIntro: displayArchiveIntro, notice: notice, mode: mode, chatListLocation: location, contacts: contacts, accountPeerId: accountPeerId, isMainTab: isMainTab) var isEmpty = true var entries = rawEntries.filter { entry in switch entry { diff --git a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift index 0a155daf89..ae22930744 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift @@ -568,9 +568,9 @@ struct ChatListContactPeer { } } -func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState, savedMessagesPeer: EnginePeer?, foundPeers: [(EnginePeer, EnginePeer?)], hideArchivedFolderByDefault: Bool, displayArchiveIntro: Bool, notice: ChatListNotice?, mode: ChatListNodeMode, chatListLocation: ChatListControllerLocation, contacts: [ChatListContactPeer], accountPeerId: EnginePeer.Id) -> (entries: [ChatListNodeEntry], loading: Bool) { +func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState, savedMessagesPeer: EnginePeer?, foundPeers: [(EnginePeer, EnginePeer?)], hideArchivedFolderByDefault: Bool, displayArchiveIntro: Bool, notice: ChatListNotice?, mode: ChatListNodeMode, chatListLocation: ChatListControllerLocation, contacts: [ChatListContactPeer], accountPeerId: EnginePeer.Id, isMainTab: Bool) -> (entries: [ChatListNodeEntry], loading: Bool) { var groupItems = view.groupItems - if state.archiveStoryState != nil && groupItems.isEmpty { + if isMainTab && state.archiveStoryState != nil && groupItems.isEmpty { groupItems.append(EngineChatList.GroupItem( id: .archive, topMessage: nil, diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/OpenStories.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/OpenStories.swift index 4d8ba99e91..a67530f1dc 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/OpenStories.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/OpenStories.swift @@ -15,7 +15,7 @@ public extension StoryContainerScreen { |> mapToSignal { state -> Signal in if let slice = state.slice { return waitUntilStoryMediaPreloaded(context: context, peerId: slice.peer.id, storyItem: slice.item.storyItem) - |> timeout(2.0, queue: .mainQueue(), alternate: .complete()) + |> timeout(4.0, queue: .mainQueue(), alternate: .complete()) |> map { _ -> Void in } |> then(.single(Void())) @@ -171,7 +171,7 @@ public extension StoryContainerScreen { |> mapToSignal { state -> Signal in if let slice = state.slice { return waitUntilStoryMediaPreloaded(context: context, peerId: slice.peer.id, storyItem: slice.item.storyItem) - |> timeout(2.0, queue: .mainQueue(), alternate: .complete()) + |> timeout(4.0, queue: .mainQueue(), alternate: .complete()) |> map { _ -> StoryContentContextState in } |> then(.single(state)) diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift index c1e1494a02..b5a6af9573 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift @@ -1022,33 +1022,51 @@ private final class StoryContainerScreenComponent: Component { ) } - self.contentUpdatedDisposable?.dispose() var update = false - self.contentUpdatedDisposable = (component.content.updated - |> deliverOnMainQueue).start(next: { [weak self] _ in - guard let self, let component = self.component else { + + let contentUpdated: (StoryContainerScreenComponent) -> Void = { [weak self] component in + guard let self else { return } - if update { - var focusedItemId: StoryId? - var isVideo = false - if let slice = component.content.stateValue?.slice { - focusedItemId = StoryId(peerId: slice.peer.id, id: slice.item.storyItem.id) - if case .file = slice.item.storyItem.media { - isVideo = true - } + + var focusedItemId: StoryId? + var isVideo = false + if let slice = component.content.stateValue?.slice { + focusedItemId = StoryId(peerId: slice.peer.id, id: slice.item.storyItem.id) + if case .file = slice.item.storyItem.media { + isVideo = true } - self.focusedItem.set(focusedItemId) - - self.contentWantsVolumeButtonMonitoring.set(isVideo) - + } + self.focusedItem.set(focusedItemId) + self.contentWantsVolumeButtonMonitoring.set(isVideo) + + if update { if component.content.stateValue?.slice == nil { self.environment?.controller()?.dismiss() } else { self.state?.updated(transition: .immediate) } + } else { + DispatchQueue.main.async { [weak self] in + guard let self else { + return + } + self.state?.updated(transition: .immediate) + } } + } + + self.contentUpdatedDisposable?.dispose() + self.contentUpdatedDisposable = (component.content.updated + |> deliverOnMainQueue).start(next: { [weak self] _ in + guard let self, let component = self.component else { + return + } + contentUpdated(component) }) + if component.content.stateValue?.slice != nil { + contentUpdated(component) + } update = true } diff --git a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift index f032bebb98..69c720d610 100644 --- a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift @@ -148,12 +148,10 @@ private final class StoryProgressLayer: HierarchyTrackingLayer { self.uploadProgressLayer.fillColor = nil self.uploadProgressLayer.strokeColor = UIColor.white.cgColor - self.uploadProgressLayer.lineWidth = 2.0 self.uploadProgressLayer.lineCap = .round self.indefiniteDashLayer.fillColor = nil self.indefiniteDashLayer.strokeColor = UIColor.white.cgColor - self.indefiniteDashLayer.lineWidth = 2.0 self.indefiniteDashLayer.lineCap = .round self.indefiniteDashLayer.lineJoin = .round self.indefiniteDashLayer.strokeEnd = 0.0333 @@ -244,7 +242,7 @@ private final class StoryProgressLayer: HierarchyTrackingLayer { } } - func update(size: CGSize, lineWidth: CGFloat, value: Value, transition: Transition) { + func update(size: CGSize, lineWidth: CGFloat, radius: CGFloat, value: Value, transition: Transition) { let params = Params( size: size, lineWidth: lineWidth, @@ -255,18 +253,20 @@ private final class StoryProgressLayer: HierarchyTrackingLayer { } self.currentParams = params - let lineWidth: CGFloat = 2.0 + self.uploadProgressLayer.lineWidth = lineWidth + self.indefiniteDashLayer.lineWidth = lineWidth + let bounds = CGRect(origin: .zero, size: size) if self.uploadProgressLayer.path == nil { let path = CGMutablePath() - path.addEllipse(in: CGRect(origin: CGPoint(x: lineWidth * 0.5, y: lineWidth * 0.5), size: CGSize(width: size.width - lineWidth, height: size.height - lineWidth))) + path.addEllipse(in: CGRect(origin: CGPoint(x: (size.width - radius * 2.0) * 0.5, y: (size.height - radius * 2.0) * 0.5), size: CGSize(width: radius * 2.0, height: radius * 2.0))) self.uploadProgressLayer.path = path self.uploadProgressLayer.frame = bounds } if self.indefiniteDashLayer.path == nil { let path = CGMutablePath() - path.addEllipse(in: CGRect(origin: CGPoint(x: lineWidth * 0.5, y: lineWidth * 0.5), size: CGSize(width: size.width - lineWidth, height: size.height - lineWidth))) + path.addEllipse(in: CGRect(origin: CGPoint(x: (size.width - radius * 2.0) * 0.5, y: (size.height - radius * 2.0) * 0.5), size: CGSize(width: radius * 2.0, height: radius * 2.0))) self.indefiniteDashLayer.path = path self.indefiniteReplicatorLayer.frame = bounds self.indefiniteDashLayer.frame = bounds @@ -861,9 +861,9 @@ public final class StoryPeerListItemComponent: Component { } else { progressTransition = .easeInOut(duration: 0.3) } - progressLayer.update(size: progressFrame.size, lineWidth: indicatorLineUnseenWidth, value: .progress(progress), transition: progressTransition) + progressLayer.update(size: progressFrame.size, lineWidth: indicatorLineUnseenWidth, radius: indicatorRadius - indicatorLineUnseenWidth * 0.5, value: .progress(progress), transition: progressTransition) case .loading: - progressLayer.update(size: progressFrame.size, lineWidth: indicatorLineUnseenWidth, value: .indefinite, transition: transition) + progressLayer.update(size: progressFrame.size, lineWidth: indicatorLineUnseenWidth, radius: indicatorRadius - indicatorLineUnseenWidth * 0.5, value: .indefinite, transition: transition) } self.indicatorShapeSeenLayer.opacity = 0.0 self.indicatorShapeUnseenLayer.opacity = 0.0