mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
9231aa8b59
@ -33,7 +33,7 @@ public final class ContextMenuContainerNode: ASDisplayNode {
|
||||
self.containerNode.view.addSubview(effectView)
|
||||
self.effectView = effectView
|
||||
} else {
|
||||
self.containerNode.backgroundColor = isDark ? UIColor(rgb: 0x8c8e8e) : UIColor(rgb: 0xF8F8F6)
|
||||
self.containerNode.backgroundColor = isDark ? UIColor(rgb: 0x2f2f2f) : UIColor(rgb: 0xF8F8F6)
|
||||
}
|
||||
|
||||
self.layer.shadowColor = UIColor.black.cgColor
|
||||
|
||||
@ -599,21 +599,19 @@ extension StoreMessage {
|
||||
if let replyToTopId = replyToTopId {
|
||||
if peerIsForum {
|
||||
if isForumTopic {
|
||||
let threadIdValue = MessageId(peerId: replyPeerId, namespace: Namespaces.Message.Cloud, id: replyToTopId)
|
||||
let threadIdValue = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: replyToTopId)
|
||||
threadMessageId = threadIdValue
|
||||
if replyPeerId == peerId {
|
||||
threadId = makeMessageThreadId(threadIdValue)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let threadIdValue = MessageId(peerId: replyPeerId, namespace: Namespaces.Message.Cloud, id: replyToTopId)
|
||||
let threadIdValue = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: replyToTopId)
|
||||
threadMessageId = threadIdValue
|
||||
if replyPeerId == peerId {
|
||||
threadId = makeMessageThreadId(threadIdValue)
|
||||
}
|
||||
}
|
||||
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
let threadIdValue = MessageId(peerId: replyPeerId, namespace: Namespaces.Message.Cloud, id: replyToMsgId)
|
||||
let threadIdValue = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: replyToMsgId)
|
||||
|
||||
if peerIsForum {
|
||||
if isForumTopic {
|
||||
|
||||
@ -249,6 +249,13 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
||||
var contentMediaAutomaticPlayback: Bool = false
|
||||
var contentMediaAutomaticDownload: InteractiveMediaNodeAutodownloadMode = .none
|
||||
|
||||
var mediaAndFlags = mediaAndFlags
|
||||
if let mediaAndFlagsValue = mediaAndFlags, let _ = mediaAndFlagsValue.0 as? TelegramMediaStory {
|
||||
var flags = mediaAndFlagsValue.1
|
||||
flags.remove(.preferMediaInline)
|
||||
mediaAndFlags = (mediaAndFlagsValue.0, flags)
|
||||
}
|
||||
|
||||
var contentMediaAspectFilled = false
|
||||
if let (_, flags) = mediaAndFlags {
|
||||
contentMediaAspectFilled = flags.contains(.preferMediaAspectFilled)
|
||||
@ -921,10 +928,12 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
if updateMedia {
|
||||
if let image = inlineMediaValue as? TelegramMediaImage {
|
||||
let resolvedInlineMediaValue = inlineMediaValue
|
||||
|
||||
if let image = resolvedInlineMediaValue as? TelegramMediaImage {
|
||||
let updateInlineImageSignal = chatWebpageSnippetPhoto(account: context.account, userLocation: .peer(message.id.peerId), photoReference: .message(message: MessageReference(message), media: image), placeholderColor: mainColor.withMultipliedAlpha(0.1))
|
||||
inlineMedia.setSignal(updateInlineImageSignal)
|
||||
} else if let file = inlineMediaValue as? TelegramMediaFile, let representation = file.previewRepresentations.last {
|
||||
} else if let file = resolvedInlineMediaValue as? TelegramMediaFile, let representation = file.previewRepresentations.last {
|
||||
let updateInlineImageSignal = chatWebpageSnippetFile(account: context.account, userLocation: .peer(message.id.peerId), mediaReference: .message(message: MessageReference(message), media: file), representation: representation)
|
||||
inlineMedia.setSignal(updateInlineImageSignal)
|
||||
}
|
||||
|
||||
@ -670,7 +670,7 @@ public class ChatMessageReplyInfoNode: ASDisplayNode {
|
||||
node.addSubnode(imageNode)
|
||||
node.imageNode = imageNode
|
||||
}
|
||||
imageNode.frame = CGRect(origin: CGPoint(x: 9.0, y: 3.0 + UIScreenPixel), size: CGSize(width: imageSide, height: imageSide))
|
||||
imageNode.frame = CGRect(origin: CGPoint(x: 9.0, y: 4.0), size: CGSize(width: imageSide, height: imageSide))
|
||||
|
||||
if let updateImageSignal = updateImageSignal {
|
||||
imageNode.setSignal(updateImageSignal)
|
||||
|
||||
@ -54,7 +54,7 @@ public final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContent
|
||||
item.controllerInteraction.openTheme(item.message)
|
||||
return
|
||||
} else {
|
||||
if content.embedUrl == nil && (content.title != nil || content.text != nil) {
|
||||
if content.embedUrl == nil && (content.title != nil || content.text != nil) && content.story == nil {
|
||||
var shouldOpenUrl = true
|
||||
if let file = content.file {
|
||||
if !file.isVideo, !file.isVideoSticker, !file.isAnimated, !file.isAnimatedSticker, !file.isSticker, !file.isMusic {
|
||||
|
||||
@ -507,23 +507,40 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
source = .custom(messages: messages, messageId: messageIds.first ?? MessageId(peerId: PeerId(0), namespace: 0, id: 0), quote: reply.quote?.text, loadMore: nil)
|
||||
case let .link(link):
|
||||
let messages = link.options
|
||||
|> mapToSignal { options -> Signal<(ChatControllerSubject.LinkOptions, Peer, Message?), NoError> in
|
||||
|> mapToSignal { options -> Signal<(ChatControllerSubject.LinkOptions, Peer, Message?, [StoryId: CodableEntry]), NoError> in
|
||||
let stories: Signal<[StoryId: CodableEntry], NoError>
|
||||
if case let .Loaded(content) = options.webpage.content, let story = content.story {
|
||||
stories = context.account.postbox.transaction { transaction -> [StoryId: CodableEntry] in
|
||||
var result: [StoryId: CodableEntry] = [:]
|
||||
if let storyValue = transaction.getStory(id: story.storyId) {
|
||||
result[story.storyId] = storyValue
|
||||
}
|
||||
return result
|
||||
}
|
||||
} else {
|
||||
stories = .single([:])
|
||||
}
|
||||
|
||||
if let replyMessageId = options.replyMessageId {
|
||||
return combineLatest(
|
||||
context.account.postbox.messagesAtIds([replyMessageId]),
|
||||
context.account.postbox.loadedPeerWithId(context.account.peerId)
|
||||
context.account.postbox.loadedPeerWithId(context.account.peerId),
|
||||
stories
|
||||
)
|
||||
|> map { messages, peer -> (ChatControllerSubject.LinkOptions, Peer, Message?) in
|
||||
return (options, peer, messages.first)
|
||||
|> map { messages, peer, stories -> (ChatControllerSubject.LinkOptions, Peer, Message?, [StoryId: CodableEntry]) in
|
||||
return (options, peer, messages.first, stories)
|
||||
}
|
||||
} else {
|
||||
return context.account.postbox.loadedPeerWithId(context.account.peerId)
|
||||
|> map { peer -> (ChatControllerSubject.LinkOptions, Peer, Message?) in
|
||||
return (options, peer, nil)
|
||||
return combineLatest(
|
||||
context.account.postbox.loadedPeerWithId(context.account.peerId),
|
||||
stories
|
||||
)
|
||||
|> map { peer, stories -> (ChatControllerSubject.LinkOptions, Peer, Message?, [StoryId: CodableEntry]) in
|
||||
return (options, peer, nil, stories)
|
||||
}
|
||||
}
|
||||
}
|
||||
|> map { options, accountPeer, replyMessage -> ([Message], Int32, Bool) in
|
||||
|> map { options, accountPeer, replyMessage, stories -> ([Message], Int32, Bool) in
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
peers[accountPeer.id] = accountPeer
|
||||
|
||||
@ -534,10 +551,11 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
media.append(TelegramMediaWebpage(webpageId: options.webpage.webpageId, content: .Loaded(content)))
|
||||
}
|
||||
|
||||
let associatedStories: [StoryId: CodableEntry] = stories
|
||||
|
||||
var attributes: [MessageAttribute] = []
|
||||
|
||||
attributes.append(TextEntitiesMessageAttribute(entities: options.messageEntities))
|
||||
|
||||
attributes.append(WebpagePreviewMessageAttribute(leadingPreview: !options.linkBelowText, forceLargeMedia: options.largeMedia, isManuallyAdded: true, isSafe: false))
|
||||
|
||||
if let replyMessage {
|
||||
@ -574,7 +592,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
associatedMessageIds: [],
|
||||
associatedMedia: [:],
|
||||
associatedThreadInfo: nil,
|
||||
associatedStories: [:]
|
||||
associatedStories: associatedStories
|
||||
)
|
||||
|
||||
return ([message], 1, false)
|
||||
|
||||
@ -1046,7 +1046,30 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
||||
var keyboardAppearance: UIKeyboardAppearance = UIKeyboardAppearance.default
|
||||
if let presentationInterfaceState = self.presentationInterfaceState {
|
||||
var lineStyle: ChatInputTextView.Theme.Quote.LineStyle = .solid
|
||||
if let accountPeerColor = presentationInterfaceState.accountPeerColor {
|
||||
let authorNameColor: UIColor
|
||||
let dashSecondaryColor: UIColor?
|
||||
let dashTertiaryColor: UIColor?
|
||||
|
||||
if let context = self.context, let peer = presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, case .broadcast = peer.info, let nameColor = peer.nameColor {
|
||||
let _ = nameColor
|
||||
|
||||
lineStyle = .solid
|
||||
authorNameColor = presentationInterfaceState.theme.list.itemAccentColor
|
||||
dashSecondaryColor = nil
|
||||
dashTertiaryColor = nil
|
||||
|
||||
/*let colors = context.peerNameColors.get(nameColor)
|
||||
|
||||
authorNameColor = colors.main
|
||||
dashSecondaryColor = colors.secondary
|
||||
dashTertiaryColor = colors.tertiary
|
||||
|
||||
if dashSecondaryColor != nil {
|
||||
lineStyle = .doubleDashed
|
||||
} else {
|
||||
lineStyle = .solid
|
||||
}*/
|
||||
} else if let accountPeerColor = presentationInterfaceState.accountPeerColor {
|
||||
switch accountPeerColor.style {
|
||||
case .solid:
|
||||
lineStyle = .solid
|
||||
@ -1055,11 +1078,24 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
||||
case .tripleDashed:
|
||||
lineStyle = .tripleDashed
|
||||
}
|
||||
|
||||
authorNameColor = presentationInterfaceState.theme.list.itemAccentColor
|
||||
dashSecondaryColor = .clear
|
||||
dashTertiaryColor = nil
|
||||
} else {
|
||||
lineStyle = .solid
|
||||
authorNameColor = presentationInterfaceState.theme.list.itemAccentColor
|
||||
dashSecondaryColor = nil
|
||||
dashTertiaryColor = nil
|
||||
}
|
||||
|
||||
let _ = dashSecondaryColor
|
||||
let _ = dashTertiaryColor
|
||||
|
||||
textInputNode.textView.theme = ChatInputTextView.Theme(
|
||||
quote: ChatInputTextView.Theme.Quote(
|
||||
background: presentationInterfaceState.theme.list.itemAccentColor.withMultipliedAlpha(presentationInterfaceState.theme.overallDarkAppearance ? 0.2 : 0.1),
|
||||
foreground: presentationInterfaceState.theme.list.itemAccentColor,
|
||||
background: authorNameColor.withMultipliedAlpha(presentationInterfaceState.theme.overallDarkAppearance ? 0.2 : 0.1),
|
||||
foreground: authorNameColor,
|
||||
lineStyle: lineStyle
|
||||
)
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user