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

This commit is contained in:
Ilya Laktyushin 2021-01-24 21:36:21 +03:00
commit 10612a88a4
10 changed files with 88 additions and 46 deletions

View File

@ -123,6 +123,16 @@ class BazelCommandLine:
# Build single-architecture binaries. It is almost 2 times faster is 32-bit support is not required. # Build single-architecture binaries. It is almost 2 times faster is 32-bit support is not required.
'--ios_multi_cpus=arm64', '--ios_multi_cpus=arm64',
# Always build universal Watch binaries.
'--watchos_cpus=armv7k,arm64_32'
] + self.common_debug_args
elif configuration == 'debug_armv7':
self.configuration_args = [
# bazel debug build configuration
'-c', 'dbg',
'--ios_multi_cpus=armv7',
# Always build universal Watch binaries. # Always build universal Watch binaries.
'--watchos_cpus=armv7k,arm64_32' '--watchos_cpus=armv7k,arm64_32'
] + self.common_debug_args ] + self.common_debug_args
@ -465,6 +475,7 @@ if __name__ == '__main__':
'--configuration', '--configuration',
choices=[ choices=[
'debug_arm64', 'debug_arm64',
'debug_armv7',
'release_arm64', 'release_arm64',
'release_universal' 'release_universal'
], ],

View File

@ -17,9 +17,15 @@ import ConfettiEffect
import TelegramUniversalVideoContent import TelegramUniversalVideoContent
public final class ChatImportActivityScreen: ViewController { public final class ChatImportActivityScreen: ViewController {
enum ImportError {
case generic
case chatAdminRequired
case invalidChatType
}
private enum State { private enum State {
case progress(CGFloat) case progress(CGFloat)
case error case error(ImportError)
case done case done
} }
@ -213,8 +219,17 @@ public final class ChatImportActivityScreen: ViewController {
switch self.state { switch self.state {
case .progress: case .progress:
self.statusText.attributedText = NSAttributedString(string: "Please keep this window open\nduring the import.", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemSecondaryTextColor) self.statusText.attributedText = NSAttributedString(string: "Please keep this window open\nduring the import.", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemSecondaryTextColor)
case .error: case let .error(error):
self.statusText.attributedText = NSAttributedString(string: "An error occurred.", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemDestructiveColor) let errorText: String
switch error {
case .chatAdminRequired:
errorText = "You need to be an admin."
case .invalidChatType:
errorText = "You can't import this history in this type of chat."
case .generic:
errorText = "An error occurred."
}
self.statusText.attributedText = NSAttributedString(string: errorText, font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemDestructiveColor)
case .done: case .done:
self.statusText.attributedText = NSAttributedString(string: "This chat has been imported\nsuccessfully.", font: Font.semibold(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor) self.statusText.attributedText = NSAttributedString(string: "This chat has been imported\nsuccessfully.", font: Font.semibold(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
} }
@ -427,10 +442,6 @@ public final class ChatImportActivityScreen: ViewController {
} }
private func beginImport() { private func beginImport() {
enum ImportError {
case generic
}
for (key, value) in self.pendingEntries { for (key, value) in self.pendingEntries {
self.pendingEntries[key] = (value.0, 0.0) self.pendingEntries[key] = (value.0, 0.0)
} }
@ -459,8 +470,15 @@ public final class ChatImportActivityScreen: ViewController {
} }
return ChatHistoryImport.initSession(account: context.account, peerId: peerId, file: mainEntry, mediaCount: Int32(otherEntries.count)) return ChatHistoryImport.initSession(account: context.account, peerId: peerId, file: mainEntry, mediaCount: Int32(otherEntries.count))
|> mapError { _ -> ImportError in |> mapError { error -> ImportError in
return .generic switch error {
case .chatAdminRequired:
return .chatAdminRequired
case .invalidChatType:
return .invalidChatType
case .generic:
return .generic
}
} }
} }
|> mapToSignal { session -> Signal<(String, Float), ImportError> in |> mapToSignal { session -> Signal<(String, Float), ImportError> in
@ -531,11 +549,11 @@ public final class ChatImportActivityScreen: ViewController {
totalProgress = CGFloat(totalDoneBytes) / CGFloat(strongSelf.totalBytes) totalProgress = CGFloat(totalDoneBytes) / CGFloat(strongSelf.totalBytes)
} }
strongSelf.controllerNode.updateState(state: .progress(totalProgress), animated: true) strongSelf.controllerNode.updateState(state: .progress(totalProgress), animated: true)
}, error: { [weak self] _ in }, error: { [weak self] error in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
strongSelf.controllerNode.updateState(state: .error, animated: true) strongSelf.controllerNode.updateState(state: .error(error), animated: true)
}, completed: { [weak self] in }, completed: { [weak self] in
guard let strongSelf = self else { guard let strongSelf = self else {
return return

View File

@ -958,7 +958,11 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
} else if let message = messages.last, let author = message.author as? TelegramUser, let peer = itemPeer.chatMainPeer, !(peer is TelegramUser) { } else if let message = messages.last, let author = message.author as? TelegramUser, let peer = itemPeer.chatMainPeer, !(peer is TelegramUser) {
if let peer = peer as? TelegramChannel, case .broadcast = peer.info { if let peer = peer as? TelegramChannel, case .broadcast = peer.info {
} else if !displayAsMessage { } else if !displayAsMessage {
peerText = author.id == account.peerId ? item.presentationData.strings.DialogList_You : author.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder) if let forwardInfo = message.forwardInfo, forwardInfo.flags.contains(.isImported), let authorSignature = forwardInfo.authorSignature {
peerText = authorSignature
} else {
peerText = author.id == account.peerId ? item.presentationData.strings.DialogList_You : author.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
}
} }
} }

View File

@ -139,7 +139,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1511503333] = { return Api.InputEncryptedFile.parse_inputEncryptedFile($0) } dict[1511503333] = { return Api.InputEncryptedFile.parse_inputEncryptedFile($0) }
dict[767652808] = { return Api.InputEncryptedFile.parse_inputEncryptedFileBigUploaded($0) } dict[767652808] = { return Api.InputEncryptedFile.parse_inputEncryptedFileBigUploaded($0) }
dict[-1456996667] = { return Api.messages.InactiveChats.parse_inactiveChats($0) } dict[-1456996667] = { return Api.messages.InactiveChats.parse_inactiveChats($0) }
dict[-1199443157] = { return Api.GroupCallParticipant.parse_groupCallParticipant($0) } dict[1690708501] = { return Api.GroupCallParticipant.parse_groupCallParticipant($0) }
dict[1443858741] = { return Api.messages.SentEncryptedMessage.parse_sentEncryptedMessage($0) } dict[1443858741] = { return Api.messages.SentEncryptedMessage.parse_sentEncryptedMessage($0) }
dict[-1802240206] = { return Api.messages.SentEncryptedMessage.parse_sentEncryptedFile($0) } dict[-1802240206] = { return Api.messages.SentEncryptedMessage.parse_sentEncryptedFile($0) }
dict[1571494644] = { return Api.ExportedMessageLink.parse_exportedMessageLink($0) } dict[1571494644] = { return Api.ExportedMessageLink.parse_exportedMessageLink($0) }

View File

@ -5510,13 +5510,13 @@ public extension Api {
} }
public enum GroupCallParticipant: TypeConstructorDescription { public enum GroupCallParticipant: TypeConstructorDescription {
case groupCallParticipant(flags: Int32, userId: Int32, date: Int32, activeDate: Int32?, source: Int32, volume: Int32?, mutedCnt: Int32?) case groupCallParticipant(flags: Int32, userId: Int32, date: Int32, activeDate: Int32?, source: Int32, volume: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .groupCallParticipant(let flags, let userId, let date, let activeDate, let source, let volume, let mutedCnt): case .groupCallParticipant(let flags, let userId, let date, let activeDate, let source, let volume):
if boxed { if boxed {
buffer.appendInt32(-1199443157) buffer.appendInt32(1690708501)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(userId, buffer: buffer, boxed: false) serializeInt32(userId, buffer: buffer, boxed: false)
@ -5524,15 +5524,14 @@ public extension Api {
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(activeDate!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 3) != 0 {serializeInt32(activeDate!, buffer: buffer, boxed: false)}
serializeInt32(source, buffer: buffer, boxed: false) serializeInt32(source, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 7) != 0 {serializeInt32(volume!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 7) != 0 {serializeInt32(volume!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 8) != 0 {serializeInt32(mutedCnt!, buffer: buffer, boxed: false)}
break break
} }
} }
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .groupCallParticipant(let flags, let userId, let date, let activeDate, let source, let volume, let mutedCnt): case .groupCallParticipant(let flags, let userId, let date, let activeDate, let source, let volume):
return ("groupCallParticipant", [("flags", flags), ("userId", userId), ("date", date), ("activeDate", activeDate), ("source", source), ("volume", volume), ("mutedCnt", mutedCnt)]) return ("groupCallParticipant", [("flags", flags), ("userId", userId), ("date", date), ("activeDate", activeDate), ("source", source), ("volume", volume)])
} }
} }
@ -5549,17 +5548,14 @@ public extension Api {
_5 = reader.readInt32() _5 = reader.readInt32()
var _6: Int32? var _6: Int32?
if Int(_1!) & Int(1 << 7) != 0 {_6 = reader.readInt32() } if Int(_1!) & Int(1 << 7) != 0 {_6 = reader.readInt32() }
var _7: Int32?
if Int(_1!) & Int(1 << 8) != 0 {_7 = reader.readInt32() }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 3) == 0) || _4 != nil let _c4 = (Int(_1!) & Int(1 << 3) == 0) || _4 != nil
let _c5 = _5 != nil let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 7) == 0) || _6 != nil let _c6 = (Int(_1!) & Int(1 << 7) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 8) == 0) || _7 != nil if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { return Api.GroupCallParticipant.groupCallParticipant(flags: _1!, userId: _2!, date: _3!, activeDate: _4, source: _5!, volume: _6)
return Api.GroupCallParticipant.groupCallParticipant(flags: _1!, userId: _2!, date: _3!, activeDate: _4, source: _5!, volume: _6, mutedCnt: _7)
} }
else { else {
return nil return nil

View File

@ -14,6 +14,8 @@ public enum ChatHistoryImport {
public enum InitImportError { public enum InitImportError {
case generic case generic
case chatAdminRequired
case invalidChatType
} }
public enum ParsedInfo { public enum ParsedInfo {
@ -63,8 +65,15 @@ public enum ChatHistoryImport {
return .fail(.generic) return .fail(.generic)
} }
return account.network.request(Api.functions.messages.initHistoryImport(peer: inputPeer, file: inputFile, mediaCount: mediaCount)) return account.network.request(Api.functions.messages.initHistoryImport(peer: inputPeer, file: inputFile, mediaCount: mediaCount))
|> mapError { _ -> InitImportError in |> mapError { error -> InitImportError in
return .generic switch error.errorDescription {
case "CHAT_ADMIN_REQUIRED":
return .chatAdminRequired
case "IMPORT_PEER_TYPE_INVALID":
return .invalidChatType
default:
return .generic
}
} }
|> map { result -> Session in |> map { result -> Session in
switch result { switch result {

View File

@ -88,7 +88,7 @@ public func getCurrentGroupCall(account: Account, callId: Int64, accessHash: Int
loop: for participant in participants { loop: for participant in participants {
switch participant { switch participant {
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume, mutedCnt): case let .groupCallParticipant(flags, userId, date, activeDate, source, volume):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId) let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
let ssrc = UInt32(bitPattern: source) let ssrc = UInt32(bitPattern: source)
guard let peer = transaction.getPeer(peerId) else { guard let peer = transaction.getPeer(peerId) else {
@ -228,7 +228,7 @@ public func getGroupCallParticipants(account: Account, callId: Int64, accessHash
loop: for participant in participants { loop: for participant in participants {
switch participant { switch participant {
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume, mutedCnt): case let .groupCallParticipant(flags, userId, date, activeDate, source, volume):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId) let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
let ssrc = UInt32(bitPattern: source) let ssrc = UInt32(bitPattern: source)
guard let peer = transaction.getPeer(peerId) else { guard let peer = transaction.getPeer(peerId) else {
@ -1194,7 +1194,7 @@ public final class GroupCallParticipantsContext {
extension GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate { extension GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate {
init(_ apiParticipant: Api.GroupCallParticipant) { init(_ apiParticipant: Api.GroupCallParticipant) {
switch apiParticipant { switch apiParticipant {
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume, mutedCnt): case let .groupCallParticipant(flags, userId, date, activeDate, source, volume):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId) let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
let ssrc = UInt32(bitPattern: source) let ssrc = UInt32(bitPattern: source)
let muted = (flags & (1 << 0)) != 0 let muted = (flags & (1 << 0)) != 0
@ -1236,7 +1236,7 @@ extension GroupCallParticipantsContext.Update.StateUpdate {
var participantUpdates: [GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate] = [] var participantUpdates: [GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate] = []
for participant in participants { for participant in participants {
switch participant { switch participant {
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume, mutedCnt): case let .groupCallParticipant(flags, userId, date, activeDate, source, volume):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId) let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
let ssrc = UInt32(bitPattern: source) let ssrc = UInt32(bitPattern: source)
let muted = (flags & (1 << 0)) != 0 let muted = (flags & (1 << 0)) != 0

View File

@ -62,19 +62,15 @@ final class ChatMessageAvatarAccessoryItem: ListViewAccessoryItem {
if abs(effectiveTimestamp - effectiveOtherTimestamp) >= 10 * 60 { if abs(effectiveTimestamp - effectiveOtherTimestamp) >= 10 * 60 {
return false return false
} }
if let forwardInfo = self.forwardInfo, let otherForwardInfo = other.forwardInfo { if let forwardInfo = self.forwardInfo, let otherForwardInfo = other.forwardInfo, forwardInfo.flags.contains(.isImported), otherForwardInfo.flags.contains(.isImported) {
if forwardInfo.flags.contains(.isImported) && forwardInfo.flags.contains(.isImported) == forwardInfo.flags.contains(.isImported) { if let authorSignature = forwardInfo.authorSignature, let otherAuthorSignature = otherForwardInfo.authorSignature {
if let authorSignature = forwardInfo.authorSignature, let otherAuthorSignature = otherForwardInfo.authorSignature { if authorSignature != otherAuthorSignature {
if authorSignature != otherAuthorSignature { return false
return false }
} } else if let authorId = forwardInfo.author?.id, let otherAuthorId = other.forwardInfo?.author?.id {
} else if let authorId = forwardInfo.author?.id, let otherAuthorId = other.forwardInfo?.author?.id { if authorId != otherAuthorId {
if authorId != otherAuthorId { return false
return false
}
} }
} else {
return false
} }
} else if let forwardInfo = self.forwardInfo, forwardInfo.flags.contains(.isImported) { } else if let forwardInfo = self.forwardInfo, forwardInfo.flags.contains(.isImported) {
return false return false

View File

@ -534,9 +534,16 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
let addedWidth = intersection.width + 20 let addedWidth = intersection.width + 20
fittedLayoutSize.width += addedWidth fittedLayoutSize.width += addedWidth
} }
if let statusFrameValue = statusFrame, let iconFrame = iconFrame, iconFrame.intersects(statusFrameValue) { if let statusFrameValue = statusFrame, let iconFrame = iconFrame {
fittedLayoutSize.height += 15.0 if iconFrame.intersects(statusFrameValue) {
statusFrame = statusFrameValue.offsetBy(dx: 0.0, dy: 15.0) fittedLayoutSize.height += 15.0
statusFrame = statusFrameValue.offsetBy(dx: 0.0, dy: 15.0)
}
} else if let statusFrameValue = statusFrame {
if progressFrame.intersects(statusFrameValue) {
fittedLayoutSize.height += 10.0
statusFrame = statusFrameValue.offsetBy(dx: 0.0, dy: 15.0)
}
} }
if (isAudio && !isVoice) || file.previewRepresentations.isEmpty { if (isAudio && !isVoice) || file.previewRepresentations.isEmpty {

View File

@ -3266,7 +3266,8 @@ common_arm_specific_sources = ["webrtc-ios/src/" + path for path in [
]] ]]
armv7_specific_sources = ["webrtc-ios/src/" + path for path in [ armv7_specific_sources = ["webrtc-ios/src/" + path for path in [
"common_audio/signal_processing/filter_ar_fast_q12.c",
"common_audio/signal_processing/complex_bit_reverse.c",
]] ]]
arm64_specific_sources = ["webrtc-ios/src/" + path for path in [ arm64_specific_sources = ["webrtc-ios/src/" + path for path in [