Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2020-06-30 18:15:14 +03:00
commit a2b82285db
11 changed files with 133 additions and 68 deletions

View File

@ -986,9 +986,6 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
} else if let _ = message.peers[message.id.peerId] as? TelegramSecretChat {
displayMediaPreviews = false
}
if !item.context.sharedContext.immediateExperimentalUISettings.chatListPhotos {
displayMediaPreviews = false
}
if displayMediaPreviews {
let contentImageFillSize = CGSize(width: 8.0, height: contentImageSize.height)
_ = contentImageFillSize

View File

@ -599,7 +599,7 @@ private func debugControllerEntries(presentationData: PresentationData, loggingS
entries.append(.resetHoles(presentationData.theme))
entries.append(.reindexUnread(presentationData.theme))
entries.append(.optimizeDatabase(presentationData.theme))
entries.append(.photoPreview(presentationData.theme, experimentalSettings.chatListPhotos))
//entries.append(.photoPreview(presentationData.theme, experimentalSettings.chatListPhotos))
entries.append(.knockoutWallpaper(presentationData.theme, experimentalSettings.knockoutWallpaper))
entries.append(.alternativeFolderTabs(experimentalSettings.foldersTabAtBottom))
entries.append(.videoCalls(experimentalSettings.videoCalls))

View File

@ -254,6 +254,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1512627963] = { return Api.Update.parse_updateDialogFilterOrder($0) }
dict[889491791] = { return Api.Update.parse_updateDialogFilters($0) }
dict[643940105] = { return Api.Update.parse_updatePhoneCallSignalingData($0) }
dict[-1812551503] = { return Api.Update.parse_updateChannelParticipant($0) }
dict[136574537] = { return Api.messages.VotesList.parse_votesList($0) }
dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) }
dict[-373643672] = { return Api.FolderPeer.parse_folderPeer($0) }
@ -821,9 +822,9 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1730311882] = { return Api.PageListOrderedItem.parse_pageListOrderedItemBlocks($0) }
dict[-1417756512] = { return Api.EncryptedChat.parse_encryptedChatEmpty($0) }
dict[1006044124] = { return Api.EncryptedChat.parse_encryptedChatWaiting($0) }
dict[-931638658] = { return Api.EncryptedChat.parse_encryptedChatRequested($0) }
dict[-94974410] = { return Api.EncryptedChat.parse_encryptedChat($0) }
dict[332848423] = { return Api.EncryptedChat.parse_encryptedChatDiscarded($0) }
dict[1651608194] = { return Api.EncryptedChat.parse_encryptedChatRequested($0) }
dict[-901375139] = { return Api.PeerLocated.parse_peerLocated($0) }
dict[-118740917] = { return Api.PeerLocated.parse_peerSelfLocated($0) }
dict[922273905] = { return Api.Document.parse_documentEmpty($0) }

View File

@ -6029,6 +6029,7 @@ public extension Api {
case updateDialogFilterOrder(order: [Int32])
case updateDialogFilters
case updatePhoneCallSignalingData(phoneCallId: Int64, data: Buffer)
case updateChannelParticipant(channelId: Int32, prevParticipant: Api.ChannelParticipant, newParticipant: Api.ChannelParticipant, qts: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -6709,6 +6710,15 @@ public extension Api {
serializeInt64(phoneCallId, buffer: buffer, boxed: false)
serializeBytes(data, buffer: buffer, boxed: false)
break
case .updateChannelParticipant(let channelId, let prevParticipant, let newParticipant, let qts):
if boxed {
buffer.appendInt32(-1812551503)
}
serializeInt32(channelId, buffer: buffer, boxed: false)
prevParticipant.serialize(buffer, true)
newParticipant.serialize(buffer, true)
serializeInt32(qts, buffer: buffer, boxed: false)
break
}
}
@ -6876,6 +6886,8 @@ public extension Api {
return ("updateDialogFilters", [])
case .updatePhoneCallSignalingData(let phoneCallId, let data):
return ("updatePhoneCallSignalingData", [("phoneCallId", phoneCallId), ("data", data)])
case .updateChannelParticipant(let channelId, let prevParticipant, let newParticipant, let qts):
return ("updateChannelParticipant", [("channelId", channelId), ("prevParticipant", prevParticipant), ("newParticipant", newParticipant), ("qts", qts)])
}
}
@ -8221,6 +8233,30 @@ public extension Api {
return nil
}
}
public static func parse_updateChannelParticipant(_ reader: BufferReader) -> Update? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.ChannelParticipant?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.ChannelParticipant
}
var _3: Api.ChannelParticipant?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.ChannelParticipant
}
var _4: Int32?
_4 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.Update.updateChannelParticipant(channelId: _1!, prevParticipant: _2!, newParticipant: _3!, qts: _4!)
}
else {
return nil
}
}
}
public enum PopularContact: TypeConstructorDescription {
@ -22468,9 +22504,9 @@ public extension Api {
public enum EncryptedChat: TypeConstructorDescription {
case encryptedChatEmpty(id: Int32)
case encryptedChatWaiting(id: Int32, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32)
case encryptedChatRequested(id: Int32, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gA: Buffer)
case encryptedChat(id: Int32, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gAOrB: Buffer, keyFingerprint: Int64)
case encryptedChatDiscarded(id: Int32)
case encryptedChatRequested(flags: Int32, folderId: Int32?, id: Int32, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gA: Buffer)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -22490,17 +22526,6 @@ public extension Api {
serializeInt32(adminId, buffer: buffer, boxed: false)
serializeInt32(participantId, buffer: buffer, boxed: false)
break
case .encryptedChatRequested(let id, let accessHash, let date, let adminId, let participantId, let gA):
if boxed {
buffer.appendInt32(-931638658)
}
serializeInt32(id, buffer: buffer, boxed: false)
serializeInt64(accessHash, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(adminId, buffer: buffer, boxed: false)
serializeInt32(participantId, buffer: buffer, boxed: false)
serializeBytes(gA, buffer: buffer, boxed: false)
break
case .encryptedChat(let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint):
if boxed {
buffer.appendInt32(-94974410)
@ -22519,6 +22544,19 @@ public extension Api {
}
serializeInt32(id, buffer: buffer, boxed: false)
break
case .encryptedChatRequested(let flags, let folderId, let id, let accessHash, let date, let adminId, let participantId, let gA):
if boxed {
buffer.appendInt32(1651608194)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(folderId!, buffer: buffer, boxed: false)}
serializeInt32(id, buffer: buffer, boxed: false)
serializeInt64(accessHash, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(adminId, buffer: buffer, boxed: false)
serializeInt32(participantId, buffer: buffer, boxed: false)
serializeBytes(gA, buffer: buffer, boxed: false)
break
}
}
@ -22528,12 +22566,12 @@ public extension Api {
return ("encryptedChatEmpty", [("id", id)])
case .encryptedChatWaiting(let id, let accessHash, let date, let adminId, let participantId):
return ("encryptedChatWaiting", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId)])
case .encryptedChatRequested(let id, let accessHash, let date, let adminId, let participantId, let gA):
return ("encryptedChatRequested", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gA", gA)])
case .encryptedChat(let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint):
return ("encryptedChat", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gAOrB", gAOrB), ("keyFingerprint", keyFingerprint)])
case .encryptedChatDiscarded(let id):
return ("encryptedChatDiscarded", [("id", id)])
case .encryptedChatRequested(let flags, let folderId, let id, let accessHash, let date, let adminId, let participantId, let gA):
return ("encryptedChatRequested", [("flags", flags), ("folderId", folderId), ("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gA", gA)])
}
}
@ -22571,32 +22609,6 @@ public extension Api {
return nil
}
}
public static func parse_encryptedChatRequested(_ reader: BufferReader) -> EncryptedChat? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
_5 = reader.readInt32()
var _6: Buffer?
_6 = parseBytes(reader)
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.EncryptedChat.encryptedChatRequested(id: _1!, accessHash: _2!, date: _3!, adminId: _4!, participantId: _5!, gA: _6!)
}
else {
return nil
}
}
public static func parse_encryptedChat(_ reader: BufferReader) -> EncryptedChat? {
var _1: Int32?
_1 = reader.readInt32()
@ -22637,6 +22649,38 @@ public extension Api {
return nil
}
}
public static func parse_encryptedChatRequested(_ reader: BufferReader) -> EncryptedChat? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() }
var _3: Int32?
_3 = reader.readInt32()
var _4: Int64?
_4 = reader.readInt64()
var _5: Int32?
_5 = reader.readInt32()
var _6: Int32?
_6 = reader.readInt32()
var _7: Int32?
_7 = reader.readInt32()
var _8: Buffer?
_8 = parseBytes(reader)
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.EncryptedChat.encryptedChatRequested(flags: _1!, folderId: _2, id: _3!, accessHash: _4!, date: _5!, adminId: _6!, participantId: _7!, gA: _8!)
}
else {
return nil
}
}
}
public enum PeerLocated: TypeConstructorDescription {

View File

@ -6803,12 +6803,12 @@ public extension Api {
})
}
public static func uploadProfilePhoto(flags: Int32, file: Api.InputFile, video: Api.InputFile?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.photos.Photo>) {
public static func uploadProfilePhoto(flags: Int32, file: Api.InputFile?, video: Api.InputFile?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.photos.Photo>) {
let buffer = Buffer()
buffer.appendInt32(770436592)
buffer.appendInt32(28740206)
serializeInt32(flags, buffer: buffer, boxed: false)
file.serialize(buffer, true)
if Int(flags) & Int(1 << 0) != 0 {video!.serialize(buffer, true)}
if Int(flags) & Int(1 << 0) != 0 {file!.serialize(buffer, true)}
if Int(flags) & Int(1 << 1) != 0 {video!.serialize(buffer, true)}
return (FunctionDescription(name: "photos.uploadProfilePhoto", parameters: [("flags", flags), ("file", file), ("video", video)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.photos.Photo? in
let reader = BufferReader(buffer)
var result: Api.photos.Photo?

View File

@ -152,11 +152,11 @@ private final class MultipartUploadManager {
self.progress = progress
self.completed = completed
//if headerSize == 0 {
if headerSize == 0 {
self.headerPartState = .ready
/*} else {
} else {
self.headerPartState = .notStarted
}*/
}
if let hintFileSize = hintFileSize, hintFileSize > 10 * 1024 * 1024 {
self.defaultPartSize = 512 * 1024

View File

@ -78,7 +78,7 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
}
case .encryptedChatEmpty(_):
break
case let .encryptedChatRequested(_, accessHash, date, adminId, participantId, gA):
case let .encryptedChatRequested(_, folderId, _, accessHash, date, adminId, participantId, gA):
if currentPeer == nil && participantId == accountPeerId.id {
if settings.acceptOnThisDevice {
let state = SecretChatState(role: .participant, embeddedState: .handshake(.accepting), keychain: SecretChatKeychain(keys: []), keyFingerprint: nil, messageAutoremoveTimeout: nil)
@ -92,11 +92,15 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: adminId), accessHash: accessHash, role: updatedState.role, embeddedState: updatedState.embeddedState.peerState, messageAutoremoveTimeout: nil)
updatePeers(transaction: transaction, peers: [peer], update: { _, updated in return updated })
if folderId != nil {
transaction.updatePeerChatListInclusion(peer.id, inclusion: .ifHasMessagesOrOneOf(groupId: Namespaces.PeerGroup.archive, pinningIndex: nil, minTimestamp: date))
}
transaction.resetIncomingReadStates([peer.id: [
Namespaces.Message.SecretIncoming: .indexBased(maxIncomingReadIndex: MessageIndex.lowerBound(peerId: peer.id), maxOutgoingReadIndex: MessageIndex.lowerBound(peerId: peer.id), count: 0, markedUnread: false),
Namespaces.Message.Local: .indexBased(maxIncomingReadIndex: MessageIndex.lowerBound(peerId: peer.id), maxOutgoingReadIndex: MessageIndex.lowerBound(peerId: peer.id), count: 0, markedUnread: false)
]
])
])
} else {
assertionFailure()
}

View File

@ -560,7 +560,7 @@ extension Api.EncryptedChat {
return PeerId(namespace: Namespaces.Peer.SecretChat, id: id)
case let .encryptedChatEmpty(id):
return PeerId(namespace: Namespaces.Peer.SecretChat, id: id)
case let .encryptedChatRequested(id, _, _, _, _, _):
case let .encryptedChatRequested(_, _, id, _, _, _, _, _):
return PeerId(namespace: Namespaces.Peer.SecretChat, id: id)
case let .encryptedChatWaiting(id, _, _, _, _):
return PeerId(namespace: Namespaces.Peer.SecretChat, id: id)

View File

@ -376,7 +376,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
case .inline:
navigationBarPresentationData = nil
default:
navigationBarPresentationData = NavigationBarPresentationData(presentationData: self.presentationData, hideBackground: true, hideBadge: false)
navigationBarPresentationData = NavigationBarPresentationData(presentationData: self.presentationData, hideBackground: false, hideBadge: false)
}
super.init(context: context, navigationBarPresentationData: navigationBarPresentationData, mediaAccessoryPanelVisibility: mediaAccessoryPanelVisibility, locationBroadcastPanelSource: locationBroadcastPanelSource)
@ -2808,7 +2808,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if self.hasEmbeddedTitleContent {
navigationBarTheme = NavigationBarTheme(rootControllerTheme: defaultDarkPresentationTheme, hideBackground: true, hideBadge: true)
} else {
navigationBarTheme = NavigationBarTheme(rootControllerTheme: self.presentationData.theme, hideBackground: true, hideBadge: false)
navigationBarTheme = NavigationBarTheme(rootControllerTheme: self.presentationData.theme, hideBackground: false, hideBadge: false)
}
self.navigationBar?.updatePresentationData(NavigationBarPresentationData(theme: navigationBarTheme, strings: NavigationBarStrings(presentationStrings: self.presentationData.strings)))
@ -5085,19 +5085,28 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}
}
if let peekData = self.peekData {
if let peekData = self.peekData, case let .peer(peerId) = self.chatLocation {
let timestamp = Int32(Date().timeIntervalSince1970)
let remainingTime = max(1, peekData.deadline - timestamp)
self.peekTimerDisposable.set((
(
combineLatest(
self.context.account.postbox.peerView(id: peerId),
Signal<Bool, NoError>.single(true)
|> suspendAwareDelay(Double(remainingTime), granularity: 2.0, queue: .mainQueue())
)
|> deliverOnMainQueue
).start(next: { [weak self] _ in
guard let strongSelf = self else {
).start(next: { [weak self] peerView, _ in
guard let strongSelf = self, let peer = peerViewMainPeer(peerView) else {
return
}
if let peer = peer as? TelegramChannel {
switch peer.participationStatus {
case .member:
return
default:
break
}
}
strongSelf.present(textAlertController(
context: strongSelf.context,
title: strongSelf.presentationData.strings.Conversation_PrivateChannelTimeLimitedAlertTitle,

View File

@ -563,7 +563,9 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
self.addSubnode(self.navigateButtons)
self.addSubnode(self.navigationBarBackroundNode)
self.navigationBarBackroundNode.isHidden = true
self.addSubnode(self.navigationBarSeparatorNode)
self.navigationBarSeparatorNode.isHidden = true
self.historyNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:))))
@ -1449,10 +1451,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
transition.updateFrame(node: self.navigateButtons, frame: apparentNavigateButtonsFrame)
if let titleAccessoryPanelNode = self.titleAccessoryPanelNode, let titleAccessoryPanelFrame = titleAccessoryPanelFrame, !titleAccessoryPanelNode.frame.equalTo(titleAccessoryPanelFrame) {
if immediatelyLayoutTitleAccessoryPanelNodeAndAnimateAppearance {
titleAccessoryPanelNode.frame = titleAccessoryPanelFrame.offsetBy(dx: 0.0, dy: -titleAccessoryPanelFrame.size.height)
}
transition.updateFrame(node: titleAccessoryPanelNode, frame: titleAccessoryPanelFrame)
titleAccessoryPanelNode.frame = titleAccessoryPanelFrame
transition.animatePositionAdditive(node: titleAccessoryPanelNode, offset: CGPoint(x: 0.0, y: -titleAccessoryPanelFrame.height))
}
if let inputPanelNode = self.inputPanelNode, let apparentInputPanelFrame = apparentInputPanelFrame, !inputPanelNode.frame.equalTo(apparentInputPanelFrame) {
@ -1865,6 +1865,12 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
self.emptyNode?.isHidden = false
}
var showNavigateButtons = true
if let _ = chatPresentationInterfaceState.inputTextPanelState.mediaRecordingState {
showNavigateButtons = false
}
transition.updateAlpha(node: self.navigateButtons, alpha: showNavigateButtons ? 1.0 : 0.0)
if let openStickersDisposable = self.openStickersDisposable {
if case .media = chatPresentationInterfaceState.inputMode {
} else {
@ -2685,6 +2691,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
}
func updateEmbeddedTitlePeekContent(content: NavigationControllerDropContent?) {
return;
guard let (_, navigationHeight) = self.validLayout else {
return
}
@ -2711,6 +2719,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
var updateHasEmbeddedTitleContent: (() -> Void)?
func acceptEmbeddedTitlePeekContent(content: NavigationControllerDropContent) -> Bool {
return false;
guard let (_, navigationHeight) = self.validLayout else {
return false
}

View File

@ -1049,12 +1049,12 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
self.addSubnode(audioRecordingDotNode)
}
animateDotAppearing = transition.isAnimated && !isLocked && !hideInfo
animateDotAppearing = transition.isAnimated && !hideInfo
audioRecordingDotNode.frame = CGRect(origin: CGPoint(x: leftInset + 2.0 - UIScreenPixel, y: panelHeight - 44 + 1), size: CGSize(width: 40.0, height: 40))
if animateDotAppearing {
audioRecordingDotNode.layer.animateScale(from: 0.3, to: 1, duration: 0.15, delay: 0, removeOnCompletion: false)
audioRecordingDotNode.layer.animateAlpha(from: 0, to: 1, duration: 0.15, delay: 0, completion: { [weak audioRecordingDotNode] finished in
audioRecordingDotNode.layer.animateAlpha(from: CGFloat(audioRecordingDotNode.layer.presentation()?.opacity ?? 1), to: 1, duration: 0.15, delay: 0, completion: { [weak audioRecordingDotNode] finished in
if finished {
let animation = CAKeyframeAnimation(keyPath: "opacity")
animation.values = [1.0 as NSNumber, 1.0 as NSNumber, 0.0 as NSNumber]
@ -1067,7 +1067,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
}
})
self.attachmentButton.layer.animateAlpha(from: 1, to: 0, duration: 0.15, delay: 0, removeOnCompletion: false)
self.attachmentButton.layer.animateAlpha(from: CGFloat(self.attachmentButton.layer.presentation()?.opacity ?? 1), to: 0, duration: 0.15, delay: 0, removeOnCompletion: false)
self.attachmentButton.layer.animateScale(from: 1, to: 0.3, duration: 0.15, delay: 0, removeOnCompletion: false)
}