mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Fixes
This commit is contained in:
parent
1c9126971a
commit
b102311660
@ -7239,3 +7239,6 @@ Sorry for the inconvenience.";
|
|||||||
"Share.ShareMessage" = "Share Message";
|
"Share.ShareMessage" = "Share Message";
|
||||||
|
|
||||||
"Conversation.UserSendMessage" = "SEND MESSAGE";
|
"Conversation.UserSendMessage" = "SEND MESSAGE";
|
||||||
|
|
||||||
|
"Conversation.CopyProtectionForwardingDisabledBot" = "Forwards from this bot are restricted";
|
||||||
|
"Conversation.CopyProtectionSavingDisabledBot" = "Saving from this bot is restricted";
|
||||||
|
@ -618,19 +618,30 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
}
|
}
|
||||||
|> deliverOnMainQueue).start(next: { messages in
|
|> deliverOnMainQueue).start(next: { messages in
|
||||||
if let strongSelf = self, !messages.isEmpty {
|
if let strongSelf = self, !messages.isEmpty {
|
||||||
var isChannel = false
|
enum PeerType {
|
||||||
|
case group
|
||||||
|
case channel
|
||||||
|
case bot
|
||||||
|
}
|
||||||
|
var type: PeerType = .group
|
||||||
for message in messages {
|
for message in messages {
|
||||||
if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = channel.info {
|
if let user = message.author?._asPeer() as? TelegramUser, user.botInfo != nil {
|
||||||
isChannel = true
|
type = .bot
|
||||||
|
break
|
||||||
|
} else if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = channel.info {
|
||||||
|
type = .channel
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let text: String
|
let text: String
|
||||||
if save {
|
switch type {
|
||||||
text = isChannel ? strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledChannel : strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledGroup
|
case .group:
|
||||||
} else {
|
text = save ? strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledGroup : strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledGroup
|
||||||
text = isChannel ? strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledChannel : strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledGroup
|
case .channel:
|
||||||
|
text = save ? strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledChannel : strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledChannel
|
||||||
|
case .bot:
|
||||||
|
text = save ? strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledBot : strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledBot
|
||||||
}
|
}
|
||||||
|
|
||||||
strongSelf.copyProtectionTooltipController?.dismiss()
|
strongSelf.copyProtectionTooltipController?.dismiss()
|
||||||
|
@ -809,23 +809,23 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
if strongSelf.fromPublicChannel, let context = strongSelf.context, let node = node as? ContextReferenceContentNode {
|
// if strongSelf.fromPublicChannel, let context = strongSelf.context, let node = node as? ContextReferenceContentNode {
|
||||||
let presentationData = strongSelf.presentationData
|
// let presentationData = strongSelf.presentationData
|
||||||
let items: [ContextMenuItem] = [
|
// let items: [ContextMenuItem] = [
|
||||||
.action(ContextMenuActionItem(text: presentationData.strings.Share_ShareAsLink, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Link"), color: theme.contextMenu.primaryColor) }, action: { _, f in
|
// .action(ContextMenuActionItem(text: presentationData.strings.Share_ShareAsLink, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Link"), color: theme.contextMenu.primaryColor) }, action: { _, f in
|
||||||
f(.default)
|
// f(.default)
|
||||||
proceed(false)
|
// proceed(false)
|
||||||
})),
|
// })),
|
||||||
.action(ContextMenuActionItem(text: presentationData.strings.Share_ShareAsImage, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Image"), color: theme.contextMenu.primaryColor) }, action: { _, f in
|
// .action(ContextMenuActionItem(text: presentationData.strings.Share_ShareAsImage, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Image"), color: theme.contextMenu.primaryColor) }, action: { _, f in
|
||||||
f(.default)
|
// f(.default)
|
||||||
proceed(true)
|
// proceed(true)
|
||||||
}))
|
// }))
|
||||||
]
|
// ]
|
||||||
let contextController = ContextController(account: context.account, presentationData: presentationData, source: .reference(ShareContextReferenceContentSource(sourceNode: node)), items: .single(ContextController.Items(content: .list(items))), gesture: gesture)
|
// let contextController = ContextController(account: context.account, presentationData: presentationData, source: .reference(ShareContextReferenceContentSource(sourceNode: node)), items: .single(ContextController.Items(content: .list(items))), gesture: gesture)
|
||||||
strongSelf.present?(contextController)
|
// strongSelf.present?(contextController)
|
||||||
} else {
|
// } else {
|
||||||
proceed(false)
|
proceed(false)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
peersContentNode.openShare = { node, gesture in
|
peersContentNode.openShare = { node, gesture in
|
||||||
openShare(false, node, gesture)
|
openShare(false, node, gesture)
|
||||||
|
@ -1979,11 +1979,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}, openMessageShareMenu: { [weak self] id in
|
}, openMessageShareMenu: { [weak self] id in
|
||||||
if let strongSelf = self, let messages = strongSelf.chatDisplayNode.historyNode.messageGroupInCurrentHistoryView(id), let _ = messages.first {
|
if let strongSelf = self, let messages = strongSelf.chatDisplayNode.historyNode.messageGroupInCurrentHistoryView(id), let _ = messages.first {
|
||||||
let shareController = ShareController(context: strongSelf.context, subject: .messages(messages), updatedPresentationData: strongSelf.updatedPresentationData, shareAsLink: true)
|
let shareController = ShareController(context: strongSelf.context, subject: .messages(messages), updatedPresentationData: strongSelf.updatedPresentationData, shareAsLink: true)
|
||||||
shareController.openShareAsImage = { [weak self] messages in
|
// shareController.openShareAsImage = { [weak self] messages in
|
||||||
if let strongSelf = self {
|
// if let strongSelf = self {
|
||||||
strongSelf.present(ChatQrCodeScreen(context: strongSelf.context, subject: .messages(messages)), in: .window(.root))
|
// strongSelf.present(ChatQrCodeScreen(context: strongSelf.context, subject: .messages(messages)), in: .window(.root))
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
shareController.dismissed = { [weak self] shared in
|
shareController.dismissed = { [weak self] shared in
|
||||||
if shared {
|
if shared {
|
||||||
self?.commitPurposefulAction()
|
self?.commitPurposefulAction()
|
||||||
@ -7885,35 +7885,69 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}, presentChatRequestAdminInfo: { [weak self] in
|
}, presentChatRequestAdminInfo: { [weak self] in
|
||||||
self?.presentChatRequestAdminInfo()
|
self?.presentChatRequestAdminInfo()
|
||||||
}, displayCopyProtectionTip: { [weak self] node, save in
|
}, displayCopyProtectionTip: { [weak self] node, save in
|
||||||
if let strongSelf = self, let peer = strongSelf.presentationInterfaceState.renderedPeer?.peer {
|
if let strongSelf = self, let peer = strongSelf.presentationInterfaceState.renderedPeer?.peer, let messageIds = strongSelf.presentationInterfaceState.interfaceState.selectionState?.selectedIds {
|
||||||
let isChannel: Bool
|
let _ = (strongSelf.context.account.postbox.transaction { transaction -> [EngineMessage] in
|
||||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
var messages: [EngineMessage] = []
|
||||||
isChannel = true
|
for id in messageIds {
|
||||||
} else {
|
if let message = transaction.getMessage(id) {
|
||||||
isChannel = false
|
messages.append(EngineMessage(message))
|
||||||
}
|
}
|
||||||
let text: String
|
|
||||||
if save {
|
|
||||||
text = isChannel ? strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionSavingDisabledChannel : strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionSavingDisabledGroup
|
|
||||||
} else {
|
|
||||||
text = isChannel ? strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionForwardingDisabledChannel : strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionForwardingDisabledGroup
|
|
||||||
}
|
|
||||||
|
|
||||||
strongSelf.copyProtectionTooltipController?.dismiss()
|
|
||||||
let tooltipController = TooltipController(content: .text(text), baseFontSize: strongSelf.presentationData.listsFontSize.baseDisplaySize, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true)
|
|
||||||
strongSelf.copyProtectionTooltipController = tooltipController
|
|
||||||
tooltipController.dismissed = { [weak tooltipController] _ in
|
|
||||||
if let strongSelf = self, let tooltipController = tooltipController, strongSelf.copyProtectionTooltipController === tooltipController {
|
|
||||||
strongSelf.copyProtectionTooltipController = nil
|
|
||||||
}
|
}
|
||||||
|
return messages
|
||||||
}
|
}
|
||||||
strongSelf.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: {
|
|> deliverOnMainQueue).start(next: { [weak self] messages in
|
||||||
if let strongSelf = self {
|
guard let strongSelf = self else {
|
||||||
let rect = node.view.convert(node.view.bounds, to: strongSelf.chatDisplayNode.view).offsetBy(dx: 0.0, dy: 3.0)
|
return
|
||||||
return (strongSelf.chatDisplayNode, rect)
|
|
||||||
}
|
}
|
||||||
return nil
|
enum PeerType {
|
||||||
}))
|
case group
|
||||||
|
case channel
|
||||||
|
case bot
|
||||||
|
}
|
||||||
|
var isBot = false
|
||||||
|
for message in messages {
|
||||||
|
if let author = message.author, case let .user(user) = author, user.botInfo != nil {
|
||||||
|
isBot = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let type: PeerType
|
||||||
|
if isBot {
|
||||||
|
type = .bot
|
||||||
|
} else if let user = peer as? TelegramUser, user.botInfo != nil {
|
||||||
|
type = .bot
|
||||||
|
} else if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||||
|
type = .channel
|
||||||
|
} else {
|
||||||
|
type = .group
|
||||||
|
}
|
||||||
|
|
||||||
|
let text: String
|
||||||
|
switch type {
|
||||||
|
case .group:
|
||||||
|
text = save ? strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionSavingDisabledGroup : strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionForwardingDisabledGroup
|
||||||
|
case .channel:
|
||||||
|
text = save ? strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionSavingDisabledChannel : strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionForwardingDisabledChannel
|
||||||
|
case .bot:
|
||||||
|
text = save ? strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionSavingDisabledBot : strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionForwardingDisabledBot
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.copyProtectionTooltipController?.dismiss()
|
||||||
|
let tooltipController = TooltipController(content: .text(text), baseFontSize: strongSelf.presentationData.listsFontSize.baseDisplaySize, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true)
|
||||||
|
strongSelf.copyProtectionTooltipController = tooltipController
|
||||||
|
tooltipController.dismissed = { [weak tooltipController] _ in
|
||||||
|
if let strongSelf = self, let tooltipController = tooltipController, strongSelf.copyProtectionTooltipController === tooltipController {
|
||||||
|
strongSelf.copyProtectionTooltipController = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strongSelf.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: {
|
||||||
|
if let strongSelf = self {
|
||||||
|
let rect = node.view.convert(node.view.bounds, to: strongSelf.chatDisplayNode.view).offsetBy(dx: 0.0, dy: 3.0)
|
||||||
|
return (strongSelf.chatDisplayNode, rect)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}, statuses: ChatPanelInterfaceInteractionStatuses(editingMessage: self.editingMessage.get(), startingBot: self.startingBot.get(), unblockingPeer: self.unblockingPeer.get(), searching: self.searching.get(), loadingMessage: self.loadingMessage.get(), inlineSearch: self.performingInlineSearch.get()))
|
}, statuses: ChatPanelInterfaceInteractionStatuses(editingMessage: self.editingMessage.get(), startingBot: self.startingBot.get(), unblockingPeer: self.unblockingPeer.get(), searching: self.searching.get(), loadingMessage: self.loadingMessage.get(), inlineSearch: self.performingInlineSearch.get()))
|
||||||
|
|
||||||
|
@ -1111,7 +1111,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
|||||||
}
|
}
|
||||||
|
|
||||||
if data.messageActions.options.contains(.forward) {
|
if data.messageActions.options.contains(.forward) {
|
||||||
if chatPresentationInterfaceState.copyProtectionEnabled {
|
if chatPresentationInterfaceState.copyProtectionEnabled || message.isCopyProtected() {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuForward, icon: { theme in
|
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuForward, icon: { theme in
|
||||||
@ -1508,7 +1508,7 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let user = peer as? TelegramUser {
|
} else if let user = peer as? TelegramUser {
|
||||||
if !isScheduled && message.id.peerId.namespace != Namespaces.Peer.SecretChat && !message.containsSecretMedia && !isAction && !message.id.peerId.isReplies {
|
if !isScheduled && message.id.peerId.namespace != Namespaces.Peer.SecretChat && !message.containsSecretMedia && !isAction && !message.id.peerId.isReplies && !message.isCopyProtected() {
|
||||||
if !(message.flags.isSending || message.flags.contains(.Failed)) {
|
if !(message.flags.isSending || message.flags.contains(.Failed)) {
|
||||||
optionsMap[id]!.insert(.forward)
|
optionsMap[id]!.insert(.forward)
|
||||||
}
|
}
|
||||||
|
@ -6567,35 +6567,69 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
self?.controller?.push(c)
|
self?.controller?.push(c)
|
||||||
}, completion: { _, _ in }), in: .window(.root))
|
}, completion: { _, _ in }), in: .window(.root))
|
||||||
}, displayCopyProtectionTip: { [weak self] node, save in
|
}, displayCopyProtectionTip: { [weak self] node, save in
|
||||||
if let strongSelf = self, let peer = strongSelf.data?.peer {
|
if let strongSelf = self, let peer = strongSelf.data?.peer, let messageIds = strongSelf.state.selectedMessageIds, !messageIds.isEmpty {
|
||||||
let isChannel: Bool
|
let _ = (strongSelf.context.account.postbox.transaction { transaction -> [EngineMessage] in
|
||||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
var messages: [EngineMessage] = []
|
||||||
isChannel = true
|
for id in messageIds {
|
||||||
} else {
|
if let message = transaction.getMessage(id) {
|
||||||
isChannel = false
|
messages.append(EngineMessage(message))
|
||||||
}
|
}
|
||||||
let text: String
|
|
||||||
if save {
|
|
||||||
text = isChannel ? strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledChannel : strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledGroup
|
|
||||||
} else {
|
|
||||||
text = isChannel ? strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledChannel : strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledGroup
|
|
||||||
}
|
|
||||||
|
|
||||||
strongSelf.copyProtectionTooltipController?.dismiss()
|
|
||||||
let tooltipController = TooltipController(content: .text(text), baseFontSize: strongSelf.presentationData.listsFontSize.baseDisplaySize, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true)
|
|
||||||
strongSelf.copyProtectionTooltipController = tooltipController
|
|
||||||
tooltipController.dismissed = { [weak tooltipController] _ in
|
|
||||||
if let strongSelf = self, let tooltipController = tooltipController, strongSelf.copyProtectionTooltipController === tooltipController {
|
|
||||||
strongSelf.copyProtectionTooltipController = nil
|
|
||||||
}
|
}
|
||||||
|
return messages
|
||||||
}
|
}
|
||||||
strongSelf.controller?.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: {
|
|> deliverOnMainQueue).start(next: { [weak self] messages in
|
||||||
if let strongSelf = self {
|
guard let strongSelf = self else {
|
||||||
let rect = node.view.convert(node.view.bounds, to: strongSelf.view).offsetBy(dx: 0.0, dy: 3.0)
|
return
|
||||||
return (strongSelf, rect)
|
|
||||||
}
|
}
|
||||||
return nil
|
enum PeerType {
|
||||||
}))
|
case group
|
||||||
|
case channel
|
||||||
|
case bot
|
||||||
|
}
|
||||||
|
var isBot = false
|
||||||
|
for message in messages {
|
||||||
|
if let author = message.author, case let .user(user) = author, user.botInfo != nil {
|
||||||
|
isBot = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let type: PeerType
|
||||||
|
if isBot {
|
||||||
|
type = .bot
|
||||||
|
} else if let user = peer as? TelegramUser, user.botInfo != nil {
|
||||||
|
type = .bot
|
||||||
|
} else if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||||
|
type = .channel
|
||||||
|
} else {
|
||||||
|
type = .group
|
||||||
|
}
|
||||||
|
|
||||||
|
let text: String
|
||||||
|
switch type {
|
||||||
|
case .group:
|
||||||
|
text = save ? strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledGroup : strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledGroup
|
||||||
|
case .channel:
|
||||||
|
text = save ? strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledChannel : strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledChannel
|
||||||
|
case .bot:
|
||||||
|
text = save ? strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledBot : strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledBot
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.copyProtectionTooltipController?.dismiss()
|
||||||
|
let tooltipController = TooltipController(content: .text(text), baseFontSize: strongSelf.presentationData.listsFontSize.baseDisplaySize, dismissByTapOutside: true, dismissImmediatelyOnLayoutUpdate: true)
|
||||||
|
strongSelf.copyProtectionTooltipController = tooltipController
|
||||||
|
tooltipController.dismissed = { [weak tooltipController] _ in
|
||||||
|
if let strongSelf = self, let tooltipController = tooltipController, strongSelf.copyProtectionTooltipController === tooltipController {
|
||||||
|
strongSelf.copyProtectionTooltipController = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strongSelf.controller?.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: {
|
||||||
|
if let strongSelf = self {
|
||||||
|
let rect = node.view.convert(node.view.bounds, to: strongSelf.view).offsetBy(dx: 0.0, dy: 3.0)
|
||||||
|
return (strongSelf, rect)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.paneContainerNode.selectionPanelNode = selectionPanelNode
|
self.paneContainerNode.selectionPanelNode = selectionPanelNode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user