mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Don't mark messages as read when something is covering the chat screen
This commit is contained in:
parent
38f6adeda1
commit
5149253333
@ -20,8 +20,9 @@ public final class GalleryControllerActionInteraction {
|
|||||||
public let addContact: (String) -> Void
|
public let addContact: (String) -> Void
|
||||||
public let storeMediaPlaybackState: (MessageId, Double?, Double) -> Void
|
public let storeMediaPlaybackState: (MessageId, Double?, Double) -> Void
|
||||||
public let editMedia: (MessageId, [UIView], @escaping () -> Void) -> Void
|
public let editMedia: (MessageId, [UIView], @escaping () -> Void) -> Void
|
||||||
|
public let updateCanReadHistory: (Bool) -> Void
|
||||||
|
|
||||||
public init(openUrl: @escaping (String, Bool) -> Void, openUrlIn: @escaping (String) -> Void, openPeerMention: @escaping (String) -> Void, openPeer: @escaping (EnginePeer) -> Void, openHashtag: @escaping (String?, String) -> Void, openBotCommand: @escaping (String) -> Void, addContact: @escaping (String) -> Void, storeMediaPlaybackState: @escaping (MessageId, Double?, Double) -> Void, editMedia: @escaping (MessageId, [UIView], @escaping () -> Void) -> Void) {
|
public init(openUrl: @escaping (String, Bool) -> Void, openUrlIn: @escaping (String) -> Void, openPeerMention: @escaping (String) -> Void, openPeer: @escaping (EnginePeer) -> Void, openHashtag: @escaping (String?, String) -> Void, openBotCommand: @escaping (String) -> Void, addContact: @escaping (String) -> Void, storeMediaPlaybackState: @escaping (MessageId, Double?, Double) -> Void, editMedia: @escaping (MessageId, [UIView], @escaping () -> Void) -> Void, updateCanReadHistory: @escaping (Bool) -> Void) {
|
||||||
self.openUrl = openUrl
|
self.openUrl = openUrl
|
||||||
self.openUrlIn = openUrlIn
|
self.openUrlIn = openUrlIn
|
||||||
self.openPeerMention = openPeerMention
|
self.openPeerMention = openPeerMention
|
||||||
@ -31,5 +32,6 @@ public final class GalleryControllerActionInteraction {
|
|||||||
self.addContact = addContact
|
self.addContact = addContact
|
||||||
self.storeMediaPlaybackState = storeMediaPlaybackState
|
self.storeMediaPlaybackState = storeMediaPlaybackState
|
||||||
self.editMedia = editMedia
|
self.editMedia = editMedia
|
||||||
|
self.updateCanReadHistory = updateCanReadHistory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1153,6 +1153,7 @@ public class GalleryController: ViewController, StandalonePresentableController,
|
|||||||
|
|
||||||
let completion = { [weak self] in
|
let completion = { [weak self] in
|
||||||
if animatedOutNode && animatedOutInterface {
|
if animatedOutNode && animatedOutInterface {
|
||||||
|
self?.actionInteraction?.updateCanReadHistory(true)
|
||||||
self?._hiddenMedia.set(.single(nil))
|
self?._hiddenMedia.set(.single(nil))
|
||||||
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
||||||
}
|
}
|
||||||
@ -1228,12 +1229,14 @@ public class GalleryController: ViewController, StandalonePresentableController,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
self.galleryNode.dismiss = { [weak self] in
|
self.galleryNode.dismiss = { [weak self] in
|
||||||
|
self?.actionInteraction?.updateCanReadHistory(true)
|
||||||
self?._hiddenMedia.set(.single(nil))
|
self?._hiddenMedia.set(.single(nil))
|
||||||
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.galleryNode.beginCustomDismiss = { [weak self] simpleAnimation in
|
self.galleryNode.beginCustomDismiss = { [weak self] simpleAnimation in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
|
strongSelf.actionInteraction?.updateCanReadHistory(true)
|
||||||
strongSelf._hiddenMedia.set(.single(nil))
|
strongSelf._hiddenMedia.set(.single(nil))
|
||||||
|
|
||||||
let animatedOutNode = !simpleAnimation
|
let animatedOutNode = !simpleAnimation
|
||||||
@ -1513,6 +1516,8 @@ public class GalleryController: ViewController, StandalonePresentableController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.accountInUseDisposable.set(self.context.sharedContext.setAccountUserInterfaceInUse(self.context.account.id))
|
self.accountInUseDisposable.set(self.context.sharedContext.setAccountUserInterfaceInUse(self.context.account.id))
|
||||||
|
|
||||||
|
self.actionInteraction?.updateCanReadHistory(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func didAppearInContextPreview() {
|
override public func didAppearInContextPreview() {
|
||||||
|
@ -2793,11 +2793,8 @@ final class StorageUsageScreenComponent: Component {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let _ = self
|
let _ = self
|
||||||
}, editMedia: { [weak self] messageId, snapshots, transitionCompletion in
|
}, editMedia: { _, _, _ in
|
||||||
guard let self else {
|
}, updateCanReadHistory: { _ in
|
||||||
return
|
|
||||||
}
|
|
||||||
let _ = self
|
|
||||||
}),
|
}),
|
||||||
centralItemUpdated: { [weak self] messageId in
|
centralItemUpdated: { [weak self] messageId in
|
||||||
//let _ = self?.paneContainerNode.requestExpandTabs?()
|
//let _ = self?.paneContainerNode.requestExpandTabs?()
|
||||||
|
@ -1065,6 +1065,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}, updateCanReadHistory: { [weak self] canReadHistory in
|
||||||
|
self?.canReadHistory.set(canReadHistory)
|
||||||
}),
|
}),
|
||||||
getSourceRect: { [weak self] in
|
getSourceRect: { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
@ -1326,7 +1328,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
source = .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, engine: strongSelf.context.engine, message: message, selectAll: selectAll))
|
source = .extracted(ChatMessageContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, engine: strongSelf.context.engine, message: message, selectAll: selectAll))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strongSelf.canReadHistory.set(false)
|
||||||
|
|
||||||
let controller = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: source, items: actionsSignal, recognizer: recognizer, gesture: gesture)
|
let controller = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: source, items: actionsSignal, recognizer: recognizer, gesture: gesture)
|
||||||
|
controller.dismissed = { [weak self] in
|
||||||
|
self?.canReadHistory.set(true)
|
||||||
|
}
|
||||||
controller.immediateItemsTransitionAnimation = disableTransitionAnimations
|
controller.immediateItemsTransitionAnimation = disableTransitionAnimations
|
||||||
controller.getOverlayViews = { [weak self] in
|
controller.getOverlayViews = { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
@ -1658,8 +1665,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let controller = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .extracted(ChatMessageReactionContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, engine: strongSelf.context.engine, message: message, contentView: sourceView)), items: .single(items), recognizer: nil, gesture: gesture)
|
strongSelf.canReadHistory.set(false)
|
||||||
|
|
||||||
|
let controller = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .extracted(ChatMessageReactionContextExtractedContentSource(chatNode: strongSelf.chatDisplayNode, engine: strongSelf.context.engine, message: message, contentView: sourceView)), items: .single(items), recognizer: nil, gesture: gesture)
|
||||||
|
controller.dismissed = { [weak self] in
|
||||||
|
self?.canReadHistory.set(true)
|
||||||
|
}
|
||||||
dismissController = { [weak controller] completion in
|
dismissController = { [weak controller] completion in
|
||||||
controller?.dismiss(completion: {
|
controller?.dismiss(completion: {
|
||||||
completion()
|
completion()
|
||||||
@ -3209,7 +3220,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
let peerId = replyThreadMessage.messageId.peerId
|
let peerId = replyThreadMessage.messageId.peerId
|
||||||
strongSelf.navigateToMessage(from: nil, to: .index(MessageIndex(id: MessageId(peerId: peerId, namespace: 0, id: 0), timestamp: timestamp - Int32(NSTimeZone.local.secondsFromGMT()))), scrollPosition: .bottom(0.0), rememberInStack: false, forceInCurrentChat: true, animated: true, completion: nil)
|
strongSelf.navigateToMessage(from: nil, to: .index(MessageIndex(id: MessageId(peerId: peerId, namespace: 0, id: 0), timestamp: timestamp - Int32(NSTimeZone.local.secondsFromGMT()))), scrollPosition: .bottom(0.0), rememberInStack: false, forceInCurrentChat: true, animated: true, completion: nil)
|
||||||
case .feed:
|
case .feed:
|
||||||
//TODO:implement
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}, requestRedeliveryOfFailedMessages: { [weak self] id in
|
}, requestRedeliveryOfFailedMessages: { [weak self] id in
|
||||||
@ -3832,7 +3842,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
strongSelf.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts()
|
strongSelf.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts()
|
||||||
|
|
||||||
|
strongSelf.canReadHistory.set(false)
|
||||||
|
|
||||||
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: galleryController, sourceNode: node, passthroughTouches: false)), items: .single(ContextController.Items(content: .list(items))), gesture: gesture)
|
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: galleryController, sourceNode: node, passthroughTouches: false)), items: .single(ContextController.Items(content: .list(items))), gesture: gesture)
|
||||||
|
contextController.dismissed = { [weak self] in
|
||||||
|
self?.canReadHistory.set(true)
|
||||||
|
}
|
||||||
strongSelf.presentInGlobalOverlay(contextController)
|
strongSelf.presentInGlobalOverlay(contextController)
|
||||||
})
|
})
|
||||||
}, openMessageReplies: { [weak self] messageId, isChannelPost, displayModalProgress in
|
}, openMessageReplies: { [weak self] messageId, isChannelPost, displayModalProgress in
|
||||||
@ -4485,7 +4500,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
strongSelf.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts()
|
strongSelf.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts()
|
||||||
|
|
||||||
|
strongSelf.canReadHistory.set(false)
|
||||||
|
|
||||||
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: galleryController, sourceNode: node, passthroughTouches: false)), items: items |> map { ContextController.Items(content: .list($0)) }, gesture: gesture)
|
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: galleryController, sourceNode: node, passthroughTouches: false)), items: items |> map { ContextController.Items(content: .list($0)) }, gesture: gesture)
|
||||||
|
contextController.dismissed = { [weak self] in
|
||||||
|
self?.canReadHistory.set(true)
|
||||||
|
}
|
||||||
strongSelf.presentInGlobalOverlay(contextController)
|
strongSelf.presentInGlobalOverlay(contextController)
|
||||||
}
|
}
|
||||||
chatInfoButtonItem = UIBarButtonItem(customDisplayNode: avatarNode)!
|
chatInfoButtonItem = UIBarButtonItem(customDisplayNode: avatarNode)!
|
||||||
@ -8320,7 +8340,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
strongSelf.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts()
|
strongSelf.chatDisplayNode.messageTransitionNode.dismissMessageReactionContexts()
|
||||||
|
|
||||||
|
strongSelf.canReadHistory.set(false)
|
||||||
|
|
||||||
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: sourceNode, passthroughTouches: true)), items: items |> map { ContextController.Items(content: .list($0)) })
|
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: sourceNode, passthroughTouches: true)), items: items |> map { ContextController.Items(content: .list($0)) })
|
||||||
|
contextController.dismissed = { [weak self] in
|
||||||
|
self?.canReadHistory.set(true)
|
||||||
|
}
|
||||||
contextController.dismissedForCancel = { [weak chatController] in
|
contextController.dismissedForCancel = { [weak chatController] in
|
||||||
if let selectedMessageIds = (chatController as? ChatControllerImpl)?.selectedMessageIds {
|
if let selectedMessageIds = (chatController as? ChatControllerImpl)?.selectedMessageIds {
|
||||||
var forwardMessageIds = strongSelf.presentationInterfaceState.interfaceState.forwardMessageIds ?? []
|
var forwardMessageIds = strongSelf.presentationInterfaceState.interfaceState.forwardMessageIds ?? []
|
||||||
@ -12563,10 +12588,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let areCustomEmojiEnabled = strongSelf.presentationInterfaceState.customEmojiAvailable
|
return EntityInputView(context: strongSelf.context, isDark: true, areCustomEmojiEnabled: strongSelf.presentationInterfaceState.customEmojiAvailable)
|
||||||
|
|
||||||
return EntityInputView(context: strongSelf.context, isDark: true, areCustomEmojiEnabled: areCustomEmojiEnabled)
|
|
||||||
})
|
})
|
||||||
inputPanelNode.interfaceInteraction = interfaceInteraction
|
inputPanelNode.interfaceInteraction = interfaceInteraction
|
||||||
inputPanelNode.effectivePresentationInterfaceState = {
|
inputPanelNode.effectivePresentationInterfaceState = {
|
||||||
@ -12965,15 +12988,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
let currentFilesController = Atomic<AttachmentFileControllerImpl?>(value: nil)
|
let currentFilesController = Atomic<AttachmentFileControllerImpl?>(value: nil)
|
||||||
let currentLocationController = Atomic<LocationPickerController?>(value: nil)
|
let currentLocationController = Atomic<LocationPickerController?>(value: nil)
|
||||||
|
|
||||||
|
strongSelf.canReadHistory.set(false)
|
||||||
|
|
||||||
let attachmentController = AttachmentController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, chatLocation: strongSelf.chatLocation, buttons: buttons, initialButton: initialButton, makeEntityInputView: { [weak self] in
|
let attachmentController = AttachmentController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, chatLocation: strongSelf.chatLocation, buttons: buttons, initialButton: initialButton, makeEntityInputView: { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
return EntityInputView(context: strongSelf.context, isDark: false, areCustomEmojiEnabled: strongSelf.presentationInterfaceState.customEmojiAvailable)
|
||||||
let areCustomEmojiEnabled = strongSelf.presentationInterfaceState.customEmojiAvailable
|
|
||||||
|
|
||||||
return EntityInputView(context: strongSelf.context, isDark: false, areCustomEmojiEnabled: areCustomEmojiEnabled)
|
|
||||||
})
|
})
|
||||||
|
attachmentController.didDismiss = { [weak self] in
|
||||||
|
self?.attachmentController = nil
|
||||||
|
self?.canReadHistory.set(true)
|
||||||
|
}
|
||||||
attachmentController.getSourceRect = { [weak self] in
|
attachmentController.getSourceRect = { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
return strongSelf.chatDisplayNode.frameForAttachmentButton()?.offsetBy(dx: strongSelf.chatDisplayNode.supernode?.frame.minX ?? 0.0, dy: 0.0)
|
return strongSelf.chatDisplayNode.frameForAttachmentButton()?.offsetBy(dx: strongSelf.chatDisplayNode.supernode?.frame.minX ?? 0.0, dy: 0.0)
|
||||||
|
@ -438,7 +438,7 @@ final class ChatMediaInputStickerGridItemNode: GridItemNode {
|
|||||||
let dimensions = item.stickerItem.file.dimensions ?? PixelDimensions(width: 512, height: 512)
|
let dimensions = item.stickerItem.file.dimensions ?? PixelDimensions(width: 512, height: 512)
|
||||||
let fitSize = item.large ? CGSize(width: 384.0, height: 384.0) : CGSize(width: 160.0, height: 160.0)
|
let fitSize = item.large ? CGSize(width: 384.0, height: 384.0) : CGSize(width: 160.0, height: 160.0)
|
||||||
let fittedDimensions = dimensions.cgSize.aspectFitted(fitSize)
|
let fittedDimensions = dimensions.cgSize.aspectFitted(fitSize)
|
||||||
animationNode.setup(source: AnimatedStickerResourceSource(account: item.context.account, resource: item.stickerItem.file.resource, isVideo: item.stickerItem.file.isVideoSticker), width: Int(fittedDimensions.width), height: Int(fittedDimensions.height), playbackMode: .loop, mode: .cached)
|
animationNode.setup(source: AnimatedStickerResourceSource(account: item.context.account, resource: item.stickerItem.file.resource, isVideo: item.stickerItem.file.isVideoSticker), width: Int(fittedDimensions.width), height: Int(fittedDimensions.height), playbackMode: .loop, mode: .direct(cachePathPrefix: nil))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1315,7 +1315,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
strongSelf.animatedStickerNode = animatedStickerNode
|
strongSelf.animatedStickerNode = animatedStickerNode
|
||||||
let dimensions = updatedAnimatedStickerFile.dimensions ?? PixelDimensions(width: 512, height: 512)
|
let dimensions = updatedAnimatedStickerFile.dimensions ?? PixelDimensions(width: 512, height: 512)
|
||||||
let fittedDimensions = dimensions.cgSize.aspectFitted(CGSize(width: 384.0, height: 384.0))
|
let fittedDimensions = dimensions.cgSize.aspectFitted(CGSize(width: 384.0, height: 384.0))
|
||||||
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: context.account, resource: updatedAnimatedStickerFile.resource, isVideo: updatedAnimatedStickerFile.isVideo), width: Int(fittedDimensions.width), height: Int(fittedDimensions.height), mode: .cached)
|
animatedStickerNode.setup(source: AnimatedStickerResourceSource(account: context.account, resource: updatedAnimatedStickerFile.resource, isVideo: updatedAnimatedStickerFile.isVideo), width: Int(fittedDimensions.width), height: Int(fittedDimensions.height), mode: .direct(cachePathPrefix: nil))
|
||||||
strongSelf.pinchContainerNode.contentNode.insertSubnode(animatedStickerNode, aboveSubnode: strongSelf.imageNode)
|
strongSelf.pinchContainerNode.contentNode.insertSubnode(animatedStickerNode, aboveSubnode: strongSelf.imageNode)
|
||||||
animatedStickerNode.visibility = strongSelf.visibility
|
animatedStickerNode.visibility = strongSelf.visibility
|
||||||
}
|
}
|
||||||
|
@ -3993,6 +3993,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}, updateCanReadHistory: { _ in
|
||||||
}), centralItemUpdated: { [weak self] messageId in
|
}), centralItemUpdated: { [weak self] messageId in
|
||||||
let _ = self?.paneContainerNode.requestExpandTabs?()
|
let _ = self?.paneContainerNode.requestExpandTabs?()
|
||||||
self?.paneContainerNode.currentPane?.node.ensureMessageIsVisible(id: messageId)
|
self?.paneContainerNode.currentPane?.node.ensureMessageIsVisible(id: messageId)
|
||||||
|
@ -249,9 +249,11 @@ private final class PrefetchManagerInnerImpl {
|
|||||||
self.preloadGreetingStickerDisposable.set((self.preloadedGreetingStickerPromise.get()
|
self.preloadGreetingStickerDisposable.set((self.preloadedGreetingStickerPromise.get()
|
||||||
|> mapToSignal { sticker -> Signal<Void, NoError> in
|
|> mapToSignal { sticker -> Signal<Void, NoError> in
|
||||||
if let sticker = sticker {
|
if let sticker = sticker {
|
||||||
let _ = freeMediaFileInteractiveFetched(account: account, userLocation: .other, fileReference: .standalone(media: sticker)).start()
|
return freeMediaFileInteractiveFetched(account: account, userLocation: .other, fileReference: .standalone(media: sticker))
|
||||||
return chatMessageAnimationData(mediaBox: account.postbox.mediaBox, resource: sticker.resource, fitzModifier: nil, isVideo: sticker.isVideoSticker, width: 384, height: 384, synchronousLoad: false)
|
|> map { _ -> Void in
|
||||||
|> mapToSignal { _ -> Signal<Void, NoError> in
|
return Void()
|
||||||
|
}
|
||||||
|
|> `catch` { _ -> Signal<Void, NoError> in
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user