mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Video avatar fixes
This commit is contained in:
parent
d3f4e63c93
commit
2686879ea3
@ -215,12 +215,12 @@ public func fetchedAvatarGalleryEntries(account: Account, peer: Peer) -> Signal<
|
||||
}
|
||||
}
|
||||
|
||||
public func fetchedAvatarGalleryEntries(account: Account, peer: Peer, firstEntry: AvatarGalleryEntry) -> Signal<[AvatarGalleryEntry], NoError> {
|
||||
public func fetchedAvatarGalleryEntries(account: Account, peer: Peer, firstEntry: AvatarGalleryEntry) -> Signal<(Bool, [AvatarGalleryEntry]), NoError> {
|
||||
let initialEntries = [firstEntry]
|
||||
return Signal<[AvatarGalleryEntry], NoError>.single(initialEntries)
|
||||
return Signal<(Bool, [AvatarGalleryEntry]), NoError>.single((false, initialEntries))
|
||||
|> then(
|
||||
requestPeerPhotos(postbox: account.postbox, network: account.network, peerId: peer.id)
|
||||
|> map { photos -> [AvatarGalleryEntry] in
|
||||
|> map { photos -> (Bool, [AvatarGalleryEntry]) in
|
||||
var result: [AvatarGalleryEntry] = []
|
||||
let initialEntries = [firstEntry]
|
||||
if photos.isEmpty {
|
||||
@ -266,7 +266,7 @@ public func fetchedAvatarGalleryEntries(account: Account, peer: Peer, firstEntry
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
return (true, result)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -5124,7 +5124,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
if peerId.namespace == Namespaces.Peer.CloudUser {
|
||||
self.preloadAvatarDisposable.set((peerInfoProfilePhotosWithCache(context: context, peerId: peerId)
|
||||
|> mapToSignal { result -> Signal<Never, NoError> in
|
||||
|> mapToSignal { (complete, result) -> Signal<Never, NoError> in
|
||||
var signals: [Signal<Never, NoError>] = [.complete()]
|
||||
for i in 0 ..< min(1, result.count) {
|
||||
if let video = result[i].videoRepresentations.first {
|
||||
|
@ -328,14 +328,14 @@ private func peerInfoProfilePhotos(context: AccountContext, peerId: PeerId) -> S
|
||||
}
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
|> mapToSignal { firstEntry -> Signal<[AvatarGalleryEntry], NoError> in
|
||||
|> mapToSignal { firstEntry -> Signal<(Bool, [AvatarGalleryEntry]), NoError> in
|
||||
if let firstEntry = firstEntry {
|
||||
return context.account.postbox.loadedPeerWithId(peerId)
|
||||
|> mapToSignal { peer -> Signal<[AvatarGalleryEntry], NoError>in
|
||||
|> mapToSignal { peer -> Signal<(Bool, [AvatarGalleryEntry]), NoError>in
|
||||
return fetchedAvatarGalleryEntries(account: context.account, peer: peer, firstEntry: firstEntry)
|
||||
}
|
||||
} else {
|
||||
return .single([])
|
||||
return .single((true, []))
|
||||
}
|
||||
}
|
||||
|> map { items -> Any in
|
||||
@ -343,10 +343,10 @@ private func peerInfoProfilePhotos(context: AccountContext, peerId: PeerId) -> S
|
||||
}
|
||||
}
|
||||
|
||||
func peerInfoProfilePhotosWithCache(context: AccountContext, peerId: PeerId) -> Signal<[AvatarGalleryEntry], NoError> {
|
||||
func peerInfoProfilePhotosWithCache(context: AccountContext, peerId: PeerId) -> Signal<(Bool, [AvatarGalleryEntry]), NoError> {
|
||||
return context.peerChannelMemberCategoriesContextsManager.profilePhotos(postbox: context.account.postbox, network: context.account.network, peerId: peerId, fetch: peerInfoProfilePhotos(context: context, peerId: peerId))
|
||||
|> map { items -> [AvatarGalleryEntry] in
|
||||
return items as? [AvatarGalleryEntry] ?? []
|
||||
|> map { items -> (Bool, [AvatarGalleryEntry]) in
|
||||
return items as? (Bool, [AvatarGalleryEntry]) ?? (true, [])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,11 +203,11 @@ final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
||||
private let preloadDisposable = MetaDisposable()
|
||||
private let statusNode: RadialStatusNode
|
||||
|
||||
|
||||
private var playerStatus: MediaPlayerStatus?
|
||||
private var isLoading = ValuePromise<Bool>(false)
|
||||
private var loadingProgress = ValuePromise<Float?>(nil)
|
||||
private var loadingProgressDisposable = MetaDisposable()
|
||||
private var hasProgress = false
|
||||
|
||||
let isReady = Promise<Bool>()
|
||||
private var didSetReady: Bool = false
|
||||
@ -274,14 +274,25 @@ final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
||||
} else {
|
||||
return .single(value)
|
||||
}
|
||||
}, self.loadingProgress.get())).start(next: { [weak self] isLoading, progress in
|
||||
} |> distinctUntilChanged, self.loadingProgress.get() |> distinctUntilChanged)).start(next: { [weak self] isLoading, progress in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if isLoading, let progress = progress {
|
||||
strongSelf.hasProgress = true
|
||||
strongSelf.statusNode.transitionToState(.progress(color: .white, lineWidth: nil, value: CGFloat(max(0.027, progress)), cancelEnabled: false), completion: {})
|
||||
} else {
|
||||
strongSelf.statusNode.transitionToState(.none, completion: {})
|
||||
} else if strongSelf.hasProgress {
|
||||
strongSelf.hasProgress = false
|
||||
strongSelf.statusNode.transitionToState(.progress(color: .white, lineWidth: nil, value: 1.0, cancelEnabled: false), completion: { [weak self] in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if !strongSelf.hasProgress {
|
||||
Queue.mainQueue().after(0.3) {
|
||||
strongSelf.statusNode.transitionToState(.none, completion: {})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}))
|
||||
}
|
||||
@ -309,7 +320,6 @@ final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
||||
bufferingProgress = nil
|
||||
}
|
||||
}
|
||||
|
||||
self.loadingProgress.set(bufferingProgress)
|
||||
self.isLoading.set(bufferingProgress != nil)
|
||||
}
|
||||
@ -1043,12 +1053,12 @@ final class PeerInfoAvatarListContainerNode: ASDisplayNode {
|
||||
if let peer = peer, !self.initializedList {
|
||||
self.initializedList = true
|
||||
self.disposable.set((peerInfoProfilePhotosWithCache(context: self.context, peerId: peer.id)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] entries in
|
||||
|> deliverOnMainQueue).start(next: { [weak self] (complete, entries) in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
if strongSelf.galleryEntries.count > 1, entries.count == 1, let first = entries.first, case .topImage = first {
|
||||
if strongSelf.galleryEntries.count > 1, entries.count == 1 && !complete {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user