Various fixes

This commit is contained in:
Ilya Laktyushin 2022-04-20 14:04:39 +04:00
parent 78cc7c543a
commit e172502145
4 changed files with 148 additions and 85 deletions

View File

@ -105,6 +105,48 @@ public enum PeerInfoAvatarListItem: Equatable {
}
}
func isSemanticallyEqual(to: PeerInfoAvatarListItem) -> Bool {
if case let .topImage(lhsRepresentations, _, _) = self {
if case let .topImage(rhsRepresentations, _, _) = self {
if let lhsRepresentation = largestImageRepresentation(lhsRepresentations.map { $0.representation }),
let rhsRepresentation = largestImageRepresentation(rhsRepresentations.map { $0.representation }) {
return lhsRepresentation.isSemanticallyEqual(to: rhsRepresentation)
} else {
return false
}
} else if case let .image(_, rhsRepresentations, _, _) = self {
if let lhsRepresentation = largestImageRepresentation(lhsRepresentations.map { $0.representation }),
let rhsRepresentation = largestImageRepresentation(rhsRepresentations.map { $0.representation }) {
return lhsRepresentation.isSemanticallyEqual(to: rhsRepresentation)
} else {
return false
}
} else {
return false
}
} else if case let .image(_, lhsRepresentations, _, _) = self {
if case let .topImage(rhsRepresentations, _, _) = self {
if let lhsRepresentation = largestImageRepresentation(lhsRepresentations.map { $0.representation }),
let rhsRepresentation = largestImageRepresentation(rhsRepresentations.map { $0.representation }) {
return lhsRepresentation.isSemanticallyEqual(to: rhsRepresentation)
} else {
return false
}
} else if case let .image(_, rhsRepresentations, _, _) = self {
if let lhsRepresentation = largestImageRepresentation(lhsRepresentations.map { $0.representation }),
let rhsRepresentation = largestImageRepresentation(rhsRepresentations.map { $0.representation }) {
return lhsRepresentation.isSemanticallyEqual(to: rhsRepresentation)
} else {
return false
}
} else {
return false
}
} else {
return false
}
}
var representations: [ImageRepresentationWithReference] {
switch self {
case .custom:
@ -344,9 +386,15 @@ public final class PeerInfoAvatarListItemNode: ASDisplayNode {
}
func setup(item: PeerInfoAvatarListItem, isMain: Bool, progress: Signal<Float?, NoError>? = nil, synchronous: Bool, fullSizeOnly: Bool = false) {
let previousItem = self.item
self.item = item
self.progress = progress
var fullSizeOnly = fullSizeOnly
if let previousItem = previousItem, previousItem.isSemanticallyEqual(to: item) && self.didSetReady && isMain {
fullSizeOnly = true
}
if let progress = progress {
self.loadingProgress.set((progress
|> beforeNext { [weak self] next in
@ -1142,7 +1190,7 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode {
var additiveTransitionOffset: CGFloat = 0.0
var itemsAdded = false
if self.currentIndex >= 0 && self.currentIndex < self.items.count {
let preloadSpan: Int = 2
let preloadSpan: Int = 0
for i in max(0, self.currentIndex - preloadSpan) ... min(self.currentIndex + preloadSpan, self.items.count - 1) {
if self.items[i].representations.isEmpty {
continue

View File

@ -2343,7 +2343,7 @@ public func svgIconImageFile(account: Account, fileReference: FileMediaReference
}
}
private func avatarGalleryPhotoDatas(account: Account, fileReference: FileMediaReference? = nil, representations: [ImageRepresentationWithReference], immediateThumbnailData: Data?, autoFetchFullSize: Bool = false, attemptSynchronously: Bool = false) -> Signal<Tuple3<Data?, Data?, Bool>, NoError> {
private func avatarGalleryPhotoDatas(account: Account, fileReference: FileMediaReference? = nil, representations: [ImageRepresentationWithReference], immediateThumbnailData: Data?, autoFetchFullSize: Bool = false, attemptSynchronously: Bool = false, skipThumbnail: Bool = false) -> Signal<Tuple3<Data?, Data?, Bool>, NoError> {
if let smallestRepresentation = smallestImageRepresentation(representations.map({ $0.representation })), let largestRepresentation = largestImageRepresentation(representations.map({ $0.representation })), let smallestIndex = representations.firstIndex(where: { $0.representation == smallestRepresentation }), let largestIndex = representations.firstIndex(where: { $0.representation == largestRepresentation }) {
let maybeFullSize = account.postbox.mediaBox.resourceData(largestRepresentation.resource, attemptSynchronously: attemptSynchronously)
@ -2403,6 +2403,15 @@ private func avatarGalleryPhotoDatas(account: Account, fileReference: FileMediaR
}
}
if skipThumbnail {
return fullSizeData |> mapToSignal { value -> Signal <Tuple3<Data?, Data?, Bool>, NoError> in
if value._1 {
return .single(Tuple(nil, value._0, value._1))
} else {
return .complete()
}
}
} else {
return thumbnail |> mapToSignal { thumbnailData in
return fullSizeData |> map { value in
return Tuple(thumbnailData, value._0, value._1)
@ -2410,6 +2419,7 @@ private func avatarGalleryPhotoDatas(account: Account, fileReference: FileMediaR
}
}
}
}
return signal
} else {
@ -2418,7 +2428,7 @@ private func avatarGalleryPhotoDatas(account: Account, fileReference: FileMediaR
}
public func chatAvatarGalleryPhoto(account: Account, representations: [ImageRepresentationWithReference], immediateThumbnailData: Data?, autoFetchFullSize: Bool = false, attemptSynchronously: Bool = false, skipThumbnail: Bool = false, skipBlurIfLarge: Bool = false) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> {
let signal = avatarGalleryPhotoDatas(account: account, representations: representations, immediateThumbnailData: immediateThumbnailData, autoFetchFullSize: autoFetchFullSize, attemptSynchronously: attemptSynchronously)
let signal = avatarGalleryPhotoDatas(account: account, representations: representations, immediateThumbnailData: immediateThumbnailData, autoFetchFullSize: autoFetchFullSize, attemptSynchronously: attemptSynchronously, skipThumbnail: skipThumbnail)
return signal
|> map { value in

View File

@ -151,6 +151,9 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode {
self.messageDisposable.set((context.account.postbox.messagesAtIds(messageIds)
|> deliverOnMainQueue).start(next: { [weak self] messages in
if let strongSelf = self {
if messages.isEmpty {
strongSelf.dismiss?()
} else {
var authors = ""
var uniquePeerIds = Set<PeerId>()
var title = ""
@ -232,6 +235,7 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode {
}
})
}
}
}))
}

View File

@ -65,12 +65,13 @@ final class WebAppWebView: WKWebView {
configuration.userContentController = userController
configuration.allowsInlineMediaPlayback = true
configuration.allowsPictureInPictureMediaPlayback = false
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
configuration.mediaTypesRequiringUserActionForPlayback = []
configuration.mediaTypesRequiringUserActionForPlayback = .all
} else if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
configuration.requiresUserActionForMediaPlayback = false
configuration.requiresUserActionForMediaPlayback = true
} else {
configuration.mediaPlaybackRequiresUserAction = false
configuration.mediaPlaybackRequiresUserAction = true
}
super.init(frame: CGRect(), configuration: configuration)