Various fixes

This commit is contained in:
Ilya Laktyushin 2021-02-11 23:20:03 +04:00
commit 172aa38270
20 changed files with 241 additions and 86 deletions

View File

@ -793,7 +793,7 @@ class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessag
if let searchTerm = searchTerm {
if !searchTerm.isEmpty {
for renderedPeer in transaction.searchPeers(query: searchTerm) {
if let peer = renderedPeer.peer, !(peer is TelegramSecretChat) {
if let peer = renderedPeer.peer, !(peer is TelegramSecretChat), !peer.isDeleted {
peers.append(peer)
}
}
@ -804,7 +804,7 @@ class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessag
}
} else {
for renderedPeer in transaction.getTopChatListEntries(groupId: .root, count: 50) {
if let peer = renderedPeer.peer, !(peer is TelegramSecretChat) {
if let peer = renderedPeer.peer, !(peer is TelegramSecretChat), !peer.isDeleted {
peers.append(peer)
}
}

View File

@ -369,12 +369,12 @@ struct WidgetView: View {
}
}
private func linkForPeer(id: Int64) -> String {
private func linkForPeer(accountId: Int64, id: Int64) -> String {
switch self.widgetFamily {
case .systemSmall:
return "\(buildConfig.appSpecificUrlScheme)://"
default:
return "\(buildConfig.appSpecificUrlScheme)://localpeer?id=\(id)"
return "\(buildConfig.appSpecificUrlScheme)://localpeer?id=\(id)&accountId=\(accountId)"
}
}
@ -427,7 +427,7 @@ struct WidgetView: View {
return ZStack {
ForEach(0 ..< min(peers.peers.count, columnCount * rowCount), content: { i in
Link(destination: URL(string: linkForPeer(id: peers.peers[i].peer.id))!, label: {
Link(destination: URL(string: linkForPeer(accountId: peers.peers[i].accountId, id: peers.peers[i].peer.id))!, label: {
AvatarItemView(
peer: peers.peers[i],
itemSize: itemSize
@ -507,13 +507,29 @@ struct WidgetView: View {
case .text:
break
case .image:
text = "🖼 Photo"
if !message.text.isEmpty {
text = "🖼 \(message.text)"
} else {
text = "🖼 Photo"
}
case .video:
text = "📹 Video"
if !message.text.isEmpty {
text = "📹 \(message.text)"
} else {
text = "📹 Video"
}
case .gif:
text = "Gif"
if !message.text.isEmpty {
text = "\(message.text)"
} else {
text = "Gif"
}
case let .file(file):
text = "📎 \(file.name)"
if !message.text.isEmpty {
text = "📹 \(message.text)"
} else {
text = "📎 \(file.name)"
}
case let .music(music):
if !music.title.isEmpty && !music.artist.isEmpty {
text = "\(music.artist)\(music.title)"
@ -611,9 +627,11 @@ struct WidgetView: View {
func chatContentView(_ index: Int, size: CGSize) -> AnyView {
let peers: ParsedPeers?
var isPlaceholder = false
switch data {
case let .peers(peersValue):
if peersValue.peers.count <= index {
isPlaceholder = peersValue.peers.count != 0
peers = nil
} else {
peers = peersValue
@ -624,9 +642,15 @@ struct WidgetView: View {
let itemHeight = (size.height - 22.0) / 2.0
if isPlaceholder {
return AnyView(Spacer()
.frame(width: size.width, height: itemHeight, alignment: .leading)
)
}
let url: URL
if let peers = peers {
url = URL(string: linkForPeer(id: peers.peers[index].peer.id))!
url = URL(string: linkForPeer(accountId: peers.peers[index].accountId, id: peers.peers[index].peer.id))!
} else {
url = URL(string: "\(buildConfig.appSpecificUrlScheme)://")!
}

View File

@ -60,6 +60,7 @@ public enum AnimatedStickerPlaybackPosition {
public enum AnimatedStickerPlaybackMode {
case once
case count(Int)
case loop
case still(AnimatedStickerPlaybackPosition)
}
@ -757,6 +758,7 @@ public final class AnimatedStickerNode: ASDisplayNode {
private var renderer: (AnimationRenderer & ASDisplayNode)?
public var isPlaying: Bool = false
private var currentLoopCount: Int = 0
private var canDisplayFirstFrame: Bool = false
private var playbackMode: AnimatedStickerPlaybackMode = .loop
@ -910,8 +912,14 @@ public final class AnimatedStickerNode: ASDisplayNode {
private var isSetUpForPlayback = false
public func play(firstFrame: Bool = false) {
if case .once = self.playbackMode {
switch self.playbackMode {
case .once:
self.isPlaying = true
case .count:
self.currentLoopCount = 0
self.isPlaying = true
default:
break
}
if self.isSetUpForPlayback {
let directData = self.directData
@ -976,6 +984,11 @@ public final class AnimatedStickerNode: ASDisplayNode {
var stopNow = false
if case .once = strongSelf.playbackMode {
stopNow = true
} else if case let .count(count) = strongSelf.playbackMode {
strongSelf.currentLoopCount += 1
if count <= strongSelf.currentLoopCount {
stopNow = true
}
} else if strongSelf.stopAtNearestLoop {
stopNow = true
}
@ -1061,6 +1074,11 @@ public final class AnimatedStickerNode: ASDisplayNode {
var stopNow = false
if case .once = strongSelf.playbackMode {
stopNow = true
} else if case let .count(count) = strongSelf.playbackMode {
strongSelf.currentLoopCount += 1
if count <= strongSelf.currentLoopCount {
stopNow = true
}
} else if strongSelf.stopAtNearestLoop {
stopNow = true
}

View File

@ -106,11 +106,14 @@ class ChatListFilterSettingsHeaderItemNode: ListViewItemNode {
let makeTitleLayout = TextNode.asyncLayout(self.titleNode)
return { item, params, neighbors in
let isHidden = params.width > params.availableHeight && params.availableHeight < 400.0
let leftInset: CGFloat = 32.0 + params.leftInset
let animationName: String
var size = 192
var insetDifference = 100
var additionalBottomInset: CGFloat = 0.0
var playbackMode: AnimatedStickerPlaybackMode = .once
switch item.animation {
case .folders:
@ -123,7 +126,8 @@ class ChatListFilterSettingsHeaderItemNode: ListViewItemNode {
animationName = "MessageAutoRemove"
size = 260
insetDifference = 120
playbackMode = .loop
playbackMode = .count(2)
additionalBottomInset = isHidden ? 8.0 : 16.0
}
let topInset: CGFloat = CGFloat(size - insetDifference)
@ -132,9 +136,14 @@ class ChatListFilterSettingsHeaderItemNode: ListViewItemNode {
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: attributedText, backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: params.width - params.rightInset - leftInset * 2.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
let contentSize = CGSize(width: params.width, height: topInset + titleLayout.size.height)
let insets = itemListNeighborsGroupedInsets(neighbors)
var insets = itemListNeighborsGroupedInsets(neighbors)
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
if isHidden {
insets = UIEdgeInsets()
}
insets.bottom += additionalBottomInset
let layout = ListViewItemNodeLayout(contentSize: isHidden ? CGSize(width: params.width, height: 0.0) : contentSize, insets: insets)
return (layout, { [weak self] in
if let strongSelf = self {
@ -154,6 +163,9 @@ class ChatListFilterSettingsHeaderItemNode: ListViewItemNode {
let _ = titleApply()
strongSelf.titleNode.frame = CGRect(origin: CGPoint(x: floor((layout.size.width - titleLayout.size.width) / 2.0), y: topInset + 8.0), size: titleLayout.size)
strongSelf.animationNode.alpha = isHidden ? 0.0 : 1.0
strongSelf.titleNode.alpha = isHidden ? 0.0 : 1.0
}
})
}

View File

@ -32,13 +32,11 @@ private enum PeerAutoremoveSetupEntry: ItemListNodeEntry {
case timeHeader(String)
case timeValue(Int32, Int32, [Int32])
case timeComment(String)
case globalSwitch(String, Bool)
case globalSwitch(String, Bool, Bool)
var section: ItemListSectionId {
switch self {
case .header:
return PeerAutoremoveSetupSection.header.rawValue
case .timeHeader, .timeValue, .timeComment:
case .header, .timeHeader, .timeValue, .timeComment:
return PeerAutoremoveSetupSection.time.rawValue
case .globalSwitch:
return PeerAutoremoveSetupSection.global.rawValue
@ -86,8 +84,8 @@ private enum PeerAutoremoveSetupEntry: ItemListNodeEntry {
} else {
return false
}
case let .globalSwitch(lhsText, lhsValue):
if case let .globalSwitch(rhsText, rhsValue) = rhs, lhsText == rhsText, lhsValue == rhsValue {
case let .globalSwitch(lhsText, lhsValue, lhsEnable):
if case let .globalSwitch(rhsText, rhsValue, rhsEnable) = rhs, lhsText == rhsText, lhsValue == rhsValue, lhsEnable == rhsEnable {
return true
} else {
return false
@ -112,8 +110,8 @@ private enum PeerAutoremoveSetupEntry: ItemListNodeEntry {
}, tag: nil)
case let .timeComment(text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
case let .globalSwitch(text, value):
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in
case let .globalSwitch(text, value, enabled):
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, enabled: enabled, maximumNumberOfLines: 2, sectionId: self.section, style: .blocks, updated: { value in
arguments.toggleGlobal(value)
})
}
@ -150,9 +148,9 @@ private func peerAutoremoveSetupEntries(peer: Peer?, presentationData: Presentat
24 * 60 * 60 * 7,
Int32.max
]
if isDebug {
availableValues[0] = 5
availableValues[1] = 60
if isDebug || true {
availableValues[0] = 60
availableValues[1] = 5 * 60
}
entries.append(.timeValue(resolvedValue, resolvedMaxValue, availableValues))
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
@ -165,7 +163,7 @@ private func peerAutoremoveSetupEntries(peer: Peer?, presentationData: Presentat
}
}
if let user = peer as? TelegramUser {
entries.append(.globalSwitch("Also auto-delete for \(user.compactDisplayTitle)", globalValue))
entries.append(.globalSwitch("Also auto-delete for \(user.compactDisplayTitle)", globalValue, resolvedValue != Int32.max))
}
return entries

View File

@ -142,7 +142,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1511503333] = { return Api.InputEncryptedFile.parse_inputEncryptedFile($0) }
dict[767652808] = { return Api.InputEncryptedFile.parse_inputEncryptedFileBigUploaded($0) }
dict[-1456996667] = { return Api.messages.InactiveChats.parse_inactiveChats($0) }
dict[-817921892] = { return Api.GroupCallParticipant.parse_groupCallParticipant($0) }
dict[1690708501] = { return Api.GroupCallParticipant.parse_groupCallParticipant($0) }
dict[1443858741] = { return Api.messages.SentEncryptedMessage.parse_sentEncryptedMessage($0) }
dict[-1802240206] = { return Api.messages.SentEncryptedMessage.parse_sentEncryptedFile($0) }
dict[1571494644] = { return Api.ExportedMessageLink.parse_exportedMessageLink($0) }
@ -460,6 +460,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-384910503] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionExportedInviteEdit($0) }
dict[1557846647] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionParticipantJoinByInvite($0) }
dict[1048537159] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionParticipantVolume($0) }
dict[1855199800] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeHistoryTTL($0) }
dict[-543777747] = { return Api.auth.ExportedAuthorization.parse_exportedAuthorization($0) }
dict[2103482845] = { return Api.SecurePlainData.parse_securePlainPhone($0) }
dict[569137759] = { return Api.SecurePlainData.parse_securePlainEmail($0) }

View File

@ -3638,13 +3638,13 @@ public extension Api {
}
public enum GroupCallParticipant: TypeConstructorDescription {
case groupCallParticipant(flags: Int32, userId: Int32, date: Int32, activeDate: Int32?, source: Int32, volume: Int32?, params: Api.DataJSON?)
case groupCallParticipant(flags: Int32, userId: Int32, date: Int32, activeDate: Int32?, source: Int32, volume: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .groupCallParticipant(let flags, let userId, let date, let activeDate, let source, let volume, let params):
case .groupCallParticipant(let flags, let userId, let date, let activeDate, let source, let volume):
if boxed {
buffer.appendInt32(-817921892)
buffer.appendInt32(1690708501)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(userId, buffer: buffer, boxed: false)
@ -3652,15 +3652,14 @@ public extension Api {
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(activeDate!, 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 << 10) != 0 {params!.serialize(buffer, true)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .groupCallParticipant(let flags, let userId, let date, let activeDate, let source, let volume, let params):
return ("groupCallParticipant", [("flags", flags), ("userId", userId), ("date", date), ("activeDate", activeDate), ("source", source), ("volume", volume), ("params", params)])
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)])
}
}
@ -3677,19 +3676,14 @@ public extension Api {
_5 = reader.readInt32()
var _6: Int32?
if Int(_1!) & Int(1 << 7) != 0 {_6 = reader.readInt32() }
var _7: Api.DataJSON?
if Int(_1!) & Int(1 << 10) != 0 {if let signature = reader.readInt32() {
_7 = Api.parse(reader, signature: signature) as? Api.DataJSON
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 3) == 0) || _4 != nil
let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 7) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 10) == 0) || _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.GroupCallParticipant.groupCallParticipant(flags: _1!, userId: _2!, date: _3!, activeDate: _4, source: _5!, volume: _6, params: _7)
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.GroupCallParticipant.groupCallParticipant(flags: _1!, userId: _2!, date: _3!, activeDate: _4, source: _5!, volume: _6)
}
else {
return nil
@ -11095,6 +11089,7 @@ public extension Api {
case channelAdminLogEventActionExportedInviteEdit(prevInvite: Api.ExportedChatInvite, newInvite: Api.ExportedChatInvite)
case channelAdminLogEventActionParticipantJoinByInvite(invite: Api.ExportedChatInvite)
case channelAdminLogEventActionParticipantVolume(participant: Api.GroupCallParticipant)
case channelAdminLogEventActionChangeHistoryTTL(prevValue: Int32, newValue: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -11297,6 +11292,13 @@ public extension Api {
}
participant.serialize(buffer, true)
break
case .channelAdminLogEventActionChangeHistoryTTL(let prevValue, let newValue):
if boxed {
buffer.appendInt32(1855199800)
}
serializeInt32(prevValue, buffer: buffer, boxed: false)
serializeInt32(newValue, buffer: buffer, boxed: false)
break
}
}
@ -11364,6 +11366,8 @@ public extension Api {
return ("channelAdminLogEventActionParticipantJoinByInvite", [("invite", invite)])
case .channelAdminLogEventActionParticipantVolume(let participant):
return ("channelAdminLogEventActionParticipantVolume", [("participant", participant)])
case .channelAdminLogEventActionChangeHistoryTTL(let prevValue, let newValue):
return ("channelAdminLogEventActionChangeHistoryTTL", [("prevValue", prevValue), ("newValue", newValue)])
}
}
@ -11795,6 +11799,20 @@ public extension Api {
return nil
}
}
public static func parse_channelAdminLogEventActionChangeHistoryTTL(_ reader: BufferReader) -> ChannelAdminLogEventAction? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.ChannelAdminLogEventAction.channelAdminLogEventActionChangeHistoryTTL(prevValue: _1!, newValue: _2!)
}
else {
return nil
}
}
}
public enum SecurePlainData: TypeConstructorDescription {

View File

@ -4707,6 +4707,20 @@ public extension Api {
return result
})
}
public static func convertToGigagroup(channel: Api.InputChannel) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(187239529)
channel.serialize(buffer, true)
return (FunctionDescription(name: "channels.convertToGigagroup", parameters: [("channel", channel)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Updates
}
return result
})
}
}
public struct payments {
public static func getPaymentForm(msgId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.payments.PaymentForm>) {

View File

@ -247,6 +247,8 @@ public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: Pe
case let .channelAdminLogEventActionParticipantVolume(participant):
let parsedParticipant = GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate(participant)
action = .groupCallUpdateParticipantVolume(peerId: parsedParticipant.peerId, volume: parsedParticipant.volume ?? 10000)
case let .channelAdminLogEventActionChangeHistoryTTL(prevValue, newValue):
action = nil
}
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
if let action = action {

View File

@ -88,7 +88,7 @@ public func getCurrentGroupCall(account: Account, callId: Int64, accessHash: Int
loop: for participant in participants {
switch participant {
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume, params):
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
let ssrc = UInt32(bitPattern: source)
guard let peer = transaction.getPeer(peerId) else {
@ -104,12 +104,12 @@ public func getCurrentGroupCall(account: Account, callId: Int64, accessHash: Int
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: false, mutedByYou: mutedByYou)
}
var jsonParams: String?
if let params = params {
/*if let params = params {
switch params {
case let .dataJSON(data):
jsonParams = data
}
}
}*/
parsedParticipants.append(GroupCallParticipantsContext.Participant(
peer: peer,
ssrc: ssrc,
@ -236,7 +236,7 @@ public func getGroupCallParticipants(account: Account, callId: Int64, accessHash
loop: for participant in participants {
switch participant {
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume, params):
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
let ssrc = UInt32(bitPattern: source)
guard let peer = transaction.getPeer(peerId) else {
@ -252,12 +252,12 @@ public func getGroupCallParticipants(account: Account, callId: Int64, accessHash
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: false, mutedByYou: mutedByYou)
}
var jsonParams: String?
if let params = params {
/*if let params = params {
switch params {
case let .dataJSON(data):
jsonParams = data
}
}
}*/
parsedParticipants.append(GroupCallParticipantsContext.Participant(
peer: peer,
ssrc: ssrc,
@ -1363,7 +1363,7 @@ public final class GroupCallParticipantsContext {
extension GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate {
init(_ apiParticipant: Api.GroupCallParticipant) {
switch apiParticipant {
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume, params):
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
let ssrc = UInt32(bitPattern: source)
let muted = (flags & (1 << 0)) != 0
@ -1388,12 +1388,12 @@ extension GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate {
}
var jsonParams: String?
if let params = params {
/*if let params = params {
switch params {
case let .dataJSON(data):
jsonParams = data
}
}
}*/
self.init(
peerId: peerId,
@ -1414,7 +1414,7 @@ extension GroupCallParticipantsContext.Update.StateUpdate {
var participantUpdates: [GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate] = []
for participant in participants {
switch participant {
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume, params):
case let .groupCallParticipant(flags, userId, date, activeDate, source, volume):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
let ssrc = UInt32(bitPattern: source)
let muted = (flags & (1 << 0)) != 0
@ -1439,12 +1439,12 @@ extension GroupCallParticipantsContext.Update.StateUpdate {
}
var jsonParams: String?
if let params = params {
/*if let params = params {
switch params {
case let .dataJSON(data):
jsonParams = data
}
}
}*/
participantUpdates.append(GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate(
peerId: peerId,

View File

@ -6,6 +6,54 @@ import MtProtoKit
import SyncCore
public func revokePersistentPeerExportedInvitation(account: Account, peerId: PeerId) -> Signal<ExportedInvitation?, NoError> {
return account.postbox.transaction { transaction -> Signal<ExportedInvitation?, NoError> in
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
let flags: Int32 = (1 << 2)
if let _ = peer as? TelegramChannel {
return account.network.request(Api.functions.messages.exportChatInvite(flags: flags, peer: inputPeer, expireDate: nil, usageLimit: nil))
|> retryRequest
|> mapToSignal { result -> Signal<ExportedInvitation?, NoError> in
return account.postbox.transaction { transaction -> ExportedInvitation? in
let invitation = ExportedInvitation(apiExportedInvite: result)
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
if let current = current as? CachedChannelData {
return current.withUpdatedExportedInvitation(invitation)
} else {
return CachedChannelData().withUpdatedExportedInvitation(invitation)
}
})
return invitation
}
}
} else if let _ = peer as? TelegramGroup {
return account.network.request(Api.functions.messages.exportChatInvite(flags: flags, peer: inputPeer, expireDate: nil, usageLimit: nil))
|> retryRequest
|> mapToSignal { result -> Signal<ExportedInvitation?, NoError> in
return account.postbox.transaction { transaction -> ExportedInvitation? in
let invitation = ExportedInvitation(apiExportedInvite: result)
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
if let current = current as? CachedGroupData {
return current.withUpdatedExportedInvitation(invitation)
} else {
return current
}
})
return invitation
}
}
} else {
return .complete()
}
} else {
return .complete()
}
} |> switchToLatest
}
public enum CreatePeerExportedInvitationError {
case generic
}
@ -840,10 +888,13 @@ public func peerExportedInvitationsCreators(account: Account, peerId: PeerId) ->
peersMap[telegramUser.id] = telegramUser
}
for case let .chatAdminWithInvites(adminId, invitesCount, revokedInvitesCount) in admins {
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: adminId)
if let peer = peersMap[peerId], peerId != account.peerId {
creators.append(ExportedInvitationCreator(peer: RenderedPeer(peer: peer), count: invitesCount, revokedCount: revokedInvitesCount))
for admin in admins {
switch admin {
case let .chatAdminWithInvites(adminId, invitesCount, revokedInvitesCount):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: adminId)
if let peer = peersMap[peerId], peerId != account.peerId {
creators.append(ExportedInvitationCreator(peer: RenderedPeer(peer: peer), count: invitesCount, revokedCount: revokedInvitesCount))
}
}
}

View File

@ -104,7 +104,7 @@ private extension ReportReason {
return .inputReportReasonCopyright
case .irrelevantLocation:
return .inputReportReasonGeoIrrelevant
case let .custom:
case .custom:
return .inputReportReasonOther
}
}

View File

@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
public class Serialization: NSObject, MTSerialization {
public func currentLayer() -> UInt {
return 125
return 124
}
public func parseMessage(_ data: Data!) -> Any! {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5562,18 +5562,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if case .creator = group.role {
canSetupAutoremoveTimeout = true
} else if case let .admin(rights, _) = group.role {
if rights.flags.contains(.canChangeInfo) {
canSetupAutoremoveTimeout = true
}
} else if let defaultBannedRights = group.defaultBannedRights {
if !defaultBannedRights.flags.contains(.banChangeInfo) {
if rights.flags.contains(.canDeleteMessages) {
canSetupAutoremoveTimeout = true
}
}
} else if let _ = peer as? TelegramUser {
canSetupAutoremoveTimeout = true
} else if let channel = peer as? TelegramChannel {
if channel.hasPermission(.changeInfo) {
if channel.hasPermission(.deleteAllMessages) {
canSetupAutoremoveTimeout = true
}
}
@ -7466,6 +7462,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if let currentButton = self.leftNavigationButton?.action, currentButton == button.action {
animated = false
}
animated = false
self.navigationItem.setLeftBarButton(button.buttonItem, animated: animated)
self.leftNavigationButton = button
}
@ -7713,7 +7710,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
], parseMarkdown: true), in: .window(.root))
}))
} else {
items.append(ActionSheetTextItem(title: text))
if !isClearCache {
items.append(ActionSheetTextItem(title: text))
}
items.append(ActionSheetButtonItem(title: isClearCache ? self.presentationData.strings.Conversation_ClearCache : self.presentationData.strings.Conversation_ClearAll, color: isClearCache ? .accent : .destructive, action: { [weak self, weak actionSheet] in
actionSheet?.dismissAnimated()
@ -7745,18 +7744,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if case .creator = group.role {
canSetupAutoremoveTimeout = true
} else if case let .admin(rights, _) = group.role {
if rights.flags.contains(.canChangeInfo) {
canSetupAutoremoveTimeout = true
}
} else if let defaultBannedRights = group.defaultBannedRights {
if !defaultBannedRights.flags.contains(.banChangeInfo) {
if rights.flags.contains(.canDeleteMessages) {
canSetupAutoremoveTimeout = true
}
}
} else if let _ = self.presentationInterfaceState.renderedPeer?.peer as? TelegramUser {
canSetupAutoremoveTimeout = true
} else if let channel = self.presentationInterfaceState.renderedPeer?.peer as? TelegramChannel {
if channel.hasPermission(.changeInfo) {
if channel.hasPermission(.deleteAllMessages) {
canSetupAutoremoveTimeout = true
}
}
@ -7771,10 +7766,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return
}
Queue.mainQueue().after(0.8, {
self?.updateChatPresentationInterfaceState(animated: false, interactive: false, { $0.updatedInterfaceState({ $0.withoutSelectionState() }) })
})
actionSheet.dismissAnimated()
strongSelf.presentAutoremoveSetup()
@ -11940,18 +11931,27 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return
}
strongSelf.updateChatPresentationInterfaceState(animated: false, interactive: false, { $0.updatedInterfaceState({ $0.withoutSelectionState() }) })
var isOn: Bool = true
var title: String?
var text: String?
if let myValue = value.myValue {
if let limitedByValue = value.limitedByValue, limitedByValue < myValue {
title = "Auto-Delete On — \(timeIntervalString(strings: strongSelf.presentationData.strings, value: limitedByValue))"
text = "\(peer.compactDisplayTitle) has set messages to auto-delete in \(timeIntervalString(strings: strongSelf.presentationData.strings, value: limitedByValue)). You can't cancel it or make this interval longer."
} else {
text = strongSelf.presentationData.strings.Conversation_AutoremoveChanged("\(timeIntervalString(strings: strongSelf.presentationData.strings, value: myValue))").0
}
} else if let limitedByValue = value.limitedByValue {
title = "Auto-Delete On — \(timeIntervalString(strings: strongSelf.presentationData.strings, value: limitedByValue))"
text = "\(peer.compactDisplayTitle) has set messages to auto-delete in \(timeIntervalString(strings: strongSelf.presentationData.strings, value: limitedByValue)). You can't cancel it or make this interval longer."
} else {
isOn = false
text = "Auto-Delete is now off."
}
if let text = text {
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .succeed(text: text), elevatedLayout: false, action: { _ in return false }), in: .current)
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .autoDelete(isOn: isOn, title: title, text: text), elevatedLayout: false, action: { _ in return false }), in: .current)
}
}
})

View File

@ -242,18 +242,14 @@ func inputTextPanelStateForChatPresentationInterfaceState(_ chatPresentationInte
if case .creator = group.role {
canSetupAutoremoveTimeout = true
} else if case let .admin(rights, _) = group.role {
if rights.flags.contains(.canChangeInfo) {
canSetupAutoremoveTimeout = true
}
} else if let defaultBannedRights = group.defaultBannedRights {
if !defaultBannedRights.flags.contains(.banChangeInfo) {
if rights.flags.contains(.canDeleteMessages) {
canSetupAutoremoveTimeout = true
}
}
} else if let _ = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramUser {
canSetupAutoremoveTimeout = true
} else if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel {
if channel.hasPermission(.changeInfo) {
if channel.hasPermission(.deleteAllMessages) {
canSetupAutoremoveTimeout = true
}
}
@ -285,7 +281,7 @@ func inputTextPanelStateForChatPresentationInterfaceState(_ chatPresentationInte
if !extendedSearchLayout {
if let peer = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramSecretChat {
accessoryItems.append(.messageAutoremoveTimeout(peer.messageAutoremoveTimeout))
} else if currentAutoremoveTimeout != nil {
} else if currentAutoremoveTimeout != nil && chatPresentationInterfaceState.interfaceState.composeInputState.inputText.length == 0 {
accessoryItems.append(.messageAutoremoveTimeout(currentAutoremoveTimeout))
}
}

View File

@ -236,18 +236,21 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
if parsedUrl.host == "localpeer" {
if let components = URLComponents(string: "/?" + query) {
var peerId: PeerId?
var accountId: Int64?
if let queryItems = components.queryItems {
for queryItem in queryItems {
if let value = queryItem.value {
if queryItem.name == "id", let intValue = Int64(value) {
peerId = PeerId(intValue)
} else if queryItem.name == "accountId", let intValue = Int64(value) {
accountId = intValue
}
}
}
}
if let peerId = peerId, let navigationController = navigationController {
if let peerId = peerId, let accountId = accountId {
context.sharedContext.applicationBindings.dismissNativeController()
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peerId)))
context.sharedContext.navigateToChat(accountId: AccountRecordId(rawValue: accountId), peerId: peerId, messageId: nil)
}
}
} else if parsedUrl.host == "join" {

View File

@ -29,6 +29,7 @@ public enum UndoOverlayContent {
case importedMessage(text: String)
case audioRate(slowdown: Bool, text: String)
case forward(savedMessages: Bool, text: String)
case autoDelete(isOn: Bool, title: String?, text: String)
}
public enum UndoOverlayAction {

View File

@ -136,6 +136,18 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(14.0), textColor: .white)
displayUndo = undo
self.originalRemainingSeconds = 3
case let .autoDelete(isOn, title, text):
self.avatarNode = nil
self.iconNode = nil
self.iconCheckNode = nil
self.animationNode = AnimationNode(animation: isOn ? "anim_autoremove_on" : "anim_autoremove_off", colors: ["info1.info1.stroke": self.animationBackgroundColor, "info2.info2.Fill": self.animationBackgroundColor], scale: 1.0)
self.animatedStickerNode = nil
if let title = title {
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(14.0), textColor: .white)
}
self.textNode.attributedText = NSAttributedString(string: text, font: Font.regular(14.0), textColor: .white)
displayUndo = false
self.originalRemainingSeconds = 3
case let .succeed(text):
self.avatarNode = nil
self.iconNode = nil
@ -537,7 +549,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
switch content {
case .removedChat:
self.panelWrapperNode.addSubnode(self.timerTextNode)
case .archivedChat, .hidArchive, .revealedArchive, .succeed, .emoji, .swipeToReply, .actionSucceeded, .stickersModified, .chatAddedToFolder, .chatRemovedFromFolder, .messagesUnpinned, .setProximityAlert, .invitedToVoiceChat, .linkCopied, .banned, .importedMessage, .audioRate, .forward:
case .archivedChat, .hidArchive, .revealedArchive, .autoDelete, .succeed, .emoji, .swipeToReply, .actionSucceeded, .stickersModified, .chatAddedToFolder, .chatRemovedFromFolder, .messagesUnpinned, .setProximityAlert, .invitedToVoiceChat, .linkCopied, .banned, .importedMessage, .audioRate, .forward:
break
case .dice:
self.panelWrapperNode.clipsToBounds = true
@ -655,6 +667,9 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
} else if case .banned = self.content {
let factor: CGFloat = 0.08
preferredSize = CGSize(width: floor(iconSize.width * factor), height: floor(iconSize.height * factor))
} else if case .autoDelete = self.content {
let factor: CGFloat = 0.06
preferredSize = CGSize(width: floor(iconSize.width * factor), height: floor(iconSize.height * factor))
} else {
preferredSize = iconSize
}