mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-02-14 23:09:38 +00:00
Support drop auth alerts
This commit is contained in:
@@ -109,7 +109,7 @@ struct AccountMutableState {
|
||||
var namespacesWithHolesFromPreviousState: [PeerId: Set<MessageId.Namespace>]
|
||||
|
||||
var storedMessagesByPeerIdAndTimestamp: [PeerId: Set<MessageIndex>]
|
||||
var displayAlerts: [String] = []
|
||||
var displayAlerts: [(text: String, isDropAuth: Bool)] = []
|
||||
|
||||
var insertedPeers: [PeerId: Peer] = [:]
|
||||
|
||||
@@ -132,7 +132,7 @@ struct AccountMutableState {
|
||||
self.namespacesWithHolesFromPreviousState = [:]
|
||||
}
|
||||
|
||||
init(initialState: AccountInitialState, operations: [AccountStateMutationOperation], state: AuthorizedAccountState.State, peers: [PeerId: Peer], chatStates: [PeerId: PeerChatState], peerNotificationSettings: [PeerId: PeerNotificationSettings], referencedMessageIds: Set<MessageId>, storedMessages: Set<MessageId>, readInboxMaxIds: [PeerId: MessageId], storedMessagesByPeerIdAndTimestamp: [PeerId: Set<MessageIndex>], namespacesWithHolesFromPreviousState: [PeerId: Set<MessageId.Namespace>], displayAlerts: [String], branchOperationIndex: Int) {
|
||||
init(initialState: AccountInitialState, operations: [AccountStateMutationOperation], state: AuthorizedAccountState.State, peers: [PeerId: Peer], chatStates: [PeerId: PeerChatState], peerNotificationSettings: [PeerId: PeerNotificationSettings], referencedMessageIds: Set<MessageId>, storedMessages: Set<MessageId>, readInboxMaxIds: [PeerId: MessageId], storedMessagesByPeerIdAndTimestamp: [PeerId: Set<MessageIndex>], namespacesWithHolesFromPreviousState: [PeerId: Set<MessageId.Namespace>], displayAlerts: [(text: String, isDropAuth: Bool)], branchOperationIndex: Int) {
|
||||
self.initialState = initialState
|
||||
self.operations = operations
|
||||
self.state = state
|
||||
@@ -180,8 +180,8 @@ struct AccountMutableState {
|
||||
self.addOperation(.AddMessages(messages, location))
|
||||
}
|
||||
|
||||
mutating func addDisplayAlert(_ text: String) {
|
||||
self.displayAlerts.append(text)
|
||||
mutating func addDisplayAlert(_ text: String, isDropAuth: Bool) {
|
||||
self.displayAlerts.append((text: text, isDropAuth: isDropAuth))
|
||||
}
|
||||
|
||||
mutating func deleteMessagesWithGlobalIds(_ globalIds: [Int32]) {
|
||||
@@ -451,7 +451,7 @@ struct AccountFinalStateEvents {
|
||||
let updatedWebpages: [MediaId: TelegramMediaWebpage]
|
||||
let updatedCalls: [Api.PhoneCall]
|
||||
let isContactUpdates: [(PeerId, Bool)]
|
||||
let displayAlerts: [String]
|
||||
let displayAlerts: [(text: String, isDropAuth: Bool)]
|
||||
let delayNotificatonsUntil: Int32?
|
||||
let updatedMaxMessageId: Int32?
|
||||
let updatedQts: Int32?
|
||||
@@ -472,7 +472,7 @@ struct AccountFinalStateEvents {
|
||||
self.updatedQts = nil
|
||||
}
|
||||
|
||||
init(addedIncomingMessageIds: [MessageId], updatedTypingActivities: [PeerId: [PeerId: PeerInputActivity?]], updatedWebpages: [MediaId: TelegramMediaWebpage], updatedCalls: [Api.PhoneCall], isContactUpdates: [(PeerId, Bool)], displayAlerts: [String], delayNotificatonsUntil: Int32?, updatedMaxMessageId: Int32?, updatedQts: Int32?) {
|
||||
init(addedIncomingMessageIds: [MessageId], updatedTypingActivities: [PeerId: [PeerId: PeerInputActivity?]], updatedWebpages: [MediaId: TelegramMediaWebpage], updatedCalls: [Api.PhoneCall], isContactUpdates: [(PeerId, Bool)], displayAlerts: [(text: String, isDropAuth: Bool)], delayNotificatonsUntil: Int32?, updatedMaxMessageId: Int32?, updatedQts: Int32?) {
|
||||
self.addedIncomingMessageIds = addedIncomingMessageIds
|
||||
self.updatedTypingActivities = updatedTypingActivities
|
||||
self.updatedWebpages = updatedWebpages
|
||||
|
||||
@@ -882,7 +882,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
updatedState.addMessages([message], location: .UpperHistoryBlock)
|
||||
}
|
||||
case let .updateServiceNotification(_, date, _, text, media, entities):
|
||||
case let .updateServiceNotification(_, date, type, text, media, entities):
|
||||
if let date = date {
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 777000)
|
||||
|
||||
@@ -928,7 +928,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
updatedState.addMessages([message], location: .UpperHistoryBlock)
|
||||
}
|
||||
} else {
|
||||
updatedState.addDisplayAlert(text)
|
||||
updatedState.addDisplayAlert(text, isDropAuth: type.hasPrefix("AUTH_KEY_DROP_"))
|
||||
}
|
||||
case let .updateReadChannelInbox(channelId, maxId):
|
||||
updatedState.readInbox(MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), namespace: Namespaces.Message.Cloud, id: maxId))
|
||||
|
||||
@@ -101,8 +101,8 @@ public final class AccountStateManager {
|
||||
return self.notificationMessagesPipe.signal()
|
||||
}
|
||||
|
||||
private let displayAlertsPipe = ValuePipe<[String]>()
|
||||
public var displayAlerts: Signal<[String], NoError> {
|
||||
private let displayAlertsPipe = ValuePipe<[(text: String, isDropAuth: Bool)]>()
|
||||
public var displayAlerts: Signal<[(text: String, isDropAuth: Bool)], NoError> {
|
||||
return self.displayAlertsPipe.signal()
|
||||
}
|
||||
|
||||
|
||||
@@ -125,11 +125,16 @@ public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: Pe
|
||||
|
||||
switch result {
|
||||
case let .adminLogResults(apiEvents, apiChats, apiUsers):
|
||||
let peers = (apiChats.flatMap { parseTelegramGroupOrChannel(chat: $0) } + apiUsers.flatMap { TelegramUser(user: $0) } + Array(arrayLiteral: peer)).reduce([:], { current, peer -> [PeerId : Peer] in
|
||||
var current = current
|
||||
current[peer.id] = peer
|
||||
return current
|
||||
})
|
||||
var peers: [PeerId: Peer] = [:]
|
||||
for apiChat in apiChats {
|
||||
if let peer = parseTelegramGroupOrChannel(chat: apiChat) {
|
||||
peers[peer.id] = peer
|
||||
}
|
||||
}
|
||||
for apiUser in apiUsers {
|
||||
let peer = TelegramUser(user: apiUser)
|
||||
peers[peer.id] = peer
|
||||
}
|
||||
|
||||
var events: [AdminLogEvent] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user