Fix open story from id

This commit is contained in:
Isaac 2024-07-12 17:08:52 +04:00
parent b97b8c369e
commit 09049a4074
3 changed files with 10 additions and 4 deletions

View file

@ -3991,6 +3991,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
StoryContainerScreen.openPeerStoriesCustom(
context: self.context,
peerId: peerId,
focusOnId: storyId,
isHidden: false,
singlePeer: true,
parentController: self,

View file

@ -163,6 +163,7 @@ public extension StoryContainerScreen {
static func openPeerStoriesCustom(
context: AccountContext,
peerId: EnginePeer.Id,
focusOnId: Int32? = nil,
isHidden: Bool,
initialOrder: [EnginePeer.Id] = [],
singlePeer: Bool,
@ -173,7 +174,7 @@ public extension StoryContainerScreen {
setProgress: @escaping (Signal<Never, NoError>) -> Void,
completion: @escaping (StoryContainerScreen) -> Void = { _ in }
) {
let storyContent = StoryContentContextImpl(context: context, isHidden: isHidden, focusedPeerId: peerId, singlePeer: singlePeer, fixedOrder: initialOrder)
let storyContent = StoryContentContextImpl(context: context, isHidden: isHidden, focusedPeerId: peerId, focusedStoryId: focusOnId, singlePeer: singlePeer, fixedOrder: initialOrder)
let signal = storyContent.state
|> take(1)
|> mapToSignal { state -> Signal<StoryContentContextState, NoError> in

View file

@ -48,6 +48,7 @@ public final class StoryContentContextImpl: StoryContentContext {
self.peerId = peerId
self.currentFocusedId = initialFocusedId
self.storedFocusedId = self.currentFocusedId
self.currentFocusedIdUpdatedPromise.set(.single(Void()))
context.engine.account.viewTracker.refreshCanSendMessagesForPeerIds(peerIds: [peerId])
@ -600,13 +601,14 @@ public final class StoryContentContextImpl: StoryContentContext {
context: AccountContext,
isHidden: Bool,
focusedPeerId: EnginePeer.Id?,
focusedStoryId: Int32? = nil,
singlePeer: Bool,
fixedOrder: [EnginePeer.Id] = []
) {
self.context = context
self.isHidden = isHidden
if let focusedPeerId {
self.focusedItem = (focusedPeerId, nil)
self.focusedItem = (focusedPeerId, focusedStoryId)
}
self.fixedSubscriptionOrder = fixedOrder
@ -858,9 +860,11 @@ public final class StoryContentContextImpl: StoryContentContext {
}
var centralIndex: Int?
if let (focusedPeerId, _) = self.focusedItem {
var centralStoryId: Int32?
if let (focusedPeerId, focusedStoryId) = self.focusedItem {
if let index = subscriptionItems.firstIndex(where: { $0.peer.id == focusedPeerId }) {
centralIndex = index
centralStoryId = focusedStoryId
}
}
if centralIndex == nil {
@ -874,7 +878,7 @@ public final class StoryContentContextImpl: StoryContentContext {
if let currentState = self.currentState, let existingContext = currentState.findPeerContext(id: subscriptionItems[centralIndex].peer.id) {
centralPeerContext = existingContext
} else {
centralPeerContext = PeerContext(context: self.context, peerId: subscriptionItems[centralIndex].peer.id, focusedId: nil, loadIds: loadIds)
centralPeerContext = PeerContext(context: self.context, peerId: subscriptionItems[centralIndex].peer.id, focusedId: centralStoryId, loadIds: loadIds)
}
var previousPeerContext: PeerContext?