mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Secret media improvements
This commit is contained in:
parent
28a5ce4e1f
commit
28dd60b887
@ -466,7 +466,7 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
|
||||
}
|
||||
}
|
||||
|
||||
public func setTimeout(_ timeout: Int32) {
|
||||
public func setTimeout(_ timeout: Int32, isVideo: Bool) {
|
||||
}
|
||||
|
||||
public func animate(_ view: UIView, frame: CGRect) {
|
||||
|
@ -631,7 +631,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
||||
func setMessage(_ message: Message, displayInfo: Bool = true, translateToLanguage: String? = nil, peerIsCopyProtected: Bool = false) {
|
||||
self.currentMessage = message
|
||||
|
||||
let canDelete: Bool
|
||||
var canDelete: Bool
|
||||
var canShare = !message.containsSecretMedia
|
||||
|
||||
var canFullscreen = false
|
||||
@ -715,6 +715,10 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
||||
canEdit = false
|
||||
}
|
||||
|
||||
if message.containsSecretMedia {
|
||||
canDelete = false
|
||||
}
|
||||
|
||||
var authorNameText: String?
|
||||
if let forwardInfo = message.forwardInfo, forwardInfo.flags.contains(.isImported), let authorSignature = forwardInfo.authorSignature {
|
||||
authorNameText = authorSignature
|
||||
|
@ -1344,7 +1344,9 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
strongSelf.isPlayingPromise.set(false)
|
||||
strongSelf.isPlaying = false
|
||||
if strongSelf.isCentral == true {
|
||||
strongSelf.updateControlsVisibility(true)
|
||||
if !item.isSecret {
|
||||
strongSelf.updateControlsVisibility(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -321,11 +321,13 @@ public final class SecretMediaPreviewController: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
var timerStarted = false
|
||||
let isOutgoing = !message.flags.contains(.Incoming)
|
||||
if let attribute = message.autoclearAttribute {
|
||||
strongSelf.currentNodeMessageIsViewOnce = attribute.timeout == viewOnceTimeout
|
||||
|
||||
if let countdownBeginTime = attribute.countdownBeginTime {
|
||||
timerStarted = true
|
||||
if let videoDuration = videoDuration, attribute.timeout != viewOnceTimeout {
|
||||
beginTimeAndTimeout = (CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, max(videoDuration, Double(attribute.timeout)), isOutgoing)
|
||||
} else {
|
||||
@ -338,6 +340,7 @@ public final class SecretMediaPreviewController: ViewController {
|
||||
strongSelf.currentNodeMessageIsViewOnce = attribute.timeout == viewOnceTimeout
|
||||
|
||||
if let countdownBeginTime = attribute.countdownBeginTime {
|
||||
timerStarted = true
|
||||
if let videoDuration = videoDuration, attribute.timeout != viewOnceTimeout {
|
||||
beginTimeAndTimeout = (CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, max(videoDuration, Double(attribute.timeout)), isOutgoing)
|
||||
} else {
|
||||
@ -370,12 +373,12 @@ public final class SecretMediaPreviewController: ViewController {
|
||||
strongSelf.controllerNode.beginTimeAndTimeout = beginTimeAndTimeout
|
||||
}
|
||||
|
||||
if strongSelf.currentNodeMessageIsVideo {
|
||||
if message.flags.contains(.Incoming) || strongSelf.currentNodeMessageIsVideo {
|
||||
if let node = strongSelf.controllerNode.pager.centralItemNode() {
|
||||
strongSelf.footerContentNode.set(node.footerContent())
|
||||
}
|
||||
} else if !message.flags.contains(.Incoming) {
|
||||
if let _ = beginTimeAndTimeout {
|
||||
} else {
|
||||
if timerStarted {
|
||||
strongSelf.controllerNode.updatePresentationState({
|
||||
$0.withUpdatedFooterContentNode(nil)
|
||||
}, transition: .immediate)
|
||||
|
@ -36,7 +36,7 @@
|
||||
- (void)setCaption:(NSAttributedString *)caption animated:(bool)animated;
|
||||
- (void)setCaptionPanelHidden:(bool)hidden animated:(bool)animated;
|
||||
|
||||
- (void)setTimeout:(int32_t)timeout;
|
||||
- (void)setTimeout:(int32_t)timeout isVideo:(bool)isVideo;
|
||||
|
||||
- (void)updateLayoutWithFrame:(CGRect)frame edgeInsets:(UIEdgeInsets)edgeInsets animated:(bool)animated;
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
@property (nonatomic, readonly) UIView * _Nonnull view;
|
||||
|
||||
- (void)setTimeout:(int32_t)timeout;
|
||||
- (void)setTimeout:(int32_t)timeout isVideo:(bool)isVideo;
|
||||
|
||||
- (NSAttributedString * _Nonnull)caption;
|
||||
- (void)setCaption:(NSAttributedString * _Nullable)caption;
|
||||
|
@ -838,7 +838,7 @@
|
||||
id<TGMediaEditAdjustments> adjustments = dict[@"adjustments"];
|
||||
NSNumber *timer = dict[@"timer"];
|
||||
|
||||
[strongSelf->_captionMixin setTimeout:[timer intValue]];
|
||||
[strongSelf->_captionMixin setTimeout:[timer intValue] isVideo:editableMediaItem.isVideo];
|
||||
|
||||
if ([adjustments isKindOfClass:[TGVideoEditAdjustments class]])
|
||||
{
|
||||
|
@ -141,8 +141,8 @@
|
||||
[_inputPanel setCaption:caption];
|
||||
}
|
||||
|
||||
- (void)setTimeout:(int32_t)timeout {
|
||||
[_inputPanel setTimeout:timeout];
|
||||
- (void)setTimeout:(int32_t)timeout isVideo:(bool)isVideo {
|
||||
[_inputPanel setTimeout:timeout isVideo:isVideo];
|
||||
}
|
||||
|
||||
- (void)setCaptionPanelHidden:(bool)hidden animated:(bool)__unused animated
|
||||
|
@ -32,6 +32,7 @@ swift_library(
|
||||
"//submodules/ItemListPeerItem:ItemListPeerItem",
|
||||
"//submodules/ItemListPeerActionItem:ItemListPeerActionItem",
|
||||
"//submodules/ContextUI:ContextUI",
|
||||
"//submodules/PremiumUI:PremiumUI",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -290,11 +290,15 @@ private func maybePredownloadedImageResource(postbox: Postbox, peerId: PeerId, r
|
||||
|> switchToLatest
|
||||
}
|
||||
|
||||
private func maybePredownloadedFileResource(postbox: Postbox, auxiliaryMethods: AccountAuxiliaryMethods, peerId: PeerId, resource: MediaResource, forceRefresh: Bool) -> Signal<PredownloadedResource, PendingMessageUploadError> {
|
||||
private func maybePredownloadedFileResource(postbox: Postbox, auxiliaryMethods: AccountAuxiliaryMethods, peerId: PeerId, resource: MediaResource, autoRemove: Bool, forceRefresh: Bool) -> Signal<PredownloadedResource, PendingMessageUploadError> {
|
||||
if peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
return .single(.none)
|
||||
}
|
||||
|
||||
if autoRemove {
|
||||
return .single(.none)
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
if !"".isEmpty {
|
||||
return .single(.none)
|
||||
@ -506,7 +510,13 @@ if "".isEmpty {
|
||||
if hasSpoiler {
|
||||
flags |= 1 << 1
|
||||
}
|
||||
return maybeCacheUploadedResource(postbox: postbox, key: referenceKey, result: .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaPhoto(flags: flags, id: .inputPhoto(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference)), ttlSeconds: ttlSeconds), text), reuploadInfo: nil, cacheReferenceKey: nil)), media: mediaImage)
|
||||
|
||||
let result: PendingMessageUploadedContentResult = .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaPhoto(flags: flags, id: .inputPhoto(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference)), ttlSeconds: ttlSeconds), text), reuploadInfo: nil, cacheReferenceKey: nil))
|
||||
if let _ = ttlSeconds {
|
||||
return .single(result)
|
||||
} else {
|
||||
return maybeCacheUploadedResource(postbox: postbox, key: referenceKey, result: result, media: mediaImage)
|
||||
}
|
||||
}
|
||||
default:
|
||||
break
|
||||
@ -656,7 +666,7 @@ public func statsCategoryForFileWithAttributes(_ attributes: [TelegramMediaFileA
|
||||
}
|
||||
|
||||
private func uploadedMediaFileContent(network: Network, postbox: Postbox, auxiliaryMethods: AccountAuxiliaryMethods, transformOutgoingMessageMedia: TransformOutgoingMessageMedia?, messageMediaPreuploadManager: MessageMediaPreuploadManager, forceReupload: Bool, isGrouped: Bool, passFetchProgress: Bool, forceNoBigParts: Bool, peerId: PeerId, messageId: MessageId?, text: String, attributes: [MessageAttribute], autoremoveMessageAttribute: AutoremoveTimeoutMessageAttribute?, autoclearMessageAttribute: AutoclearTimeoutMessageAttribute?, file: TelegramMediaFile) -> Signal<PendingMessageUploadedContentResult, PendingMessageUploadError> {
|
||||
return maybePredownloadedFileResource(postbox: postbox, auxiliaryMethods: auxiliaryMethods, peerId: peerId, resource: file.resource, forceRefresh: forceReupload)
|
||||
return maybePredownloadedFileResource(postbox: postbox, auxiliaryMethods: auxiliaryMethods, peerId: peerId, resource: file.resource, autoRemove: autoremoveMessageAttribute != nil || autoclearMessageAttribute != nil, forceRefresh: forceReupload)
|
||||
|> mapToSignal { result -> Signal<PendingMessageUploadedContentResult, PendingMessageUploadError> in
|
||||
var referenceKey: CachedSentMediaReferenceKey?
|
||||
switch result {
|
||||
@ -890,10 +900,21 @@ private func uploadedMediaFileContent(network: Network, postbox: Postbox, auxili
|
||||
case let .messageMediaDocument(_, document, _, _):
|
||||
if let document = document, let mediaFile = telegramMediaFileFromApiDocument(document), let resource = mediaFile.resource as? CloudDocumentMediaResource, let fileReference = resource.fileReference {
|
||||
var flags: Int32 = 0
|
||||
var ttlSeconds: Int32?
|
||||
if let autoclearMessageAttribute = autoclearMessageAttribute {
|
||||
flags |= 1 << 0
|
||||
ttlSeconds = autoclearMessageAttribute.timeout
|
||||
}
|
||||
if hasSpoiler {
|
||||
flags |= (1 << 2)
|
||||
}
|
||||
return maybeCacheUploadedResource(postbox: postbox, key: referenceKey, result: .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaDocument(flags: flags, id: .inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: fileReference)), ttlSeconds: nil, query: nil), text), reuploadInfo: nil, cacheReferenceKey: nil)), media: mediaFile)
|
||||
|
||||
let result: PendingMessageUploadedContentResult = .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaDocument(flags: flags, id: .inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: fileReference)), ttlSeconds: ttlSeconds, query: nil), text), reuploadInfo: nil, cacheReferenceKey: nil))
|
||||
if let _ = ttlSeconds {
|
||||
return .single(result)
|
||||
} else {
|
||||
return maybeCacheUploadedResource(postbox: postbox, key: referenceKey, result: result, media: mediaFile)
|
||||
}
|
||||
}
|
||||
default:
|
||||
break
|
||||
|
@ -31,6 +31,7 @@ public class LegacyMessageInputPanelNode: ASDisplayNode, TGCaptionPanelView {
|
||||
private var currentTimeout: Int32?
|
||||
private var currentIsEditing = false
|
||||
private var currentHeight: CGFloat?
|
||||
private var currentIsVideo = false
|
||||
|
||||
private let hapticFeedback = HapticFeedback()
|
||||
|
||||
@ -95,13 +96,14 @@ public class LegacyMessageInputPanelNode: ASDisplayNode, TGCaptionPanelView {
|
||||
transition.setFrame(view: view, frame: frame)
|
||||
}
|
||||
|
||||
public func setTimeout(_ timeout: Int32) {
|
||||
public func setTimeout(_ timeout: Int32, isVideo: Bool) {
|
||||
self.dismissTimeoutTooltip()
|
||||
var timeout: Int32? = timeout
|
||||
if timeout == 0 {
|
||||
timeout = nil
|
||||
}
|
||||
self.currentTimeout = timeout
|
||||
self.currentIsVideo = isVideo
|
||||
}
|
||||
|
||||
public func dismissInput() {
|
||||
@ -317,10 +319,13 @@ public class LegacyMessageInputPanelNode: ASDisplayNode, TGCaptionPanelView {
|
||||
|
||||
let updateTimeout: (Int32?) -> Void = { [weak self] timeout in
|
||||
if let self {
|
||||
let previousTimeout = self.currentTimeout
|
||||
self.currentTimeout = timeout
|
||||
self.timerUpdated?(timeout as? NSNumber)
|
||||
self.update(transition: .immediate)
|
||||
self.presentTimeoutTooltip(sourceView: sourceView, timeout: timeout)
|
||||
if previousTimeout != timeout {
|
||||
self.presentTimeoutTooltip(sourceView: sourceView, timeout: timeout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,7 +387,7 @@ public class LegacyMessageInputPanelNode: ASDisplayNode, TGCaptionPanelView {
|
||||
let absoluteFrame = sourceView.convert(sourceView.bounds, to: nil).offsetBy(dx: -parentFrame.minX, dy: 0.0)
|
||||
let location = CGRect(origin: CGPoint(x: absoluteFrame.midX, y: absoluteFrame.minY - 2.0), size: CGSize())
|
||||
|
||||
let isVideo = !"".isEmpty
|
||||
let isVideo = self.currentIsVideo
|
||||
let presentationData = self.context.sharedContext.currentPresentationData.with { $0 }
|
||||
let text: String
|
||||
let iconName: String
|
||||
|
Loading…
x
Reference in New Issue
Block a user