mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '047a0085c797b9e5cab24ec049d7f914ee71ddfc' into experiments/widgetkit-widget
This commit is contained in:
commit
6c36b09cbc
@ -49,10 +49,9 @@ final class ChatListSearchInteraction {
|
||||
let peerContextAction: ((Peer, ChatListSearchContextActionSource, ASDisplayNode, ContextGesture?) -> Void)?
|
||||
let present: (ViewController, Any?) -> Void
|
||||
let dismissInput: () -> Void
|
||||
let updateSuggestedPeers: ([Peer], ChatListSearchPaneKey) -> Void
|
||||
let getSelectedMessageIds: () -> Set<MessageId>?
|
||||
|
||||
init(openPeer: @escaping (Peer, Bool) -> Void, openDisabledPeer: @escaping (Peer) -> Void, openMessage: @escaping (Peer, MessageId, Bool) -> Void, openUrl: @escaping (String) -> Void, clearRecentSearch: @escaping () -> Void, addContact: @escaping (String) -> Void, toggleMessageSelection: @escaping (MessageId, Bool) -> Void, messageContextAction: @escaping ((Message, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void), mediaMessageContextAction: @escaping ((Message, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void), peerContextAction: ((Peer, ChatListSearchContextActionSource, ASDisplayNode, ContextGesture?) -> Void)?, present: @escaping (ViewController, Any?) -> Void, dismissInput: @escaping () -> Void, updateSuggestedPeers: @escaping ([Peer], ChatListSearchPaneKey) -> Void, getSelectedMessageIds: @escaping () -> Set<MessageId>?) {
|
||||
init(openPeer: @escaping (Peer, Bool) -> Void, openDisabledPeer: @escaping (Peer) -> Void, openMessage: @escaping (Peer, MessageId, Bool) -> Void, openUrl: @escaping (String) -> Void, clearRecentSearch: @escaping () -> Void, addContact: @escaping (String) -> Void, toggleMessageSelection: @escaping (MessageId, Bool) -> Void, messageContextAction: @escaping ((Message, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void), mediaMessageContextAction: @escaping ((Message, ASDisplayNode?, CGRect?, UIGestureRecognizer?) -> Void), peerContextAction: ((Peer, ChatListSearchContextActionSource, ASDisplayNode, ContextGesture?) -> Void)?, present: @escaping (ViewController, Any?) -> Void, dismissInput: @escaping () -> Void, getSelectedMessageIds: @escaping () -> Set<MessageId>?) {
|
||||
self.openPeer = openPeer
|
||||
self.openDisabledPeer = openDisabledPeer
|
||||
self.openMessage = openMessage
|
||||
@ -65,7 +64,6 @@ final class ChatListSearchInteraction {
|
||||
self.peerContextAction = peerContextAction
|
||||
self.present = present
|
||||
self.dismissInput = dismissInput
|
||||
self.updateSuggestedPeers = updateSuggestedPeers
|
||||
self.getSelectedMessageIds = getSelectedMessageIds
|
||||
}
|
||||
}
|
||||
@ -105,7 +103,6 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
||||
private var presentationDataDisposable: Disposable?
|
||||
|
||||
private let suggestedDates = Promise<[(Date?, Date, String?)]>([])
|
||||
private let suggestedPeers = Promise<[Peer]>([])
|
||||
private var suggestedFilters: [ChatListSearchFilter]?
|
||||
private let suggestedFiltersDisposable = MetaDisposable()
|
||||
|
||||
@ -219,10 +216,6 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
||||
present(c, a)
|
||||
}, dismissInput: { [weak self] in
|
||||
self?.dismissInput()
|
||||
}, updateSuggestedPeers: { [weak self] peers, key in
|
||||
if let strongSelf = self, key == .chats {
|
||||
strongSelf.suggestedPeers.set(.single(peers))
|
||||
}
|
||||
}, getSelectedMessageIds: { [weak self] () -> Set<MessageId>? in
|
||||
if let strongSelf = self {
|
||||
return strongSelf.stateValue.selectedMessageIds
|
||||
@ -337,7 +330,9 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
||||
if !peers.isEmpty && selectedFilter != .filter(ChatListSearchFilter.chats.id) {
|
||||
for peer in peers {
|
||||
let isGroup: Bool
|
||||
if let channel = peer as? TelegramChannel, case .group = channel.info {
|
||||
if peer.id.namespace == Namespaces.Peer.SecretChat {
|
||||
continue
|
||||
} else if let channel = peer as? TelegramChannel, case .group = channel.info {
|
||||
isGroup = true
|
||||
} else if peer.id.namespace == Namespaces.Peer.CloudGroup {
|
||||
isGroup = true
|
||||
|
@ -1378,10 +1378,6 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
||||
}
|
||||
}
|
||||
strongSelf.searchCurrentMessages = messages
|
||||
|
||||
if strongSelf.didSetReady && tagMask == nil {
|
||||
interaction.updateSuggestedPeers(Array(peers.prefix(8)), strongSelf.key)
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
|
@ -99,7 +99,8 @@ private let internalMimeTypes = Set<String>([
|
||||
private let internalMimePrefixes: [String] = [
|
||||
"image/jpeg",
|
||||
"image/jpg",
|
||||
"image/png"
|
||||
"image/png",
|
||||
"image/heic"
|
||||
]
|
||||
|
||||
public func internalDocumentItemSupportsMimeType(_ type: String, fileName: String?) -> Bool {
|
||||
|
@ -300,7 +300,7 @@
|
||||
fileName = asset.fileName;
|
||||
}
|
||||
|
||||
if (iosMajorVersion() >= 10 && [dataUTI rangeOfString:@"heic"].location != NSNotFound)
|
||||
if (iosMajorVersion() >= 10 && [asset.uniformTypeIdentifier rangeOfString:@"heic"].location != NSNotFound)
|
||||
{
|
||||
//#if !DEBUG
|
||||
CIContext *context = [[CIContext alloc] init];
|
||||
|
@ -753,7 +753,13 @@
|
||||
dict[@"asset"] = asset;
|
||||
dict[@"previewImage"] = image;
|
||||
dict[@"mimeType"] = TGMimeTypeForFileUTI(asset.uniformTypeIdentifier);
|
||||
dict[@"fileName"] = asset.fileName;
|
||||
|
||||
NSString *fileName = asset.fileName;
|
||||
NSRange range = [fileName.lowercaseString rangeOfString:@".heic"];
|
||||
if (range.location != NSNotFound)
|
||||
fileName = [fileName stringByReplacingCharactersInRange:range withString:@".JPG"];
|
||||
|
||||
dict[@"fileName"] = fileName;
|
||||
|
||||
if (groupedId != nil)
|
||||
dict[@"groupedId"] = groupedId;
|
||||
|
@ -167,20 +167,12 @@ public final class SearchDisplayController {
|
||||
contentNavigationBarHeight += 28.0
|
||||
}
|
||||
|
||||
let _ = (self.contentNode.ready()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
if !strongSelf.contentNode.hasDim {
|
||||
strongSelf.backgroundNode.alpha = 1.0
|
||||
strongSelf.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
|
||||
strongSelf.backgroundNode.layer.animateScale(from: 0.85, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
}
|
||||
})
|
||||
if !self.contentNode.hasDim {
|
||||
self.backgroundNode.alpha = 1.0
|
||||
self.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
|
||||
|
||||
self.backgroundNode.layer.animateScale(from: 0.85, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
|
||||
}
|
||||
|
||||
if !self.contentNode.hasDim {
|
||||
if let placeholder = placeholder {
|
||||
|
@ -355,6 +355,34 @@ public func preparedShareItems(account: Account, to peerId: PeerId, dataItems: [
|
||||
|
||||
public func sentShareItems(account: Account, to peerIds: [PeerId], items: [PreparedShareItemContent]) -> Signal<Float, Void> {
|
||||
var messages: [EnqueueMessage] = []
|
||||
var groupingKey: Int64?
|
||||
var mediaTypes: (photo: Bool, video: Bool, music: Bool, other: Bool) = (false, false, false, false)
|
||||
for item in items {
|
||||
if case let .media(result) = item, case let .media(media) = result {
|
||||
if media.media is TelegramMediaImage {
|
||||
mediaTypes.photo = true
|
||||
} else if let media = media.media as? TelegramMediaFile {
|
||||
if media.isVideo {
|
||||
mediaTypes.video = true
|
||||
} else if let fileName = media.fileName, fileName.hasPrefix("mp3") || fileName.hasPrefix("m4a") {
|
||||
mediaTypes.music = true
|
||||
} else {
|
||||
mediaTypes.other = true
|
||||
}
|
||||
} else {
|
||||
mediaTypes = (false, false, false, false)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mediaTypes.photo || mediaTypes.video) && !(mediaTypes.music || mediaTypes.other) {
|
||||
groupingKey = arc4random64()
|
||||
} else if !(mediaTypes.photo || mediaTypes.video) && (mediaTypes.music != mediaTypes.other) {
|
||||
groupingKey = arc4random64()
|
||||
}
|
||||
|
||||
var mediaMessages: [EnqueueMessage] = []
|
||||
for item in items {
|
||||
switch item {
|
||||
case let .text(text):
|
||||
@ -362,7 +390,13 @@ public func sentShareItems(account: Account, to peerIds: [PeerId], items: [Prepa
|
||||
case let .media(media):
|
||||
switch media {
|
||||
case let .media(reference):
|
||||
messages.append(.message(text: "", attributes: [], mediaReference: reference, replyToMessageId: nil, localGroupingKey: nil))
|
||||
let message: EnqueueMessage = .message(text: "", attributes: [], mediaReference: reference, replyToMessageId: nil, localGroupingKey: groupingKey)
|
||||
messages.append(message)
|
||||
mediaMessages.append(message)
|
||||
|
||||
}
|
||||
if let _ = groupingKey, mediaMessages.count % 10 == 0 {
|
||||
groupingKey = arc4random64()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user