This commit is contained in:
Peter 2019-01-14 02:24:26 +03:00
parent d544c2dd06
commit a78493367b
8 changed files with 1579 additions and 1548 deletions

View File

@ -1220,6 +1220,10 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
if strongSelf.peerView === peerView { if strongSelf.peerView === peerView {
return return
} }
var upgradedToPeerId: PeerId?
if let previous = strongSelf.peerView, let group = previous.peers[previous.peerId] as? TelegramGroup, group.migrationReference == nil, let updatedGroup = peerView.peers[peerView.peerId] as? TelegramGroup, let migrationReference = updatedGroup.migrationReference {
upgradedToPeerId = migrationReference.peerId
}
var wasGroupChannel: Bool? var wasGroupChannel: Bool?
if let previousPeerView = strongSelf.peerView, let info = (previousPeerView.peers[previousPeerView.peerId] as? TelegramChannel)?.info { if let previousPeerView = strongSelf.peerView, let info = (previousPeerView.peers[previousPeerView.peerId] as? TelegramChannel)?.info {
if case .group = info { if case .group = info {
@ -1307,6 +1311,15 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
strongSelf.didSetChatLocationInfoReady = true strongSelf.didSetChatLocationInfoReady = true
strongSelf._chatLocationInfoReady.set(.single(true)) strongSelf._chatLocationInfoReady.set(.single(true))
} }
if let upgradedToPeerId = upgradedToPeerId {
if let navigationController = strongSelf.navigationController as? NavigationController {
var viewControllers = navigationController.viewControllers
if let index = viewControllers.index(where: { $0 === strongSelf }) {
viewControllers[index] = ChatController(account: strongSelf.account, chatLocation: .peer(upgradedToPeerId))
navigationController.setViewControllers(viewControllers, animated: false)
}
}
}
} }
})) }))
} }
@ -4000,17 +4013,17 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
legacyController.bind(controller: controller) legacyController.bind(controller: controller)
legacyController.deferScreenEdgeGestures = [.top] legacyController.deferScreenEdgeGestures = [.top]
configureLegacyAssetPicker(controller, account: strongSelf.account, peer: peer, presentWebSearch: { [weak self] in configureLegacyAssetPicker(controller, account: strongSelf.account, peer: peer, presentWebSearch: { [weak self, weak legacyController] in
if let strongSelf = self { if let strongSelf = self {
let controller = WebSearchController(account: strongSelf.account, peer: peer, configuration: searchBotsConfiguration, mode: .media(completion: { [weak self, weak legacyController] results, selectionState, editingState in let controller = WebSearchController(account: strongSelf.account, peer: peer, configuration: searchBotsConfiguration, mode: .media(completion: { results, selectionState, editingState in
if let legacyController = legacyController { if let legacyController = legacyController {
legacyController.dismiss() legacyController.dismiss()
} }
legacyEnqueueWebSearchMessages(selectionState, editingState, enqueueChatContextResult: { [weak self] result in legacyEnqueueWebSearchMessages(selectionState, editingState, enqueueChatContextResult: { result in
if let strongSelf = self { if let strongSelf = self {
strongSelf.enqueueChatContextResult(results, result, hideVia: true) strongSelf.enqueueChatContextResult(results, result, hideVia: true)
} }
}, enqueueMediaMessages: { [weak self] signals in }, enqueueMediaMessages: { signals in
if let strongSelf = self { if let strongSelf = self {
strongSelf.enqueueMediaMessages(signals: signals) strongSelf.enqueueMediaMessages(signals: signals)
} }

View File

@ -362,9 +362,9 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
canStop = true canStop = true
deleteTitle = strongSelf.presentationData.strings.ChatList_DeleteChat deleteTitle = strongSelf.presentationData.strings.ChatList_DeleteChat
} else if let _ = chatPeer as? TelegramSecretChat { } else if let _ = chatPeer as? TelegramSecretChat {
deleteTitle = strongSelf.presentationData.strings.ChatList_DeleteSecretChat deleteTitle = strongSelf.presentationData.strings.ChatList_DeleteChat
} }
items.append(DeleteChatPeerActionSheetItem(account: strongSelf.account, peer: mainPeer, strings: strongSelf.presentationData.strings)) items.append(DeleteChatPeerActionSheetItem(account: strongSelf.account, peer: mainPeer, chatPeer: chatPeer, strings: strongSelf.presentationData.strings))
if canClear { if canClear {
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.DialogList_ClearHistoryConfirmation, color: .accent, action: { [weak actionSheet] in items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.DialogList_ClearHistoryConfirmation, color: .accent, action: { [weak actionSheet] in
actionSheet?.dismissAnimated() actionSheet?.dismissAnimated()
@ -1063,13 +1063,25 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
self.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil) self.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(nil)
let statusText: String let statusText: String
if let channel = chatPeer as? TelegramChannel { if let channel = chatPeer as? TelegramChannel {
if case .broadcast = channel.info { if deleteGloballyIfPossible {
statusText = self.presentationData.strings.Undo_LeftChannel if case .broadcast = channel.info {
statusText = self.presentationData.strings.Undo_DeletedChannel
} else {
statusText = self.presentationData.strings.Undo_DeletedGroup
}
} else {
if case .broadcast = channel.info {
statusText = self.presentationData.strings.Undo_LeftChannel
} else {
statusText = self.presentationData.strings.Undo_LeftGroup
}
}
} else if let _ = chatPeer as? TelegramGroup {
if deleteGloballyIfPossible {
statusText = self.presentationData.strings.Undo_DeletedGroup
} else { } else {
statusText = self.presentationData.strings.Undo_LeftGroup statusText = self.presentationData.strings.Undo_LeftGroup
} }
} else if let _ = chatPeer as? TelegramGroup {
statusText = self.presentationData.strings.Undo_LeftGroup
} else if let _ = chatPeer as? TelegramSecretChat { } else if let _ = chatPeer as? TelegramSecretChat {
statusText = self.presentationData.strings.Undo_SecretChatDeleted statusText = self.presentationData.strings.Undo_SecretChatDeleted
} else { } else {

View File

@ -575,8 +575,6 @@ struct ChatRecentActionsEntry: Comparable, Identifiable {
text += "\n" text += "\n"
} }
let prevFlags = prevBanInfo?.rights.flags ?? []
let order: [(TelegramChatBannedRightsFlags, String)] = [ let order: [(TelegramChatBannedRightsFlags, String)] = [
(.banReadMessages, self.presentationData.strings.Channel_AdminLog_BanReadMessages), (.banReadMessages, self.presentationData.strings.Channel_AdminLog_BanReadMessages),
(.banSendMessages, self.presentationData.strings.Channel_AdminLog_BanSendMessages), (.banSendMessages, self.presentationData.strings.Channel_AdminLog_BanSendMessages),
@ -584,6 +582,10 @@ struct ChatRecentActionsEntry: Comparable, Identifiable {
(.banSendStickers, self.presentationData.strings.Channel_AdminLog_BanSendStickers), (.banSendStickers, self.presentationData.strings.Channel_AdminLog_BanSendStickers),
(.banSendGifs, self.presentationData.strings.Channel_AdminLog_BanSendGifs), (.banSendGifs, self.presentationData.strings.Channel_AdminLog_BanSendGifs),
(.banEmbedLinks, self.presentationData.strings.Channel_AdminLog_BanEmbedLinks), (.banEmbedLinks, self.presentationData.strings.Channel_AdminLog_BanEmbedLinks),
(.banSendPolls, self.presentationData.strings.Channel_AdminLog_SendPolls),
(.banAddMembers, self.presentationData.strings.Channel_AdminLog_AddMembers),
(.banPinMessages, self.presentationData.strings.Channel_AdminLog_PinMessages),
(.banChangeInfo, self.presentationData.strings.Channel_AdminLog_ChangeInfo)
] ]
for (flag, string) in order { for (flag, string) in order {

View File

@ -6,16 +6,18 @@ import TelegramCore
final class DeleteChatPeerActionSheetItem: ActionSheetItem { final class DeleteChatPeerActionSheetItem: ActionSheetItem {
let account: Account let account: Account
let peer: Peer let peer: Peer
let chatPeer: Peer
let strings: PresentationStrings let strings: PresentationStrings
init(account: Account, peer: Peer, strings: PresentationStrings) { init(account: Account, peer: Peer, chatPeer: Peer, strings: PresentationStrings) {
self.account = account self.account = account
self.peer = peer self.peer = peer
self.chatPeer = chatPeer
self.strings = strings self.strings = strings
} }
func node(theme: ActionSheetControllerTheme) -> ActionSheetItemNode { func node(theme: ActionSheetControllerTheme) -> ActionSheetItemNode {
return DeleteChatPeerActionSheetItemNode(theme: theme, strings: self.strings, account: self.account, peer: self.peer) return DeleteChatPeerActionSheetItemNode(theme: theme, strings: self.strings, account: self.account, peer: self.peer, chatPeer: self.chatPeer)
} }
func updateNode(_ node: ActionSheetItemNode) { func updateNode(_ node: ActionSheetItemNode) {
@ -31,7 +33,7 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode {
private let avatarNode: AvatarNode private let avatarNode: AvatarNode
private let textNode: ImmediateTextNode private let textNode: ImmediateTextNode
init(theme: ActionSheetControllerTheme, strings: PresentationStrings, account: Account, peer: Peer) { init(theme: ActionSheetControllerTheme, strings: PresentationStrings, account: Account, peer: Peer, chatPeer: Peer) {
self.theme = theme self.theme = theme
self.strings = strings self.strings = strings
@ -49,9 +51,9 @@ private final class DeleteChatPeerActionSheetItemNode: ActionSheetItemNode {
self.avatarNode.setPeer(account: account, peer: peer) self.avatarNode.setPeer(account: account, peer: peer)
let text: (String, [(Int, NSRange)]) let text: (String, [(Int, NSRange)])
if peer is TelegramGroup || peer is TelegramChannel { if chatPeer is TelegramGroup || chatPeer is TelegramChannel {
text = strings.ChatList_LeaveGroupConfirmation(peer.displayTitle) text = strings.ChatList_LeaveGroupConfirmation(peer.displayTitle)
} else if peer is TelegramSecretChat { } else if chatPeer is TelegramSecretChat {
text = strings.ChatList_DeleteSecretChatConfirmation(peer.displayTitle) text = strings.ChatList_DeleteSecretChatConfirmation(peer.displayTitle)
} else { } else {
text = strings.ChatList_DeleteChatConfirmation(peer.displayTitle) text = strings.ChatList_DeleteChatConfirmation(peer.displayTitle)

View File

@ -1342,7 +1342,7 @@ func mediaGridMessagePhoto(account: Account, photoReference: ImageMediaReference
if let fullSizeData = fullSizeData { if let fullSizeData = fullSizeData {
if fullSizeComplete { if fullSizeComplete {
let options = NSMutableDictionary() let options = NSMutableDictionary()
options.setValue(max(fittedSize.width * context.scale, fittedSize.height * context.scale) as NSNumber, forKey: kCGImageSourceThumbnailMaxPixelSize as String) options.setValue(400 as NSNumber, forKey: kCGImageSourceThumbnailMaxPixelSize as String)
options.setValue(true as NSNumber, forKey: kCGImageSourceCreateThumbnailFromImageAlways as String) options.setValue(true as NSNumber, forKey: kCGImageSourceCreateThumbnailFromImageAlways as String)
if let imageSource = CGImageSourceCreateWithData(fullSizeData as CFData, nil), let image = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options as CFDictionary) { if let imageSource = CGImageSourceCreateWithData(fullSizeData as CFData, nil), let image = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options as CFDictionary) {
imageOrientation = imageOrientationFromSource(imageSource) imageOrientation = imageOrientationFromSource(imageSource)

File diff suppressed because it is too large Load Diff

View File

@ -149,7 +149,7 @@ public func transformOutgoingMessageMedia(postbox: Postbox, network: Network, me
|> mapToSignal { data -> Signal<AnyMediaReference?, NoError> in |> mapToSignal { data -> Signal<AnyMediaReference?, NoError> in
if data.complete { if data.complete {
if let smallest = smallestImageRepresentation(image.representations), smallest.dimensions.width > 100.0 || smallest.dimensions.height > 100.0 { if let smallest = smallestImageRepresentation(image.representations), smallest.dimensions.width > 100.0 || smallest.dimensions.height > 100.0 {
let smallestSize = smallest.dimensions.fitted(CGSize(width: 90.0, height: 90.0)) let smallestSize = smallest.dimensions.fitted(CGSize(width: 320.0, height: 320.0))
if let fullImage = UIImage(contentsOfFile: data.path), let smallestImage = generateScaledImage(image: fullImage, size: smallestSize, scale: 1.0), let smallestData = compressImageToJPEG(smallestImage, quality: 0.7) { if let fullImage = UIImage(contentsOfFile: data.path), let smallestImage = generateScaledImage(image: fullImage, size: smallestSize, scale: 1.0), let smallestData = compressImageToJPEG(smallestImage, quality: 0.7) {
var representations = image.representations var representations = image.representations