mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 01:10:09 +00:00
Merge commit 'd748b3e8811db9ff5f834e08b64eb605d85ce577'
This commit is contained in:
commit
f216ed33f0
@ -100,22 +100,21 @@ class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessag
|
|||||||
|> mapToSignal { account -> Signal<Account?, NoError> in
|
|> mapToSignal { account -> Signal<Account?, NoError> in
|
||||||
if let account = account {
|
if let account = account {
|
||||||
switch account {
|
switch account {
|
||||||
case .upgrading:
|
case .upgrading:
|
||||||
return .complete()
|
return .complete()
|
||||||
case let .authorized(account):
|
case let .authorized(account):
|
||||||
account.shouldKeepOnlinePresence.set(.single(false))
|
return applicationSettings(accountManager: accountManager)
|
||||||
return applicationSettings(accountManager: accountManager)
|
|> deliverOnMainQueue
|
||||||
|> deliverOnMainQueue
|
|> map { settings -> Account in
|
||||||
|> map { settings -> Account in
|
accountCache = account
|
||||||
accountCache = account
|
Logger.shared.logToFile = settings.logging.logToFile
|
||||||
Logger.shared.logToFile = settings.logging.logToFile
|
Logger.shared.logToConsole = settings.logging.logToConsole
|
||||||
Logger.shared.logToConsole = settings.logging.logToConsole
|
|
||||||
|
Logger.shared.redactSensitiveData = settings.logging.redactSensitiveData
|
||||||
Logger.shared.redactSensitiveData = settings.logging.redactSensitiveData
|
return account
|
||||||
return account
|
}
|
||||||
}
|
case .unauthorized:
|
||||||
case .unauthorized:
|
return .complete()
|
||||||
return .complete()
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
@ -275,7 +274,9 @@ class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessag
|
|||||||
@available(iOSApplicationExtension 11.0, *)
|
@available(iOSApplicationExtension 11.0, *)
|
||||||
func resolveRecipients(for intent: INSendMessageIntent, with completion: @escaping ([INSendMessageRecipientResolutionResult]) -> Void) {
|
func resolveRecipients(for intent: INSendMessageIntent, with completion: @escaping ([INSendMessageRecipientResolutionResult]) -> Void) {
|
||||||
if let peerId = intent.conversationIdentifier.flatMap(Int64.init) {
|
if let peerId = intent.conversationIdentifier.flatMap(Int64.init) {
|
||||||
let signal = self.accountPromise.get()
|
let account = self.accountPromise.get()
|
||||||
|
|
||||||
|
let signal = account
|
||||||
|> introduceError(IntentHandlingError.self)
|
|> introduceError(IntentHandlingError.self)
|
||||||
|> mapToSignal { account -> Signal<INPerson?, IntentHandlingError> in
|
|> mapToSignal { account -> Signal<INPerson?, IntentHandlingError> in
|
||||||
if let account = account {
|
if let account = account {
|
||||||
@ -402,8 +403,8 @@ class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessag
|
|||||||
account.resetStateManagement()
|
account.resetStateManagement()
|
||||||
|
|
||||||
let completion: Signal<Void, NoError> = account.stateManager.pollStateUpdateCompletion()
|
let completion: Signal<Void, NoError> = account.stateManager.pollStateUpdateCompletion()
|
||||||
|> map { _ in
|
|> map { _ in
|
||||||
return Void()
|
return Void()
|
||||||
}
|
}
|
||||||
|
|
||||||
return (completion |> timeout(4.0, queue: Queue.mainQueue(), alternate: .single(Void())))
|
return (completion |> timeout(4.0, queue: Queue.mainQueue(), alternate: .single(Void())))
|
||||||
@ -482,7 +483,7 @@ class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessag
|
|||||||
|
|
||||||
for (_, messageId) in maxMessageIdsToApply {
|
for (_, messageId) in maxMessageIdsToApply {
|
||||||
signals.append(applyMaxReadIndexInteractively(postbox: account.postbox, stateManager: account.stateManager, index: MessageIndex(id: messageId, timestamp: 0))
|
signals.append(applyMaxReadIndexInteractively(postbox: account.postbox, stateManager: account.stateManager, index: MessageIndex(id: messageId, timestamp: 0))
|
||||||
|> introduceError(IntentHandlingError.self))
|
|> introduceError(IntentHandlingError.self))
|
||||||
}
|
}
|
||||||
|
|
||||||
if signals.isEmpty {
|
if signals.isEmpty {
|
||||||
@ -490,11 +491,11 @@ class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessag
|
|||||||
} else {
|
} else {
|
||||||
account.shouldBeServiceTaskMaster.set(.single(.now))
|
account.shouldBeServiceTaskMaster.set(.single(.now))
|
||||||
return combineLatest(signals)
|
return combineLatest(signals)
|
||||||
|> mapToSignal { _ -> Signal<Void, IntentHandlingError> in
|
|> mapToSignal { _ -> Signal<Void, IntentHandlingError> in
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
|> afterDisposed {
|
|> afterDisposed {
|
||||||
account.shouldBeServiceTaskMaster.set(.single(.never))
|
account.shouldBeServiceTaskMaster.set(.single(.never))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,34 +574,34 @@ class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessag
|
|||||||
|
|
||||||
func handle(intent: INSearchCallHistoryIntent, completion: @escaping (INSearchCallHistoryIntentResponse) -> Void) {
|
func handle(intent: INSearchCallHistoryIntent, completion: @escaping (INSearchCallHistoryIntentResponse) -> Void) {
|
||||||
self.actionDisposable.set((self.accountPromise.get()
|
self.actionDisposable.set((self.accountPromise.get()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> introduceError(IntentHandlingError.self)
|
|> introduceError(IntentHandlingError.self)
|
||||||
|> mapToSignal { account -> Signal<[CallRecord], IntentHandlingError> in
|
|> mapToSignal { account -> Signal<[CallRecord], IntentHandlingError> in
|
||||||
guard let account = account else {
|
guard let account = account else {
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
|
||||||
|
|
||||||
account.shouldBeServiceTaskMaster.set(.single(.now))
|
|
||||||
return missedCalls(account: account)
|
|
||||||
|> introduceError(IntentHandlingError.self)
|
|
||||||
|> afterDisposed {
|
|
||||||
account.shouldBeServiceTaskMaster.set(.single(.never))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|> deliverOnMainQueue).start(next: { calls in
|
|
||||||
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSearchCallHistoryIntent.self))
|
account.shouldBeServiceTaskMaster.set(.single(.now))
|
||||||
let response: INSearchCallHistoryIntentResponse
|
return missedCalls(account: account)
|
||||||
if #available(iOSApplicationExtension 11.0, *) {
|
|> introduceError(IntentHandlingError.self)
|
||||||
response = INSearchCallHistoryIntentResponse(code: .success, userActivity: userActivity)
|
|> afterDisposed {
|
||||||
response.callRecords = calls.map { $0.intentCall }
|
account.shouldBeServiceTaskMaster.set(.single(.never))
|
||||||
} else {
|
}
|
||||||
response = INSearchCallHistoryIntentResponse(code: .continueInApp, userActivity: userActivity)
|
}
|
||||||
}
|
|> deliverOnMainQueue).start(next: { calls in
|
||||||
completion(response)
|
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSearchCallHistoryIntent.self))
|
||||||
}, error: { _ in
|
let response: INSearchCallHistoryIntentResponse
|
||||||
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSearchCallHistoryIntent.self))
|
if #available(iOSApplicationExtension 11.0, *) {
|
||||||
let response = INSearchCallHistoryIntentResponse(code: .failureRequiringAppLaunch, userActivity: userActivity)
|
response = INSearchCallHistoryIntentResponse(code: .success, userActivity: userActivity)
|
||||||
completion(response)
|
response.callRecords = calls.map { $0.intentCall }
|
||||||
}))
|
} else {
|
||||||
|
response = INSearchCallHistoryIntentResponse(code: .continueInApp, userActivity: userActivity)
|
||||||
|
}
|
||||||
|
completion(response)
|
||||||
|
}, error: { _ in
|
||||||
|
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSearchCallHistoryIntent.self))
|
||||||
|
let response = INSearchCallHistoryIntentResponse(code: .failureRequiringAppLaunch, userActivity: userActivity)
|
||||||
|
completion(response)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user