mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
4c697dcbfa
commit
90bba2d84a
@ -963,7 +963,8 @@ public protocol SharedAccountContext: AnyObject {
|
||||
func presentContactsWarningSuppression(context: AccountContext, present: (ViewController, Any?) -> Void)
|
||||
func openImagePicker(context: AccountContext, completion: @escaping (UIImage) -> Void, present: @escaping (ViewController) -> Void)
|
||||
func openAddPeerMembers(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, parentController: ViewController, groupPeer: Peer, selectAddMemberDisposable: MetaDisposable, addMemberDisposable: MetaDisposable)
|
||||
func openChatInstantPage(context: AccountContext, message: Message, sourcePeerType: MediaAutoDownloadPeerType?, navigationController: NavigationController)
|
||||
func makeInstantPageController(context: AccountContext, message: Message, sourcePeerType: MediaAutoDownloadPeerType?) -> ViewController?
|
||||
func makeInstantPageController(context: AccountContext, webPage: TelegramMediaWebpage, anchor: String?, sourceLocation: InstantPageSourceLocation) -> ViewController
|
||||
func openChatWallpaper(context: AccountContext, message: Message, present: @escaping (ViewController, Any?) -> Void)
|
||||
|
||||
func makeRecentSessionsController(context: AccountContext, activeSessionsContext: ActiveSessionsContext) -> ViewController & RecentSessionsController
|
||||
|
@ -2796,9 +2796,10 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
||||
}, openUrl: { url, _, _, message in
|
||||
interaction.openUrl(url)
|
||||
}, openInstantPage: { [weak self] message, data in
|
||||
if let (webpage, anchor) = instantPageAndAnchor(message: message) {
|
||||
let pageController = InstantPageController(context: context, webPage: webpage, sourceLocation: InstantPageSourceLocation(userLocation: .peer(message.id.peerId), peerType: .channel), anchor: anchor)
|
||||
self?.navigationController?.pushViewController(pageController)
|
||||
if let self, let navigationController = self.navigationController {
|
||||
if let controller = self.context.sharedContext.makeInstantPageController(context: self.context, message: message, sourcePeerType: .channel) {
|
||||
navigationController.pushViewController(controller)
|
||||
}
|
||||
}
|
||||
}, longTap: { action, message in
|
||||
}, getHiddenMedia: {
|
||||
|
@ -8,16 +8,6 @@ import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import AccountContext
|
||||
|
||||
public struct InstantPageSourceLocation {
|
||||
public var userLocation: MediaResourceUserLocation
|
||||
public var peerType: MediaAutoDownloadPeerType
|
||||
|
||||
public init(userLocation: MediaResourceUserLocation, peerType: MediaAutoDownloadPeerType) {
|
||||
self.userLocation = userLocation
|
||||
self.peerType = peerType
|
||||
}
|
||||
}
|
||||
|
||||
public func instantPageAndAnchor(message: Message) -> (TelegramMediaWebpage, String?)? {
|
||||
for media in message.media {
|
||||
if let webpage = media as? TelegramMediaWebpage, case let .Loaded(content) = webpage.content {
|
||||
|
@ -5,6 +5,7 @@ import AccountContext
|
||||
import InstantPageUI
|
||||
import InstantPageCache
|
||||
import UrlHandling
|
||||
import TelegramUIPreferences
|
||||
|
||||
func faqSearchableItems(context: AccountContext, resolvedUrl: Signal<ResolvedUrl?, NoError>, suggestAccountDeletion: Bool) -> Signal<[SettingsSearchableItem], NoError> {
|
||||
let strings = context.sharedContext.currentPresentationData.with { $0 }.strings
|
||||
@ -45,8 +46,9 @@ func faqSearchableItems(context: AccountContext, resolvedUrl: Signal<ResolvedUrl
|
||||
} else {
|
||||
nextIndex += 1
|
||||
}
|
||||
let item = SettingsSearchableItem(id: .faq(index), title: text.plainText, alternate: [], icon: .faq, breadcrumbs: [strings.SettingsSearch_FAQ, currentSection], present: { context, _, present in
|
||||
present(.push, InstantPageController(context: context, webPage: webPage, sourceLocation: InstantPageSourceLocation(userLocation: .other, peerType: .channel), anchor: anchor))
|
||||
let item = SettingsSearchableItem(id: .faq(index), title: text.plainText, alternate: [], icon: .faq, breadcrumbs: [strings.SettingsSearch_FAQ, currentSection], present: { context, _, present in
|
||||
let controller = context.sharedContext.makeInstantPageController(context: context, webPage: webPage, anchor: anchor, sourceLocation: InstantPageSourceLocation(userLocation: .other, peerType: .channel))
|
||||
present(.push, controller)
|
||||
})
|
||||
if index == 1 {
|
||||
results.insert(item, at: 0)
|
||||
|
@ -51,6 +51,7 @@ swift_library(
|
||||
"//submodules/TextFormat",
|
||||
"//submodules/CounterControllerTitleView",
|
||||
"//submodules/TelegramUI/Components/AdminUserActionsSheet",
|
||||
"//submodules/BrowserUI",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -320,7 +320,9 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
||||
self?.openUrl(url.url)
|
||||
}, shareCurrentLocation: {}, shareAccountContact: {}, sendBotCommand: { _, _ in }, openInstantPage: { [weak self] message, associatedData in
|
||||
if let strongSelf = self, let navigationController = strongSelf.getNavigationController() {
|
||||
strongSelf.context.sharedContext.openChatInstantPage(context: strongSelf.context, message: message, sourcePeerType: associatedData?.automaticDownloadPeerType, navigationController: navigationController)
|
||||
if let controller = strongSelf.context.sharedContext.makeInstantPageController(context: strongSelf.context, message: message, sourcePeerType: associatedData?.automaticDownloadPeerType) {
|
||||
navigationController.pushViewController(controller)
|
||||
}
|
||||
}
|
||||
}, openWallpaper: { [weak self] message in
|
||||
if let strongSelf = self{
|
||||
@ -1223,8 +1225,9 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
||||
}
|
||||
case .chatFolder:
|
||||
break
|
||||
case let .instantView(webpage, anchor):
|
||||
strongSelf.pushController(InstantPageController(context: strongSelf.context, webPage: webpage, sourceLocation: InstantPageSourceLocation(userLocation: .peer(strongSelf.peer.id), peerType: .channel), anchor: anchor))
|
||||
case let .instantView(webPage, anchor):
|
||||
let browserController = strongSelf.context.sharedContext.makeInstantPageController(context: strongSelf.context, webPage: webPage, anchor: anchor, sourceLocation: InstantPageSourceLocation(userLocation: .peer(strongSelf.peer.id), peerType: .channel))
|
||||
strongSelf.pushController(browserController)
|
||||
case let .join(link):
|
||||
strongSelf.presentController(JoinLinkPreviewController(context: strongSelf.context, link: link, navigateToPeer: { peer, peekData in
|
||||
if let strongSelf = self {
|
||||
|
@ -3351,7 +3351,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
}
|
||||
|
||||
if let foundGalleryMessage = foundGalleryMessage {
|
||||
strongSelf.context.sharedContext.openChatInstantPage(context: strongSelf.context, message: foundGalleryMessage, sourcePeerType: associatedData?.automaticDownloadPeerType, navigationController: navigationController)
|
||||
if let controller = strongSelf.context.sharedContext.makeInstantPageController(context: strongSelf.context, message: foundGalleryMessage, sourcePeerType: associatedData?.automaticDownloadPeerType) {
|
||||
navigationController.pushViewController(controller)
|
||||
}
|
||||
}
|
||||
}, openWallpaper: { _ in
|
||||
}, openTheme: { _ in
|
||||
|
@ -2532,8 +2532,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
if let strongSelf = self, strongSelf.isNodeLoaded, let navigationController = strongSelf.effectiveNavigationController, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id) {
|
||||
let _ = strongSelf.presentVoiceMessageDiscardAlert(action: {
|
||||
strongSelf.chatDisplayNode.dismissInput()
|
||||
strongSelf.context.sharedContext.openChatInstantPage(context: strongSelf.context, message: message, sourcePeerType: associatedData?.automaticDownloadPeerType, navigationController: navigationController)
|
||||
|
||||
if let controller = strongSelf.context.sharedContext.makeInstantPageController(context: strongSelf.context, message: message, sourcePeerType: associatedData?.automaticDownloadPeerType) {
|
||||
navigationController.pushViewController(controller)
|
||||
}
|
||||
if case .overlay = strongSelf.presentationInterfaceState.mode {
|
||||
strongSelf.chatDisplayNode.dismissAsOverlay()
|
||||
}
|
||||
@ -9261,7 +9262,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
break
|
||||
default:
|
||||
progress?.set(.single(false))
|
||||
self.context.sharedContext.openChatInstantPage(context: self.context, message: message, sourcePeerType: nil, navigationController: navigationController)
|
||||
if let controller = self.context.sharedContext.makeInstantPageController(context: self.context, message: message, sourcePeerType: nil) {
|
||||
navigationController.pushViewController(controller)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -381,13 +381,16 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func openChatInstantPageImpl(context: AccountContext, message: Message, sourcePeerType: MediaAutoDownloadPeerType?, navigationController: NavigationController) {
|
||||
if let (webpage, anchor) = instantPageAndAnchor(message: message) {
|
||||
let sourceLocation = InstantPageSourceLocation(userLocation: .peer(message.id.peerId), peerType: sourcePeerType ?? .channel)
|
||||
|
||||
let pageController = InstantPageController(context: context, webPage: webpage, sourceLocation: sourceLocation, anchor: anchor)
|
||||
navigationController.pushViewController(pageController)
|
||||
func makeInstantPageControllerImpl(context: AccountContext, message: Message, sourcePeerType: MediaAutoDownloadPeerType?, navigationController: NavigationController) -> ViewController? {
|
||||
guard let (webpage, anchor) = instantPageAndAnchor(message: message) else {
|
||||
return nil
|
||||
}
|
||||
let sourceLocation = InstantPageSourceLocation(userLocation: .peer(message.id.peerId), peerType: sourcePeerType ?? .channel)
|
||||
return makeInstantPageControllerImpl(context: context, webPage: webpage, anchor: anchor, sourceLocation: sourceLocation, navigationController: navigationController)
|
||||
}
|
||||
|
||||
func makeInstantPageControllerImpl(context: AccountContext, webPage: TelegramMediaWebpage, anchor: String?, sourceLocation: InstantPageSourceLocation, navigationController: NavigationController) -> ViewController {
|
||||
return BrowserScreen(context: context, subject: .instantPage(webPage: webPage, anchor: anchor, sourceLocation: sourceLocation))
|
||||
}
|
||||
|
||||
func openChatWallpaperImpl(context: AccountContext, message: Message, present: @escaping (ViewController, Any?) -> Void) {
|
||||
|
@ -248,10 +248,10 @@ func openResolvedUrlImpl(
|
||||
}
|
||||
})
|
||||
present(controller, nil)
|
||||
case let .instantView(webpage, anchor):
|
||||
case let .instantView(webPage, anchor):
|
||||
let sourceLocation = InstantPageSourceLocation(userLocation: .other, peerType: .channel)
|
||||
let pageController = BrowserScreen(context: context, subject: .instantPage(webPage: webpage, anchor: anchor, sourceLocation: sourceLocation))
|
||||
navigationController?.pushViewController(pageController)
|
||||
let browserController = context.sharedContext.makeInstantPageController(context: context, webPage: webPage, anchor: anchor, sourceLocation: sourceLocation)
|
||||
navigationController?.pushViewController(browserController)
|
||||
case let .join(link):
|
||||
dismissInput()
|
||||
|
||||
|
@ -1846,8 +1846,12 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
})
|
||||
}
|
||||
|
||||
public func openChatInstantPage(context: AccountContext, message: Message, sourcePeerType: MediaAutoDownloadPeerType?, navigationController: NavigationController) {
|
||||
openChatInstantPageImpl(context: context, message: message, sourcePeerType: sourcePeerType, navigationController: navigationController)
|
||||
public func makeInstantPageController(context: AccountContext, message: Message, sourcePeerType: MediaAutoDownloadPeerType?, navigationController: NavigationController) -> ViewController? {
|
||||
return makeInstantPageControllerImpl(context: context, message: message, sourcePeerType: sourcePeerType, navigationController: navigationController)
|
||||
}
|
||||
|
||||
public func makeInstantPageController(context: AccountContext, webPage: TelegramMediaWebpage, anchor: String?, sourceLocation: InstantPageSourceLocation, navigationController: NavigationController) -> ViewController {
|
||||
return makeInstantPageControllerImpl(context: context, webPage: webPage, anchor: anchor, sourceLocation: sourceLocation, navigationController: navigationController)
|
||||
}
|
||||
|
||||
public func openChatWallpaper(context: AccountContext, message: Message, present: @escaping (ViewController, Any?) -> Void) {
|
||||
|
@ -15,6 +15,7 @@ import JoinLinkPreviewUI
|
||||
import PresentationDataUtils
|
||||
import UrlWhitelist
|
||||
import UndoUI
|
||||
import BrowserUI
|
||||
|
||||
func handleTextLinkActionImpl(context: AccountContext, peerId: EnginePeer.Id?, navigateDisposable: MetaDisposable, controller: ViewController, action: TextLinkItemActionType, itemLink: TextLinkItem) {
|
||||
let presentImpl: (ViewController, Any?) -> Void = { controllerToPresent, _ in
|
||||
@ -87,8 +88,10 @@ func handleTextLinkActionImpl(context: AccountContext, peerId: EnginePeer.Id?, n
|
||||
case let .stickerPack(name, _):
|
||||
let packReference: StickerPackReference = .name(name)
|
||||
controller.present(StickerPackScreen(context: context, mainStickerPack: packReference, stickerPacks: [packReference], parentNavigationController: controller.navigationController as? NavigationController), in: .window(.root))
|
||||
case let .instantView(webpage, anchor):
|
||||
(controller.navigationController as? NavigationController)?.pushViewController(InstantPageController(context: context, webPage: webpage, sourceLocation: InstantPageSourceLocation(userLocation: peerId.flatMap(MediaResourceUserLocation.peer) ?? .other, peerType: .group), anchor: anchor))
|
||||
case let .instantView(webPage, anchor):
|
||||
let sourceLocation = InstantPageSourceLocation(userLocation: peerId.flatMap(MediaResourceUserLocation.peer) ?? .other, peerType: .group)
|
||||
let browserController = context.sharedContext.makeInstantPageController(context: context, webPage: webPage, anchor: anchor, sourceLocation: sourceLocation)
|
||||
(controller.navigationController as? NavigationController)?.pushViewController(browserController, animated: true)
|
||||
case let .join(link):
|
||||
controller.present(JoinLinkPreviewController(context: context, link: link, navigateToPeer: { peer, peekData in
|
||||
openResolvedPeerImpl(peer, .chat(textInputState: nil, subject: nil, peekData: peekData))
|
||||
|
@ -491,6 +491,16 @@ public enum MediaAutoDownloadPeerType {
|
||||
case channel
|
||||
}
|
||||
|
||||
public struct InstantPageSourceLocation {
|
||||
public var userLocation: MediaResourceUserLocation
|
||||
public var peerType: MediaAutoDownloadPeerType
|
||||
|
||||
public init(userLocation: MediaResourceUserLocation, peerType: MediaAutoDownloadPeerType) {
|
||||
self.userLocation = userLocation
|
||||
self.peerType = peerType
|
||||
}
|
||||
}
|
||||
|
||||
public func effectiveAutodownloadCategories(settings: MediaAutoDownloadSettings, networkType: MediaAutoDownloadNetworkType) -> MediaAutoDownloadCategories {
|
||||
let connection = settings.connectionSettings(for: networkType)
|
||||
switch connection.preset {
|
||||
|
@ -40,6 +40,7 @@ swift_library(
|
||||
"//submodules/ShareController",
|
||||
"//submodules/UndoUI",
|
||||
"//submodules/OverlayStatusController",
|
||||
"//submodules/TelegramUIPreferences",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -29,6 +29,7 @@ import ShareController
|
||||
import UndoUI
|
||||
import AvatarNode
|
||||
import OverlayStatusController
|
||||
import TelegramUIPreferences
|
||||
|
||||
private let durgerKingBotIds: [Int64] = [5104055776, 2200339955]
|
||||
|
||||
@ -830,7 +831,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
}
|
||||
switch result {
|
||||
case let .instantView(webPage, anchor):
|
||||
let controller = InstantPageController(context: strongSelf.context, webPage: webPage, sourceLocation: InstantPageSourceLocation(userLocation: .other, peerType: .otherPrivate), anchor: anchor)
|
||||
let controller = strongSelf.context.sharedContext.makeInstantPageController(context: strongSelf.context, webPage: webPage, anchor: anchor, sourceLocation: InstantPageSourceLocation(userLocation: .other, peerType: .otherPrivate))
|
||||
strongSelf.controller?.getNavigationController()?.pushViewController(controller)
|
||||
default:
|
||||
strongSelf.context.sharedContext.openExternalUrl(context: strongSelf.context, urlContext: .generic, url: url, forceExternal: true, presentationData: strongSelf.context.sharedContext.currentPresentationData.with { $0 }, navigationController: nil, dismissInput: {})
|
||||
|
Loading…
x
Reference in New Issue
Block a user