Various fixes

This commit is contained in:
Ilya Laktyushin 2024-10-14 21:38:35 +04:00
parent 25251fc9d4
commit 4f255424e5
5 changed files with 36 additions and 29 deletions

View File

@ -1708,11 +1708,10 @@ let setupFontFunctions = """
""" """
private let videoSource = """ private let videoSource = """
document.addEventListener('DOMContentLoaded', () => {
function tgBrowserDisableWebkitEnterFullscreen(videoElement) { function tgBrowserDisableWebkitEnterFullscreen(videoElement) {
if (videoElement && videoElement.webkitEnterFullscreen) { if (videoElement && videoElement.webkitEnterFullscreen) {
Object.defineProperty(videoElement, 'webkitEnterFullscreen', { videoElement.setAttribute('playsinline', '');
value: undefined
});
} }
} }
@ -1747,6 +1746,7 @@ _tgbrowser_observer.observe(document.body, {
function tgBrowserDisconnectObserver() { function tgBrowserDisconnectObserver() {
_tgbrowser_observer.disconnect(); _tgbrowser_observer.disconnect();
} }
});
""" """
let setupTouchObservers = let setupTouchObservers =

View File

@ -309,13 +309,16 @@ public func galleryItemForEntry(
} else { } else {
if let fileName = file.fileName, (fileName as NSString).pathExtension.lowercased() == "json" { if let fileName = file.fileName, (fileName as NSString).pathExtension.lowercased() == "json" {
return ChatAnimationGalleryItem(context: context, presentationData: presentationData, message: message, location: location) return ChatAnimationGalleryItem(context: context, presentationData: presentationData, message: message, location: location)
} } else if file.mimeType.hasPrefix("image/") && file.mimeType != "image/gif" {
else if file.mimeType.hasPrefix("image/") && file.mimeType != "image/gif" {
var pixelsCount: Int = 0 var pixelsCount: Int = 0
if let dimensions = file.dimensions { if let dimensions = file.dimensions {
pixelsCount = Int(dimensions.width) * Int(dimensions.height) pixelsCount = Int(dimensions.width) * Int(dimensions.height)
} }
if pixelsCount < 10000 * 10000 { var fileSize: Int64 = 0
if let size = file.size {
fileSize = size
}
if pixelsCount < 10000 * 10000 && fileSize < 16 * 1024 * 1024 {
return ChatImageGalleryItem( return ChatImageGalleryItem(
context: context, context: context,
presentationData: presentationData, presentationData: presentationData,

View File

@ -1283,8 +1283,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
} }
} }
recognizer.highlight = { [weak self] point in recognizer.highlight = { [weak self] point in
if let strongSelf = self { if let strongSelf = self, strongSelf.selectionNode == nil {
if strongSelf.selectionNode == nil {
if let replyInfoNode = strongSelf.replyInfoNode { if let replyInfoNode = strongSelf.replyInfoNode {
var translatedPoint: CGPoint? var translatedPoint: CGPoint?
let convertedNodeFrame = replyInfoNode.view.convert(replyInfoNode.bounds, to: strongSelf.view) let convertedNodeFrame = replyInfoNode.view.convert(replyInfoNode.bounds, to: strongSelf.view)
@ -1301,7 +1300,6 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
} }
forwardInfoNode.updateTouchesAtPoint(translatedPoint) forwardInfoNode.updateTouchesAtPoint(translatedPoint)
} }
}
for contentNode in strongSelf.contentNodes { for contentNode in strongSelf.contentNodes {
var translatedPoint: CGPoint? var translatedPoint: CGPoint?
let convertedNodeFrame = contentNode.view.convert(contentNode.bounds, to: strongSelf.view) let convertedNodeFrame = contentNode.view.convert(contentNode.bounds, to: strongSelf.view)
@ -5254,10 +5252,6 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
} }
if let selectionNode = self.selectionNode { if let selectionNode = self.selectionNode {
// if let replyInfoNode = self.replyInfoNode, replyInfoNode.frame.contains(point) {
// return replyInfoNode.view.hitTest(self.view.convert(point, to: replyInfoNode.view), with: event)
// }
if let result = self.traceSelectionNodes(parent: self, point: point.offsetBy(dx: -42.0, dy: 0.0)) { if let result = self.traceSelectionNodes(parent: self, point: point.offsetBy(dx: -42.0, dy: 0.0)) {
return result.view return result.view
} }

View File

@ -631,7 +631,17 @@ public final class MediaEditor {
let targetSize = isVideo ? CGSize(width: 128.0, height: 128.0) : CGSize(width: 1920.0, height: 1920.0) let targetSize = isVideo ? CGSize(width: 128.0, height: 128.0) : CGSize(width: 1920.0, height: 1920.0)
let options = PHImageRequestOptions() let options = PHImageRequestOptions()
options.deliveryMode = isVideo ? .fastFormat : .highQualityFormat let deliveryMode: PHImageRequestOptionsDeliveryMode
if isVideo {
if #available(iOS 14.0, *), PHPhotoLibrary.authorizationStatus(for: .readWrite) == .limited {
deliveryMode = .highQualityFormat
} else {
deliveryMode = .fastFormat
}
} else {
deliveryMode = .highQualityFormat
}
options.deliveryMode = deliveryMode
options.isNetworkAccessAllowed = true options.isNetworkAccessAllowed = true
let requestId = PHImageManager.default().requestImage( let requestId = PHImageManager.default().requestImage(