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";
|
||||
|
||||
"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
|
||||
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 {
|
||||
if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = channel.info {
|
||||
isChannel = true
|
||||
if let user = message.author?._asPeer() as? TelegramUser, user.botInfo != nil {
|
||||
type = .bot
|
||||
break
|
||||
} else if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = channel.info {
|
||||
type = .channel
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
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()
|
||||
|
@ -809,23 +809,23 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
}))
|
||||
}
|
||||
|
||||
if strongSelf.fromPublicChannel, let context = strongSelf.context, let node = node as? ContextReferenceContentNode {
|
||||
let presentationData = strongSelf.presentationData
|
||||
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
|
||||
f(.default)
|
||||
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
|
||||
f(.default)
|
||||
proceed(true)
|
||||
}))
|
||||
]
|
||||
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)
|
||||
} else {
|
||||
// if strongSelf.fromPublicChannel, let context = strongSelf.context, let node = node as? ContextReferenceContentNode {
|
||||
// let presentationData = strongSelf.presentationData
|
||||
// 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
|
||||
// f(.default)
|
||||
// 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
|
||||
// f(.default)
|
||||
// proceed(true)
|
||||
// }))
|
||||
// ]
|
||||
// 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)
|
||||
// } else {
|
||||
proceed(false)
|
||||
}
|
||||
// }
|
||||
}
|
||||
peersContentNode.openShare = { node, gesture in
|
||||
openShare(false, node, gesture)
|
||||
|
@ -1979,11 +1979,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}, openMessageShareMenu: { [weak self] id in
|
||||
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)
|
||||
shareController.openShareAsImage = { [weak self] messages in
|
||||
if let strongSelf = self {
|
||||
strongSelf.present(ChatQrCodeScreen(context: strongSelf.context, subject: .messages(messages)), in: .window(.root))
|
||||
}
|
||||
}
|
||||
// shareController.openShareAsImage = { [weak self] messages in
|
||||
// if let strongSelf = self {
|
||||
// strongSelf.present(ChatQrCodeScreen(context: strongSelf.context, subject: .messages(messages)), in: .window(.root))
|
||||
// }
|
||||
// }
|
||||
shareController.dismissed = { [weak self] shared in
|
||||
if shared {
|
||||
self?.commitPurposefulAction()
|
||||
@ -7885,35 +7885,69 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}, presentChatRequestAdminInfo: { [weak self] in
|
||||
self?.presentChatRequestAdminInfo()
|
||||
}, displayCopyProtectionTip: { [weak self] node, save in
|
||||
if let strongSelf = self, let peer = strongSelf.presentationInterfaceState.renderedPeer?.peer {
|
||||
let isChannel: Bool
|
||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||
isChannel = true
|
||||
} else {
|
||||
isChannel = false
|
||||
}
|
||||
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
|
||||
if let strongSelf = self, let peer = strongSelf.presentationInterfaceState.renderedPeer?.peer, let messageIds = strongSelf.presentationInterfaceState.interfaceState.selectionState?.selectedIds {
|
||||
let _ = (strongSelf.context.account.postbox.transaction { transaction -> [EngineMessage] in
|
||||
var messages: [EngineMessage] = []
|
||||
for id in messageIds {
|
||||
if let message = transaction.getMessage(id) {
|
||||
messages.append(EngineMessage(message))
|
||||
}
|
||||
}
|
||||
return messages
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { [weak self] messages in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
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.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)
|
||||
|
||||
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 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()))
|
||||
|
||||
|
@ -1111,7 +1111,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
||||
}
|
||||
|
||||
if data.messageActions.options.contains(.forward) {
|
||||
if chatPresentationInterfaceState.copyProtectionEnabled {
|
||||
if chatPresentationInterfaceState.copyProtectionEnabled || message.isCopyProtected() {
|
||||
|
||||
} else {
|
||||
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 {
|
||||
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)) {
|
||||
optionsMap[id]!.insert(.forward)
|
||||
}
|
||||
|
@ -6567,35 +6567,69 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
self?.controller?.push(c)
|
||||
}, completion: { _, _ in }), in: .window(.root))
|
||||
}, displayCopyProtectionTip: { [weak self] node, save in
|
||||
if let strongSelf = self, let peer = strongSelf.data?.peer {
|
||||
let isChannel: Bool
|
||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||
isChannel = true
|
||||
} else {
|
||||
isChannel = false
|
||||
}
|
||||
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
|
||||
if let strongSelf = self, let peer = strongSelf.data?.peer, let messageIds = strongSelf.state.selectedMessageIds, !messageIds.isEmpty {
|
||||
let _ = (strongSelf.context.account.postbox.transaction { transaction -> [EngineMessage] in
|
||||
var messages: [EngineMessage] = []
|
||||
for id in messageIds {
|
||||
if let message = transaction.getMessage(id) {
|
||||
messages.append(EngineMessage(message))
|
||||
}
|
||||
}
|
||||
return messages
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { [weak self] messages in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
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.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)
|
||||
|
||||
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 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user