This commit is contained in:
Ali 2023-07-11 17:17:56 +04:00
parent 6d7f74ecc3
commit e8b3615be6
5 changed files with 49 additions and 29 deletions

View File

@ -1246,6 +1246,8 @@ public final class ChatListNode: ListView {
self.animationRenderer = animationRenderer self.animationRenderer = animationRenderer
self.autoSetReady = autoSetReady self.autoSetReady = autoSetReady
let isMainTab = chatListFilter == nil && location == .chatList(groupId: .root)
var isSelecting = false var isSelecting = false
if case .peers(_, true, _, _, _, _) = mode { if case .peers(_, true, _, _, _, _) = mode {
isSelecting = true isSelecting = true
@ -1933,7 +1935,7 @@ public final class ChatListNode: ListView {
notice = nil 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 isEmpty = true
var entries = rawEntries.filter { entry in var entries = rawEntries.filter { entry in
switch entry { switch entry {

View File

@ -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 var groupItems = view.groupItems
if state.archiveStoryState != nil && groupItems.isEmpty { if isMainTab && state.archiveStoryState != nil && groupItems.isEmpty {
groupItems.append(EngineChatList.GroupItem( groupItems.append(EngineChatList.GroupItem(
id: .archive, id: .archive,
topMessage: nil, topMessage: nil,

View File

@ -15,7 +15,7 @@ public extension StoryContainerScreen {
|> mapToSignal { state -> Signal<Void, NoError> in |> mapToSignal { state -> Signal<Void, NoError> in
if let slice = state.slice { if let slice = state.slice {
return waitUntilStoryMediaPreloaded(context: context, peerId: slice.peer.id, storyItem: slice.item.storyItem) 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 |> map { _ -> Void in
} }
|> then(.single(Void())) |> then(.single(Void()))
@ -171,7 +171,7 @@ public extension StoryContainerScreen {
|> mapToSignal { state -> Signal<StoryContentContextState, NoError> in |> mapToSignal { state -> Signal<StoryContentContextState, NoError> in
if let slice = state.slice { if let slice = state.slice {
return waitUntilStoryMediaPreloaded(context: context, peerId: slice.peer.id, storyItem: slice.item.storyItem) 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 |> map { _ -> StoryContentContextState in
} }
|> then(.single(state)) |> then(.single(state))

View File

@ -1022,14 +1022,13 @@ private final class StoryContainerScreenComponent: Component {
) )
} }
self.contentUpdatedDisposable?.dispose()
var update = false var update = false
self.contentUpdatedDisposable = (component.content.updated
|> deliverOnMainQueue).start(next: { [weak self] _ in let contentUpdated: (StoryContainerScreenComponent) -> Void = { [weak self] component in
guard let self, let component = self.component else { guard let self else {
return return
} }
if update {
var focusedItemId: StoryId? var focusedItemId: StoryId?
var isVideo = false var isVideo = false
if let slice = component.content.stateValue?.slice { if let slice = component.content.stateValue?.slice {
@ -1039,16 +1038,35 @@ private final class StoryContainerScreenComponent: Component {
} }
} }
self.focusedItem.set(focusedItemId) self.focusedItem.set(focusedItemId)
self.contentWantsVolumeButtonMonitoring.set(isVideo) self.contentWantsVolumeButtonMonitoring.set(isVideo)
if update {
if component.content.stateValue?.slice == nil { if component.content.stateValue?.slice == nil {
self.environment?.controller()?.dismiss() self.environment?.controller()?.dismiss()
} else { } else {
self.state?.updated(transition: .immediate) 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 update = true
} }

View File

@ -148,12 +148,10 @@ private final class StoryProgressLayer: HierarchyTrackingLayer {
self.uploadProgressLayer.fillColor = nil self.uploadProgressLayer.fillColor = nil
self.uploadProgressLayer.strokeColor = UIColor.white.cgColor self.uploadProgressLayer.strokeColor = UIColor.white.cgColor
self.uploadProgressLayer.lineWidth = 2.0
self.uploadProgressLayer.lineCap = .round self.uploadProgressLayer.lineCap = .round
self.indefiniteDashLayer.fillColor = nil self.indefiniteDashLayer.fillColor = nil
self.indefiniteDashLayer.strokeColor = UIColor.white.cgColor self.indefiniteDashLayer.strokeColor = UIColor.white.cgColor
self.indefiniteDashLayer.lineWidth = 2.0
self.indefiniteDashLayer.lineCap = .round self.indefiniteDashLayer.lineCap = .round
self.indefiniteDashLayer.lineJoin = .round self.indefiniteDashLayer.lineJoin = .round
self.indefiniteDashLayer.strokeEnd = 0.0333 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( let params = Params(
size: size, size: size,
lineWidth: lineWidth, lineWidth: lineWidth,
@ -255,18 +253,20 @@ private final class StoryProgressLayer: HierarchyTrackingLayer {
} }
self.currentParams = params self.currentParams = params
let lineWidth: CGFloat = 2.0 self.uploadProgressLayer.lineWidth = lineWidth
self.indefiniteDashLayer.lineWidth = lineWidth
let bounds = CGRect(origin: .zero, size: size) let bounds = CGRect(origin: .zero, size: size)
if self.uploadProgressLayer.path == nil { if self.uploadProgressLayer.path == nil {
let path = CGMutablePath() 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.path = path
self.uploadProgressLayer.frame = bounds self.uploadProgressLayer.frame = bounds
} }
if self.indefiniteDashLayer.path == nil { if self.indefiniteDashLayer.path == nil {
let path = CGMutablePath() 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.indefiniteDashLayer.path = path
self.indefiniteReplicatorLayer.frame = bounds self.indefiniteReplicatorLayer.frame = bounds
self.indefiniteDashLayer.frame = bounds self.indefiniteDashLayer.frame = bounds
@ -861,9 +861,9 @@ public final class StoryPeerListItemComponent: Component {
} else { } else {
progressTransition = .easeInOut(duration: 0.3) 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: 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.indicatorShapeSeenLayer.opacity = 0.0
self.indicatorShapeUnseenLayer.opacity = 0.0 self.indicatorShapeUnseenLayer.opacity = 0.0