mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
Video avatar fixes
This commit is contained in:
parent
9456d17b7c
commit
fd212e8c22
@ -24,7 +24,7 @@ public enum AvatarGalleryEntryId: Hashable {
|
|||||||
|
|
||||||
public enum AvatarGalleryEntry: Equatable {
|
public enum AvatarGalleryEntry: Equatable {
|
||||||
case topImage([ImageRepresentationWithReference], [VideoRepresentationWithReference], Peer?, GalleryItemIndexData?, Data?, String?)
|
case topImage([ImageRepresentationWithReference], [VideoRepresentationWithReference], Peer?, GalleryItemIndexData?, Data?, String?)
|
||||||
case image(MediaId, TelegramMediaImageReference?, [ImageRepresentationWithReference], [VideoRepresentationWithReference], Peer?, Int32, GalleryItemIndexData?, MessageId?, Data?, String?)
|
case image(MediaId, TelegramMediaImageReference?, [ImageRepresentationWithReference], [VideoRepresentationWithReference], Peer?, Int32?, GalleryItemIndexData?, MessageId?, Data?, String?)
|
||||||
|
|
||||||
public var id: AvatarGalleryEntryId {
|
public var id: AvatarGalleryEntryId {
|
||||||
switch self {
|
switch self {
|
||||||
@ -148,14 +148,10 @@ public func initialAvatarGalleryEntries(account: Account, peer: Peer) -> Signal<
|
|||||||
initialPhoto = photo
|
initialPhoto = photo
|
||||||
}
|
}
|
||||||
|
|
||||||
if let photo = initialPhoto, !photo.videoRepresentations.isEmpty {
|
if let photo = initialPhoto {
|
||||||
return [.topImage(photo.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatar(peer: peerReference, resource: $0.resource)) }), photo.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatar(peer: peerReference, resource: $0.resource)) }), peer, nil, photo.immediateThumbnailData, nil)]
|
return [.image(photo.imageId, photo.reference, photo.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatar(peer: peerReference, resource: $0.resource)) }), photo.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, nil, nil, nil, photo.immediateThumbnailData, nil)]
|
||||||
} else {
|
} else {
|
||||||
if !peer.profileImageRepresentations.isEmpty {
|
return []
|
||||||
return [.topImage(peer.profileImageRepresentations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatar(peer: peerReference, resource: $0.resource)) }), [], peer, nil, initialPhoto?.immediateThumbnailData, nil)]
|
|
||||||
} else {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -175,14 +171,42 @@ public func fetchedAvatarGalleryEntries(account: Account, peer: Peer) -> Signal<
|
|||||||
result = initialEntries
|
result = initialEntries
|
||||||
} else if let peerReference = PeerReference(peer) {
|
} else if let peerReference = PeerReference(peer) {
|
||||||
var index: Int32 = 0
|
var index: Int32 = 0
|
||||||
for photo in photos {
|
if [Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(peer.id.namespace) {
|
||||||
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photos.count))
|
var initialMediaIds = Set<MediaId>()
|
||||||
if result.isEmpty, let first = initialEntries.first {
|
for entry in initialEntries {
|
||||||
result.append(.image(photo.image.imageId, photo.image.reference, first.representations, photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
if case let .image(image) = entry {
|
||||||
} else {
|
initialMediaIds.insert(image.0)
|
||||||
result.append(.image(photo.image.imageId, photo.image.reference, photo.image.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var photosCount = photos.count
|
||||||
|
for i in 0 ..< photos.count {
|
||||||
|
let photo = photos[i]
|
||||||
|
if i == 0 && !initialMediaIds.contains(photo.image.imageId) {
|
||||||
|
photosCount += 1
|
||||||
|
for entry in initialEntries {
|
||||||
|
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photosCount))
|
||||||
|
if case let .image(image) = entry {
|
||||||
|
result.append(.image(image.0, image.1, image.2, image.3, image.4, nil, indexData, nil, image.8, nil))
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photosCount))
|
||||||
|
result.append(.image(photo.image.imageId, photo.image.reference, photo.image.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for photo in photos {
|
||||||
|
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photos.count))
|
||||||
|
if result.isEmpty, let first = initialEntries.first {
|
||||||
|
result.append(.image(photo.image.imageId, photo.image.reference, first.representations, photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
||||||
|
} else {
|
||||||
|
result.append(.image(photo.image.imageId, photo.image.reference, photo.image.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
||||||
|
}
|
||||||
|
index += 1
|
||||||
}
|
}
|
||||||
index += 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@ -203,14 +227,43 @@ public func fetchedAvatarGalleryEntries(account: Account, peer: Peer, firstEntry
|
|||||||
result = initialEntries
|
result = initialEntries
|
||||||
} else if let peerReference = PeerReference(peer) {
|
} else if let peerReference = PeerReference(peer) {
|
||||||
var index: Int32 = 0
|
var index: Int32 = 0
|
||||||
for photo in photos {
|
|
||||||
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photos.count))
|
if [Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(peer.id.namespace) {
|
||||||
if result.isEmpty, let first = initialEntries.first {
|
var initialMediaIds = Set<MediaId>()
|
||||||
result.append(.image(photo.image.imageId, photo.image.reference, first.representations, photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
for entry in initialEntries {
|
||||||
} else {
|
if case let .image(image) = entry {
|
||||||
result.append(.image(photo.image.imageId, photo.image.reference, photo.image.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
initialMediaIds.insert(image.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var photosCount = photos.count
|
||||||
|
for i in 0 ..< photos.count {
|
||||||
|
let photo = photos[i]
|
||||||
|
if i == 0 && !initialMediaIds.contains(photo.image.imageId) {
|
||||||
|
photosCount += 1
|
||||||
|
for entry in initialEntries {
|
||||||
|
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photosCount))
|
||||||
|
if case let .image(image) = entry {
|
||||||
|
result.append(.image(image.0, image.1, image.2, image.3, image.4, nil, indexData, nil, image.8, nil))
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photosCount))
|
||||||
|
result.append(.image(photo.image.imageId, photo.image.reference, photo.image.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for photo in photos {
|
||||||
|
let indexData = GalleryItemIndexData(position: index, totalCount: Int32(photos.count))
|
||||||
|
if result.isEmpty, let first = initialEntries.first {
|
||||||
|
result.append(.image(photo.image.imageId, photo.image.reference, first.representations, photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
||||||
|
} else {
|
||||||
|
result.append(.image(photo.image.imageId, photo.image.reference, photo.image.representations.map({ ImageRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), photo.image.videoRepresentations.map({ VideoRepresentationWithReference(representation: $0, reference: MediaResourceReference.avatarList(peer: peerReference, resource: $0.resource)) }), peer, photo.date, indexData, photo.messageId, photo.image.immediateThumbnailData, nil))
|
||||||
|
}
|
||||||
|
index += 1
|
||||||
}
|
}
|
||||||
index += 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -109,7 +109,9 @@ final class AvatarGalleryItemFooterContentNode: GalleryFooterContentNode {
|
|||||||
switch entry {
|
switch entry {
|
||||||
case let .image(_, _, _, videoRepresentations, peer, date, _, _, _, _):
|
case let .image(_, _, _, videoRepresentations, peer, date, _, _, _, _):
|
||||||
nameText = peer?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""
|
nameText = peer?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""
|
||||||
dateText = humanReadableStringForTimestamp(strings: self.strings, dateTimeFormat: self.dateTimeFormat, timestamp: date)
|
if let date = date {
|
||||||
|
dateText = humanReadableStringForTimestamp(strings: self.strings, dateTimeFormat: self.dateTimeFormat, timestamp: date)
|
||||||
|
}
|
||||||
|
|
||||||
if (!videoRepresentations.isEmpty) {
|
if (!videoRepresentations.isEmpty) {
|
||||||
typeText = self.strings.ProfilePhoto_MainVideo
|
typeText = self.strings.ProfilePhoto_MainVideo
|
||||||
|
|||||||
@ -217,12 +217,7 @@ final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
|||||||
private var statusPromise = Promise<(MediaPlayerStatus?, Double?)?>()
|
private var statusPromise = Promise<(MediaPlayerStatus?, Double?)?>()
|
||||||
var mediaStatus: Signal<(MediaPlayerStatus?, Double?)?, NoError> {
|
var mediaStatus: Signal<(MediaPlayerStatus?, Double?)?, NoError> {
|
||||||
get {
|
get {
|
||||||
if let videoNode = self.videoNode {
|
return self.statusPromise.get()
|
||||||
let videoStartTimestamp = self.videoStartTimestamp
|
|
||||||
return videoNode.status |> map { ($0, videoStartTimestamp) }
|
|
||||||
} else {
|
|
||||||
return self.statusPromise.get()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +302,6 @@ final class PeerInfoAvatarListItemNode: ASDisplayNode {
|
|||||||
if let playerStatus = self.playerStatus {
|
if let playerStatus = self.playerStatus {
|
||||||
if case let .buffering(_, _, progress) = playerStatus.status {
|
if case let .buffering(_, _, progress) = playerStatus.status {
|
||||||
bufferingProgress = progress
|
bufferingProgress = progress
|
||||||
print(progress)
|
|
||||||
} else if case .playing = playerStatus.status {
|
} else if case .playing = playerStatus.status {
|
||||||
bufferingProgress = nil
|
bufferingProgress = nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user