Various Fixes

This commit is contained in:
Ilya Laktyushin 2022-01-14 01:56:41 +03:00
parent 1c9126971a
commit b102311660
6 changed files with 164 additions and 82 deletions

View File

@ -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";

View File

@ -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()

View File

@ -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)
// 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)
})),
.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)

View File

@ -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,18 +7885,51 @@ 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
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))
}
let text: String
if save {
text = isChannel ? strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionSavingDisabledChannel : strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionSavingDisabledGroup
}
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 {
text = isChannel ? strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionForwardingDisabledChannel : strongSelf.presentationInterfaceState.strings.Conversation_CopyProtectionForwardingDisabledGroup
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()
@ -7914,6 +7947,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}
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()))

View File

@ -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)
}

View File

@ -6567,18 +6567,51 @@ 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
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))
}
let text: String
if save {
text = isChannel ? strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledChannel : strongSelf.presentationData.strings.Conversation_CopyProtectionSavingDisabledGroup
}
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 {
text = isChannel ? strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledChannel : strongSelf.presentationData.strings.Conversation_CopyProtectionForwardingDisabledGroup
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()
@ -6596,6 +6629,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
}
return nil
}))
})
}
})
self.paneContainerNode.selectionPanelNode = selectionPanelNode