mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Stories
This commit is contained in:
@@ -888,7 +888,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
let sharedContext = SharedAccountContextImpl(mainWindow: self.mainWindow, sharedContainerPath: legacyBasePath, basePath: rootPath, encryptionParameters: encryptionParameters, accountManager: accountManager, appLockContext: appLockContext, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings, networkArguments: networkArguments, hasInAppPurchases: buildConfig.isAppStoreBuild && buildConfig.apiId == 1, rootPath: rootPath, legacyBasePath: legacyBasePath, apsNotificationToken: self.notificationTokenPromise.get() |> map(Optional.init), voipNotificationToken: self.voipTokenPromise.get() |> map(Optional.init), firebaseSecretStream: self.firebaseSecretStream.get(), setNotificationCall: { call in
|
||||
setPresentationCall?(call)
|
||||
}, navigateToChat: { accountId, peerId, messageId in
|
||||
self.openChatWhenReady(accountId: accountId, peerId: peerId, threadId: nil, messageId: messageId)
|
||||
self.openChatWhenReady(accountId: accountId, peerId: peerId, threadId: nil, messageId: messageId, storyId: nil)
|
||||
}, displayUpgradeProgress: { progress in
|
||||
if let progress = progress {
|
||||
if self.dataImportSplash == nil {
|
||||
@@ -2221,7 +2221,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
if let contact = sendMessageIntent.recipients?.first, let handle = contact.customIdentifier, handle.hasPrefix("tg") {
|
||||
let string = handle.suffix(from: handle.index(handle.startIndex, offsetBy: 2))
|
||||
if let value = Int64(string) {
|
||||
self.openChatWhenReady(accountId: nil, peerId: PeerId(value), threadId: nil, activateInput: true)
|
||||
self.openChatWhenReady(accountId: nil, peerId: PeerId(value), threadId: nil, activateInput: true, storyId: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2262,7 +2262,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
if let primary = primary {
|
||||
for context in contexts {
|
||||
if let context = context, context.account.id == primary {
|
||||
self.openChatWhenReady(accountId: nil, peerId: peerId, threadId: nil)
|
||||
self.openChatWhenReady(accountId: nil, peerId: peerId, threadId: nil, storyId: nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -2270,7 +2270,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
|
||||
for context in contexts {
|
||||
if let context = context {
|
||||
self.openChatWhenReady(accountId: context.account.id, peerId: peerId, threadId: nil)
|
||||
self.openChatWhenReady(accountId: context.account.id, peerId: peerId, threadId: nil, storyId: nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -2303,7 +2303,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
case .camera:
|
||||
context.openRootCamera()
|
||||
case .savedMessages:
|
||||
self.openChatWhenReady(accountId: nil, peerId: context.context.account.peerId, threadId: nil)
|
||||
self.openChatWhenReady(accountId: nil, peerId: context.context.account.peerId, threadId: nil, storyId: nil)
|
||||
case .account:
|
||||
context.switchAccount()
|
||||
}
|
||||
@@ -2354,7 +2354,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
}))
|
||||
}
|
||||
|
||||
private func openChatWhenReady(accountId: AccountRecordId?, peerId: PeerId, threadId: Int64?, messageId: MessageId? = nil, activateInput: Bool = false) {
|
||||
private func openChatWhenReady(accountId: AccountRecordId?, peerId: PeerId, threadId: Int64?, messageId: MessageId? = nil, activateInput: Bool = false, storyId: StoryId?) {
|
||||
let signal = self.sharedContextPromise.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue
|
||||
@@ -2373,7 +2373,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
}
|
||||
self.openChatWhenReadyDisposable.set((signal
|
||||
|> deliverOnMainQueue).start(next: { context in
|
||||
context.openChatWithPeerId(peerId: peerId, threadId: threadId, messageId: messageId, activateInput: activateInput)
|
||||
context.openChatWithPeerId(peerId: peerId, threadId: threadId, messageId: messageId, activateInput: activateInput, storyId: storyId)
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -2402,7 +2402,8 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
if response.notification.request.content.categoryIdentifier == "c" || response.notification.request.content.categoryIdentifier == "t" {
|
||||
messageId = messageIdFromNotification(peerId: peerId, notification: response.notification)
|
||||
}
|
||||
self.openChatWhenReady(accountId: accountId, peerId: peerId, threadId: threadId, messageId: messageId)
|
||||
let storyId = storyIdFromNotification(peerId: peerId, notification: response.notification)
|
||||
self.openChatWhenReady(accountId: accountId, peerId: peerId, threadId: threadId, messageId: messageId, storyId: storyId)
|
||||
}
|
||||
completionHandler()
|
||||
} else if response.actionIdentifier == "reply", let (peerId, threadId) = peerIdFromNotification(response.notification), let accountId = accountId {
|
||||
@@ -2793,7 +2794,6 @@ private func peerIdFromNotification(_ notification: UNNotification) -> (peerId:
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 10.0, *)
|
||||
private func messageIdFromNotification(peerId: PeerId, notification: UNNotification) -> MessageId? {
|
||||
let payload = notification.request.content.userInfo
|
||||
if let messageIdNamespace = payload["messageId.namespace"] as? Int32, let messageIdId = payload["messageId.id"] as? Int32 {
|
||||
@@ -2807,6 +2807,15 @@ private func messageIdFromNotification(peerId: PeerId, notification: UNNotificat
|
||||
return nil
|
||||
}
|
||||
|
||||
private func storyIdFromNotification(peerId: PeerId, notification: UNNotification) -> StoryId? {
|
||||
let payload = notification.request.content.userInfo
|
||||
if let storyId = payload["story_id"] {
|
||||
let storyIdValue = storyId as! NSString
|
||||
return StoryId(peerId: peerId, id: Int32(storyIdValue.intValue))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private enum DownloadFileError {
|
||||
case network
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user