mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Open stories from notification
This commit is contained in:
parent
031784b6e3
commit
3a0d3b66f4
@ -23,4 +23,5 @@ public protocol ChatListController: ViewController {
|
||||
func navigateToFolder(folderId: Int32, completion: @escaping () -> Void)
|
||||
|
||||
func openStories(peerId: EnginePeer.Id)
|
||||
func openStoriesFromNotification(peerId: EnginePeer.Id, storyId: Int32)
|
||||
}
|
||||
|
@ -3675,6 +3675,64 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
})
|
||||
}
|
||||
|
||||
public func openStoriesFromNotification(peerId: EnginePeer.Id, storyId: Int32) {
|
||||
let presentationData = self.presentationData
|
||||
let progressSignal = Signal<Never, NoError> { [weak self] subscriber in
|
||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
||||
self?.present(controller, in: .window(.root))
|
||||
return ActionDisposable { [weak controller] in
|
||||
Queue.mainQueue().async() {
|
||||
controller?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|> runOn(Queue.mainQueue())
|
||||
|> delay(0.8, queue: Queue.mainQueue())
|
||||
let progressDisposable = progressSignal.start()
|
||||
|
||||
let signal: Signal<Never, NoError> = self.context.engine.messages.peerStoriesAreReady(
|
||||
id: peerId,
|
||||
minId: storyId
|
||||
)
|
||||
|> filter { $0 }
|
||||
|> deliverOnMainQueue
|
||||
|> timeout(5.0, queue: .mainQueue(), alternate: .single(false))
|
||||
|> take(1)
|
||||
|> ignoreValues
|
||||
|> afterDisposed {
|
||||
Queue.mainQueue().async {
|
||||
progressDisposable.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
self.sharedOpenStoryProgressDisposable.set((signal |> deliverOnMainQueue).start(completed: { [weak self] in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
StoryContainerScreen.openPeerStoriesCustom(
|
||||
context: self.context,
|
||||
peerId: peerId,
|
||||
isHidden: false,
|
||||
singlePeer: true,
|
||||
parentController: self,
|
||||
transitionIn: {
|
||||
return nil
|
||||
},
|
||||
transitionOut: { _ in
|
||||
return nil
|
||||
},
|
||||
setFocusedItem: { _ in
|
||||
},
|
||||
setProgress: { [weak self] signal in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.sharedOpenStoryProgressDisposable.set(signal.start())
|
||||
}
|
||||
)
|
||||
}))
|
||||
}
|
||||
|
||||
public func openStories(peerId: EnginePeer.Id) {
|
||||
if let navigationBarView = self.chatListDisplayNode.navigationBarView.view as? ChatListNavigationBar.View {
|
||||
if navigationBarView.storiesUnlocked {
|
||||
|
@ -629,6 +629,20 @@ public extension TelegramEngine {
|
||||
}).start()
|
||||
}
|
||||
|
||||
public func peerStoriesAreReady(id: EnginePeer.Id, minId: Int32) -> Signal<Bool, NoError> {
|
||||
return self.account.postbox.combinedView(keys: [
|
||||
PostboxViewKey.storyItems(peerId: id)
|
||||
])
|
||||
|> map { views -> Bool in
|
||||
guard let view = views.views[PostboxViewKey.storyItems(peerId: id)] as? StoryItemsView else {
|
||||
return false
|
||||
}
|
||||
return view.items.contains(where: { item in
|
||||
return item.id >= minId
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public func storySubscriptions(isHidden: Bool, tempKeepNewlyArchived: Bool = false) -> Signal<EngineStorySubscriptions, NoError> {
|
||||
return `deferred` { () -> Signal<EngineStorySubscriptions, NoError> in
|
||||
let debugTimerSignal: Signal<Bool, NoError>
|
||||
|
@ -85,7 +85,7 @@ public extension StoryContainerScreen {
|
||||
let _ = avatarNode.pushLoadingStatus(signal: signal)
|
||||
}
|
||||
|
||||
static func openPeerStories(context: AccountContext, peerId: EnginePeer.Id, parentController: ViewController, avatarNode: AvatarNode, sharedProgressDisposable: MetaDisposable? = nil) {
|
||||
static func openPeerStories(context: AccountContext, peerId: EnginePeer.Id, parentController: ViewController, avatarNode: AvatarNode?, sharedProgressDisposable: MetaDisposable? = nil) {
|
||||
return openPeerStoriesCustom(
|
||||
context: context,
|
||||
peerId: peerId,
|
||||
|
@ -27,6 +27,7 @@ import ContextUI
|
||||
import TelegramCallsUI
|
||||
import AuthorizationUI
|
||||
import ChatListUI
|
||||
import StoryContainerScreen
|
||||
|
||||
final class UnauthorizedApplicationContext {
|
||||
let sharedContext: SharedAccountContextImpl
|
||||
@ -854,7 +855,18 @@ final class AuthorizedApplicationContext {
|
||||
|
||||
func openChatWithPeerId(peerId: PeerId, threadId: Int64?, messageId: MessageId? = nil, activateInput: Bool = false, storyId: StoryId?) {
|
||||
if let storyId {
|
||||
if let chatListController = self.rootController.chatListController as? ChatListControllerImpl {
|
||||
var controllers = self.rootController.viewControllers
|
||||
controllers = controllers.filter { c in
|
||||
if c is StoryContainerScreen {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
self.rootController.setViewControllers(controllers, animated: false)
|
||||
|
||||
self.rootController.chatListController?.openStoriesFromNotification(peerId: storyId.peerId, storyId: storyId.id)
|
||||
|
||||
/*if let chatListController = self.rootController.chatListController as? ChatListControllerImpl {
|
||||
let _ = (chatListController.context.account.postbox.transaction { transaction -> Bool in
|
||||
if let peer = transaction.getPeer(storyId.peerId) as? TelegramUser, let storiesHidden = peer.storiesHidden, storiesHidden {
|
||||
return true
|
||||
@ -902,7 +914,7 @@ final class AuthorizedApplicationContext {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}*/
|
||||
} else {
|
||||
var visiblePeerId: PeerId?
|
||||
if let controller = self.rootController.topViewController as? ChatControllerImpl, controller.chatLocation.peerId == peerId, controller.chatLocation.threadId == threadId {
|
||||
|
Loading…
x
Reference in New Issue
Block a user