diff --git a/submodules/TelegramUI/Resources/Animations/story_expired.tgs b/submodules/TelegramUI/Resources/Animations/story_expired.tgs new file mode 100644 index 0000000000..7645521dfc Binary files /dev/null and b/submodules/TelegramUI/Resources/Animations/story_expired.tgs differ diff --git a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift index 94ee68ebb9..29c939b14a 100644 --- a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift +++ b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift @@ -805,23 +805,39 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur dismissInput() } case let .story(peerId, id): - let storyContent = SingleStoryContentContextImpl(context: context, storyId: StoryId(peerId: peerId, id: id)) - let _ = (storyContent.state - |> take(1) - |> deliverOnMainQueue).start(next: { [weak navigationController] _ in - let transitionIn: StoryContainerScreen.TransitionIn? = nil - - let storyContainerScreen = StoryContainerScreen( - context: context, - content: storyContent, - transitionIn: transitionIn, - transitionOut: { _, _ in - let transitionOut: StoryContainerScreen.TransitionOut? = nil + let _ = (context.account.postbox.transaction { transaction -> Bool in + if let value = transaction.getStory(id: StoryId(peerId: peerId, id: id)), !value.data.isEmpty { + return true + } else { + return false + } + } + |> deliverOnMainQueue).start(next: { exists in + if exists { + let storyContent = SingleStoryContentContextImpl(context: context, storyId: StoryId(peerId: peerId, id: id)) + let _ = (storyContent.state + |> take(1) + |> deliverOnMainQueue).start(next: { [weak navigationController] _ in + let transitionIn: StoryContainerScreen.TransitionIn? = nil - return transitionOut - } - ) - navigationController?.pushViewController(storyContainerScreen) + let storyContainerScreen = StoryContainerScreen( + context: context, + content: storyContent, + transitionIn: transitionIn, + transitionOut: { _, _ in + let transitionOut: StoryContainerScreen.TransitionOut? = nil + + return transitionOut + } + ) + navigationController?.pushViewController(storyContainerScreen) + }) + } else { + //TODO:localize + present(UndoOverlayController(presentationData: presentationData, content: .universal(animation: "story_expired", scale: 0.066, colors: [:], title: nil, text: "This story does not exist", customUndoText: nil, timeout: nil), elevatedLayout: true, animateInAsReplacement: false, action: { _ in + return true + }), nil) + } }) } } diff --git a/submodules/UrlHandling/Sources/UrlHandling.swift b/submodules/UrlHandling/Sources/UrlHandling.swift index 5423270d01..26f61bc68e 100644 --- a/submodules/UrlHandling/Sources/UrlHandling.swift +++ b/submodules/UrlHandling/Sources/UrlHandling.swift @@ -709,7 +709,10 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) case let .voiceChat(invite): return .single(.joinVoiceChat(peer.id, invite)) case let .story(id): - return .single(.story(peerId: peer.id, id: id)) + return context.engine.messages.refreshStories(peerId: peer.id, ids: [id]) + |> map { _ -> ResolvedUrl? in + } + |> then(.single(.story(peerId: peer.id, id: id))) } } else { return .single(.peer(peer, .chat(textInputState: nil, subject: nil, peekData: nil)))