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
ed655a3945
commit
23fa85770d
@ -462,6 +462,18 @@ public final class NavigateToChatControllerParams {
|
||||
}
|
||||
}
|
||||
|
||||
public struct ReportReason {
|
||||
public let title: String
|
||||
public let option: Data
|
||||
public let message: String?
|
||||
|
||||
public init(title: String, option: Data, message: String?) {
|
||||
self.title = title
|
||||
self.option = option
|
||||
self.message = message
|
||||
}
|
||||
}
|
||||
|
||||
public let navigationController: NavigationController
|
||||
public let chatController: ChatController?
|
||||
public let context: AccountContext
|
||||
@ -481,7 +493,7 @@ public final class NavigateToChatControllerParams {
|
||||
public let activateMessageSearch: (ChatSearchDomain, String)?
|
||||
public let peekData: ChatPeekTimeout?
|
||||
public let peerNearbyData: ChatPeerNearbyData?
|
||||
public let reportReason: ReportReason?
|
||||
public let reportReason: NavigateToChatControllerParams.ReportReason?
|
||||
public let animated: Bool
|
||||
public let options: NavigationAnimationOptions
|
||||
public let parentGroupId: PeerGroupId?
|
||||
@ -495,7 +507,7 @@ public final class NavigateToChatControllerParams {
|
||||
public let forceOpenChat: Bool
|
||||
public let customChatNavigationStack: [EnginePeer.Id]?
|
||||
|
||||
public init(navigationController: NavigationController, chatController: ChatController? = nil, context: AccountContext, chatLocation: Location, chatLocationContextHolder: Atomic<ChatLocationContextHolder?> = Atomic<ChatLocationContextHolder?>(value: nil), subject: ChatControllerSubject? = nil, botStart: ChatControllerInitialBotStart? = nil, attachBotStart: ChatControllerInitialAttachBotStart? = nil, botAppStart: ChatControllerInitialBotAppStart? = nil, updateTextInputState: ChatTextInputState? = nil, activateInput: ChatControllerActivateInput? = nil, keepStack: NavigateToChatKeepStack = .default, useExisting: Bool = true, useBackAnimation: Bool = false, purposefulAction: (() -> Void)? = nil, scrollToEndIfExists: Bool = false, activateMessageSearch: (ChatSearchDomain, String)? = nil, peekData: ChatPeekTimeout? = nil, peerNearbyData: ChatPeerNearbyData? = nil, reportReason: ReportReason? = nil, animated: Bool = true, options: NavigationAnimationOptions = [], parentGroupId: PeerGroupId? = nil, chatListFilter: Int32? = nil, chatNavigationStack: [ChatNavigationStackItem] = [], changeColors: Bool = false, setupController: @escaping (ChatController) -> Void = { _ in }, pushController: ((ChatController, Bool, @escaping () -> Void) -> Void)? = nil, completion: @escaping (ChatController) -> Void = { _ in }, chatListCompletion: @escaping (ChatListController) -> Void = { _ in }, forceOpenChat: Bool = false, customChatNavigationStack: [EnginePeer.Id]? = nil) {
|
||||
public init(navigationController: NavigationController, chatController: ChatController? = nil, context: AccountContext, chatLocation: Location, chatLocationContextHolder: Atomic<ChatLocationContextHolder?> = Atomic<ChatLocationContextHolder?>(value: nil), subject: ChatControllerSubject? = nil, botStart: ChatControllerInitialBotStart? = nil, attachBotStart: ChatControllerInitialAttachBotStart? = nil, botAppStart: ChatControllerInitialBotAppStart? = nil, updateTextInputState: ChatTextInputState? = nil, activateInput: ChatControllerActivateInput? = nil, keepStack: NavigateToChatKeepStack = .default, useExisting: Bool = true, useBackAnimation: Bool = false, purposefulAction: (() -> Void)? = nil, scrollToEndIfExists: Bool = false, activateMessageSearch: (ChatSearchDomain, String)? = nil, peekData: ChatPeekTimeout? = nil, peerNearbyData: ChatPeerNearbyData? = nil, reportReason: NavigateToChatControllerParams.ReportReason? = nil, animated: Bool = true, options: NavigationAnimationOptions = [], parentGroupId: PeerGroupId? = nil, chatListFilter: Int32? = nil, chatNavigationStack: [ChatNavigationStackItem] = [], changeColors: Bool = false, setupController: @escaping (ChatController) -> Void = { _ in }, pushController: ((ChatController, Bool, @escaping () -> Void) -> Void)? = nil, completion: @escaping (ChatController) -> Void = { _ in }, chatListCompletion: @escaping (ChatListController) -> Void = { _ in }, forceOpenChat: Bool = false, customChatNavigationStack: [EnginePeer.Id]? = nil) {
|
||||
self.navigationController = navigationController
|
||||
self.chatController = chatController
|
||||
self.chatLocationContextHolder = chatLocationContextHolder
|
||||
@ -1024,7 +1036,7 @@ public protocol SharedAccountContext: AnyObject {
|
||||
func makeStarsIntroScreen(context: AccountContext) -> ViewController
|
||||
func makeGiftViewScreen(context: AccountContext, message: EngineMessage) -> ViewController
|
||||
|
||||
func makeContentReportScreen(context: AccountContext, subject: ReportContentSubject, forceDark: Bool, present: @escaping (ViewController) -> Void, completion: @escaping () -> Void)
|
||||
func makeContentReportScreen(context: AccountContext, subject: ReportContentSubject, forceDark: Bool, present: @escaping (ViewController) -> Void, completion: @escaping () -> Void, requestSelectMessages: ((String, Data, String?) -> Void)?)
|
||||
|
||||
func makeMiniAppListScreenInitialData(context: AccountContext) -> Signal<MiniAppListScreenInitialData, NoError>
|
||||
func makeMiniAppListScreen(context: AccountContext, initialData: MiniAppListScreenInitialData) -> ViewController
|
||||
|
@ -500,7 +500,7 @@ public final class ChatPresentationInterfaceState: Equatable {
|
||||
public let activeGroupCallInfo: ChatActiveGroupCallInfo?
|
||||
public let hasActiveGroupCall: Bool
|
||||
public let importState: ChatPresentationImportState?
|
||||
public let reportReason: ReportReason?
|
||||
public let reportReason: (String, Data, String?)?
|
||||
public let showCommands: Bool
|
||||
public let hasBotCommands: Bool
|
||||
public let showSendAsPeers: Bool
|
||||
@ -615,7 +615,7 @@ public final class ChatPresentationInterfaceState: Equatable {
|
||||
self.hasBirthdayToday = false
|
||||
}
|
||||
|
||||
public init(interfaceState: ChatInterfaceState, chatLocation: ChatLocation, renderedPeer: RenderedPeer?, isNotAccessible: Bool, explicitelyCanPinMessages: Bool, contactStatus: ChatContactStatus?, hasBots: Bool, isArchived: Bool, inputTextPanelState: ChatTextInputPanelState, editMessageState: ChatEditInterfaceMessageState?, inputQueryResults: [ChatPresentationInputQueryKind: ChatPresentationInputQueryResult], inputMode: ChatInputMode, titlePanelContexts: [ChatTitlePanelContext], keyboardButtonsMessage: Message?, pinnedMessageId: MessageId?, pinnedMessage: ChatPinnedMessage?, peerIsBlocked: Bool, peerIsMuted: Bool, peerDiscussionId: PeerId?, peerGeoLocation: PeerGeoLocation?, callsAvailable: Bool, callsPrivate: Bool, slowmodeState: ChatSlowmodeState?, chatHistoryState: ChatHistoryNodeHistoryState?, botStartPayload: String?, urlPreview: UrlPreview?, editingUrlPreview: UrlPreview?, search: ChatSearchData?, searchQuerySuggestionResult: ChatPresentationInputQueryResult?, historyFilter: HistoryFilter?, displayHistoryFilterAsList: Bool, presentationReady: Bool, chatWallpaper: TelegramWallpaper, theme: PresentationTheme, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, limitsConfiguration: LimitsConfiguration, fontSize: PresentationFontSize, bubbleCorners: PresentationChatBubbleCorners, accountPeerId: PeerId, mode: ChatControllerPresentationMode, hasScheduledMessages: Bool, autoremoveTimeout: Int32?, subject: ChatControllerSubject?, peerNearbyData: ChatPeerNearbyData?, greetingData: ChatGreetingData?, pendingUnpinnedAllMessages: Bool, activeGroupCallInfo: ChatActiveGroupCallInfo?, hasActiveGroupCall: Bool, importState: ChatPresentationImportState?, reportReason: ReportReason?, showCommands: Bool, hasBotCommands: Bool, showSendAsPeers: Bool, sendAsPeers: [SendAsPeer]?, botMenuButton: BotMenuButton, showWebView: Bool, currentSendAsPeerId: PeerId?, copyProtectionEnabled: Bool, hasPlentyOfMessages: Bool, isPremium: Bool, premiumGiftOptions: [CachedPremiumGiftOption], suggestPremiumGift: Bool, forceInputCommandsHidden: Bool, voiceMessagesAvailable: Bool, customEmojiAvailable: Bool, threadData: ThreadData?, forumTopicData: ThreadData?, isGeneralThreadClosed: Bool?, translationState: ChatPresentationTranslationState?, replyMessage: Message?, accountPeerColor: AccountPeerColor?, savedMessagesTopicPeer: EnginePeer?, hasSearchTags: Bool, isPremiumRequiredForMessaging: Bool, hasSavedChats: Bool, appliedBoosts: Int32?, boostsToUnrestrict: Int32?, businessIntro: TelegramBusinessIntro?, hasBirthdayToday: Bool) {
|
||||
public init(interfaceState: ChatInterfaceState, chatLocation: ChatLocation, renderedPeer: RenderedPeer?, isNotAccessible: Bool, explicitelyCanPinMessages: Bool, contactStatus: ChatContactStatus?, hasBots: Bool, isArchived: Bool, inputTextPanelState: ChatTextInputPanelState, editMessageState: ChatEditInterfaceMessageState?, inputQueryResults: [ChatPresentationInputQueryKind: ChatPresentationInputQueryResult], inputMode: ChatInputMode, titlePanelContexts: [ChatTitlePanelContext], keyboardButtonsMessage: Message?, pinnedMessageId: MessageId?, pinnedMessage: ChatPinnedMessage?, peerIsBlocked: Bool, peerIsMuted: Bool, peerDiscussionId: PeerId?, peerGeoLocation: PeerGeoLocation?, callsAvailable: Bool, callsPrivate: Bool, slowmodeState: ChatSlowmodeState?, chatHistoryState: ChatHistoryNodeHistoryState?, botStartPayload: String?, urlPreview: UrlPreview?, editingUrlPreview: UrlPreview?, search: ChatSearchData?, searchQuerySuggestionResult: ChatPresentationInputQueryResult?, historyFilter: HistoryFilter?, displayHistoryFilterAsList: Bool, presentationReady: Bool, chatWallpaper: TelegramWallpaper, theme: PresentationTheme, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, limitsConfiguration: LimitsConfiguration, fontSize: PresentationFontSize, bubbleCorners: PresentationChatBubbleCorners, accountPeerId: PeerId, mode: ChatControllerPresentationMode, hasScheduledMessages: Bool, autoremoveTimeout: Int32?, subject: ChatControllerSubject?, peerNearbyData: ChatPeerNearbyData?, greetingData: ChatGreetingData?, pendingUnpinnedAllMessages: Bool, activeGroupCallInfo: ChatActiveGroupCallInfo?, hasActiveGroupCall: Bool, importState: ChatPresentationImportState?, reportReason: (String, Data, String?)?, showCommands: Bool, hasBotCommands: Bool, showSendAsPeers: Bool, sendAsPeers: [SendAsPeer]?, botMenuButton: BotMenuButton, showWebView: Bool, currentSendAsPeerId: PeerId?, copyProtectionEnabled: Bool, hasPlentyOfMessages: Bool, isPremium: Bool, premiumGiftOptions: [CachedPremiumGiftOption], suggestPremiumGift: Bool, forceInputCommandsHidden: Bool, voiceMessagesAvailable: Bool, customEmojiAvailable: Bool, threadData: ThreadData?, forumTopicData: ThreadData?, isGeneralThreadClosed: Bool?, translationState: ChatPresentationTranslationState?, replyMessage: Message?, accountPeerColor: AccountPeerColor?, savedMessagesTopicPeer: EnginePeer?, hasSearchTags: Bool, isPremiumRequiredForMessaging: Bool, hasSavedChats: Bool, appliedBoosts: Int32?, boostsToUnrestrict: Int32?, businessIntro: TelegramBusinessIntro?, hasBirthdayToday: Bool) {
|
||||
self.interfaceState = interfaceState
|
||||
self.chatLocation = chatLocation
|
||||
self.renderedPeer = renderedPeer
|
||||
@ -859,7 +859,7 @@ public final class ChatPresentationInterfaceState: Equatable {
|
||||
if lhs.importState != rhs.importState {
|
||||
return false
|
||||
}
|
||||
if lhs.reportReason != rhs.reportReason {
|
||||
if lhs.reportReason?.0 != rhs.reportReason?.0 || lhs.reportReason?.1 != rhs.reportReason?.1 || lhs.reportReason?.2 != rhs.reportReason?.2 {
|
||||
return false
|
||||
}
|
||||
if lhs.showCommands != rhs.showCommands {
|
||||
@ -1136,7 +1136,7 @@ public final class ChatPresentationInterfaceState: Equatable {
|
||||
return ChatPresentationInterfaceState(interfaceState: self.interfaceState, chatLocation: self.chatLocation, renderedPeer: self.renderedPeer, isNotAccessible: self.isNotAccessible, explicitelyCanPinMessages: self.explicitelyCanPinMessages, contactStatus: self.contactStatus, hasBots: self.hasBots, isArchived: self.isArchived, inputTextPanelState: self.inputTextPanelState, editMessageState: self.editMessageState, inputQueryResults: self.inputQueryResults, inputMode: self.inputMode, titlePanelContexts: self.titlePanelContexts, keyboardButtonsMessage: self.keyboardButtonsMessage, pinnedMessageId: self.pinnedMessageId, pinnedMessage: self.pinnedMessage, peerIsBlocked: self.peerIsBlocked, peerIsMuted: self.peerIsMuted, peerDiscussionId: self.peerDiscussionId, peerGeoLocation: self.peerGeoLocation, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, slowmodeState: self.slowmodeState, chatHistoryState: self.chatHistoryState, botStartPayload: self.botStartPayload, urlPreview: self.urlPreview, editingUrlPreview: self.editingUrlPreview, search: self.search, searchQuerySuggestionResult: self.searchQuerySuggestionResult, historyFilter: self.historyFilter, displayHistoryFilterAsList: self.displayHistoryFilterAsList, presentationReady: self.presentationReady, chatWallpaper: self.chatWallpaper, theme: self.theme, strings: self.strings, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, limitsConfiguration: self.limitsConfiguration, fontSize: self.fontSize, bubbleCorners: self.bubbleCorners, accountPeerId: self.accountPeerId, mode: self.mode, hasScheduledMessages: self.hasScheduledMessages, autoremoveTimeout: self.autoremoveTimeout, subject: self.subject, peerNearbyData: self.peerNearbyData, greetingData: self.greetingData, pendingUnpinnedAllMessages: self.pendingUnpinnedAllMessages, activeGroupCallInfo: self.activeGroupCallInfo, hasActiveGroupCall: self.hasActiveGroupCall, importState: importState, reportReason: self.reportReason, showCommands: self.showCommands, hasBotCommands: self.hasBotCommands, showSendAsPeers: self.showSendAsPeers, sendAsPeers: self.sendAsPeers, botMenuButton: self.botMenuButton, showWebView: self.showWebView, currentSendAsPeerId: self.currentSendAsPeerId, copyProtectionEnabled: self.copyProtectionEnabled, hasPlentyOfMessages: self.hasPlentyOfMessages, isPremium: self.isPremium, premiumGiftOptions: self.premiumGiftOptions, suggestPremiumGift: self.suggestPremiumGift, forceInputCommandsHidden: self.forceInputCommandsHidden, voiceMessagesAvailable: self.voiceMessagesAvailable, customEmojiAvailable: self.customEmojiAvailable, threadData: self.threadData, forumTopicData: self.forumTopicData, isGeneralThreadClosed: self.isGeneralThreadClosed, translationState: self.translationState, replyMessage: self.replyMessage, accountPeerColor: self.accountPeerColor, savedMessagesTopicPeer: self.savedMessagesTopicPeer, hasSearchTags: self.hasSearchTags, isPremiumRequiredForMessaging: self.isPremiumRequiredForMessaging, hasSavedChats: self.hasSavedChats, appliedBoosts: self.appliedBoosts, boostsToUnrestrict: self.boostsToUnrestrict, businessIntro: self.businessIntro, hasBirthdayToday: self.hasBirthdayToday)
|
||||
}
|
||||
|
||||
public func updatedReportReason(_ reportReason: ReportReason?) -> ChatPresentationInterfaceState {
|
||||
public func updatedReportReason(_ reportReason: (String, Data, String?)?) -> ChatPresentationInterfaceState {
|
||||
return ChatPresentationInterfaceState(interfaceState: self.interfaceState, chatLocation: self.chatLocation, renderedPeer: self.renderedPeer, isNotAccessible: self.isNotAccessible, explicitelyCanPinMessages: self.explicitelyCanPinMessages, contactStatus: self.contactStatus, hasBots: self.hasBots, isArchived: self.isArchived, inputTextPanelState: self.inputTextPanelState, editMessageState: self.editMessageState, inputQueryResults: self.inputQueryResults, inputMode: self.inputMode, titlePanelContexts: self.titlePanelContexts, keyboardButtonsMessage: self.keyboardButtonsMessage, pinnedMessageId: self.pinnedMessageId, pinnedMessage: self.pinnedMessage, peerIsBlocked: self.peerIsBlocked, peerIsMuted: self.peerIsMuted, peerDiscussionId: self.peerDiscussionId, peerGeoLocation: self.peerGeoLocation, callsAvailable: self.callsAvailable, callsPrivate: self.callsPrivate, slowmodeState: self.slowmodeState, chatHistoryState: self.chatHistoryState, botStartPayload: self.botStartPayload, urlPreview: self.urlPreview, editingUrlPreview: self.editingUrlPreview, search: self.search, searchQuerySuggestionResult: self.searchQuerySuggestionResult, historyFilter: self.historyFilter, displayHistoryFilterAsList: self.displayHistoryFilterAsList, presentationReady: self.presentationReady, chatWallpaper: self.chatWallpaper, theme: self.theme, strings: self.strings, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, limitsConfiguration: self.limitsConfiguration, fontSize: self.fontSize, bubbleCorners: self.bubbleCorners, accountPeerId: self.accountPeerId, mode: self.mode, hasScheduledMessages: self.hasScheduledMessages, autoremoveTimeout: self.autoremoveTimeout, subject: self.subject, peerNearbyData: self.peerNearbyData, greetingData: self.greetingData, pendingUnpinnedAllMessages: self.pendingUnpinnedAllMessages, activeGroupCallInfo: self.activeGroupCallInfo, hasActiveGroupCall: self.hasActiveGroupCall, importState: self.importState, reportReason: reportReason, showCommands: self.showCommands, hasBotCommands: self.hasBotCommands, showSendAsPeers: self.showSendAsPeers, sendAsPeers: self.sendAsPeers, botMenuButton: self.botMenuButton, showWebView: self.showWebView, currentSendAsPeerId: self.currentSendAsPeerId, copyProtectionEnabled: self.copyProtectionEnabled, hasPlentyOfMessages: self.hasPlentyOfMessages, isPremium: self.isPremium, premiumGiftOptions: self.premiumGiftOptions, suggestPremiumGift: self.suggestPremiumGift, forceInputCommandsHidden: self.forceInputCommandsHidden, voiceMessagesAvailable: self.voiceMessagesAvailable, customEmojiAvailable: self.customEmojiAvailable, threadData: self.threadData, forumTopicData: self.forumTopicData, isGeneralThreadClosed: self.isGeneralThreadClosed, translationState: self.translationState, replyMessage: self.replyMessage, accountPeerColor: self.accountPeerColor, savedMessagesTopicPeer: self.savedMessagesTopicPeer, hasSearchTags: self.hasSearchTags, isPremiumRequiredForMessaging: self.isPremiumRequiredForMessaging, hasSavedChats: self.hasSavedChats, appliedBoosts: self.appliedBoosts, boostsToUnrestrict: self.boostsToUnrestrict, businessIntro: self.businessIntro, hasBirthdayToday: self.hasBirthdayToday)
|
||||
}
|
||||
|
||||
|
@ -170,6 +170,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
hasStickers: Bool = true,
|
||||
hasGifs: Bool = true,
|
||||
hideBackground: Bool = false,
|
||||
forceHasPremium: Bool = false,
|
||||
sendGif: ((FileMediaReference, UIView, CGRect, Bool, Bool) -> Bool)?
|
||||
) -> Signal<InputData, NoError> {
|
||||
let animationCache = context.animationCache
|
||||
@ -187,6 +188,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
||||
areCustomEmojiEnabled: areCustomEmojiEnabled,
|
||||
chatPeerId: chatPeerId,
|
||||
hasSearch: hasSearch,
|
||||
forceHasPremium: forceHasPremium,
|
||||
hideBackground: hideBackground
|
||||
)
|
||||
|
||||
|
@ -24,6 +24,7 @@ import ButtonComponent
|
||||
|
||||
private enum ReportResult {
|
||||
case reported
|
||||
case requestedMessageSelection
|
||||
}
|
||||
|
||||
private final class SheetPageContent: CombinedComponent {
|
||||
@ -350,6 +351,7 @@ private final class SheetContent: CombinedComponent {
|
||||
let complete: (ReportResult) -> Void
|
||||
let dismiss: () -> Void
|
||||
let update: (ComponentTransition) -> Void
|
||||
let requestSelectMessages: ((String, Data, String?) -> Void)?
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
@ -360,7 +362,8 @@ private final class SheetContent: CombinedComponent {
|
||||
openMore: @escaping () -> Void,
|
||||
complete: @escaping (ReportResult) -> Void,
|
||||
dismiss: @escaping () -> Void,
|
||||
update: @escaping (ComponentTransition) -> Void
|
||||
update: @escaping (ComponentTransition) -> Void,
|
||||
requestSelectMessages: ((String, Data, String?) -> Void)?
|
||||
) {
|
||||
self.context = context
|
||||
self.subject = subject
|
||||
@ -371,6 +374,7 @@ private final class SheetContent: CombinedComponent {
|
||||
self.complete = complete
|
||||
self.dismiss = dismiss
|
||||
self.update = update
|
||||
self.requestSelectMessages = requestSelectMessages
|
||||
}
|
||||
|
||||
static func ==(lhs: SheetContent, rhs: SheetContent) -> Bool {
|
||||
@ -417,6 +421,7 @@ private final class SheetContent: CombinedComponent {
|
||||
let accountContext = component.context
|
||||
let subject = component.subject
|
||||
let complete = component.complete
|
||||
let requestSelectMessages = component.requestSelectMessages
|
||||
let action: (SheetPageContent.Content.Item, String?) -> Void = { [weak state] item, message in
|
||||
guard let state else {
|
||||
return
|
||||
@ -435,9 +440,10 @@ private final class SheetContent: CombinedComponent {
|
||||
complete(.reported)
|
||||
}
|
||||
}, error: { error in
|
||||
// if case .premiumRequired = error {
|
||||
// complete(.premiumRequired)
|
||||
// }
|
||||
if case .messageIdRequired = error {
|
||||
requestSelectMessages?(item.title, item.option, message)
|
||||
complete(.requestedMessageSelection)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
@ -524,6 +530,7 @@ private final class SheetContainerComponent: CombinedComponent {
|
||||
let options: [ReportContentResult.Option]
|
||||
let openMore: () -> Void
|
||||
let complete: (ReportResult) -> Void
|
||||
let requestSelectMessages: ((String, Data, String?) -> Void)?
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
@ -531,7 +538,8 @@ private final class SheetContainerComponent: CombinedComponent {
|
||||
title: String,
|
||||
options: [ReportContentResult.Option],
|
||||
openMore: @escaping () -> Void,
|
||||
complete: @escaping (ReportResult) -> Void
|
||||
complete: @escaping (ReportResult) -> Void,
|
||||
requestSelectMessages: ((String, Data, String?) -> Void)?
|
||||
) {
|
||||
self.context = context
|
||||
self.subject = subject
|
||||
@ -539,6 +547,7 @@ private final class SheetContainerComponent: CombinedComponent {
|
||||
self.options = options
|
||||
self.openMore = openMore
|
||||
self.complete = complete
|
||||
self.requestSelectMessages = requestSelectMessages
|
||||
}
|
||||
|
||||
static func ==(lhs: SheetContainerComponent, rhs: SheetContainerComponent) -> Bool {
|
||||
@ -596,7 +605,8 @@ private final class SheetContainerComponent: CombinedComponent {
|
||||
update: { [weak state] transition in
|
||||
state?.pts += 1
|
||||
state?.updated(transition: transition)
|
||||
}
|
||||
},
|
||||
requestSelectMessages: context.component.requestSelectMessages
|
||||
)),
|
||||
backgroundColor: .color(environment.theme.list.modalBlocksBackgroundColor),
|
||||
followContentSizeChanges: true,
|
||||
@ -664,7 +674,8 @@ public final class ContentReportScreen: ViewControllerComponentContainer {
|
||||
title: String,
|
||||
options: [ReportContentResult.Option],
|
||||
forceDark: Bool = false,
|
||||
completed: @escaping () -> Void
|
||||
completed: @escaping () -> Void,
|
||||
requestSelectMessages: ((String, Data, String?) -> Void)?
|
||||
) {
|
||||
self.context = context
|
||||
|
||||
@ -679,7 +690,8 @@ public final class ContentReportScreen: ViewControllerComponentContainer {
|
||||
openMore: {},
|
||||
complete: { hidden in
|
||||
completeImpl?(hidden)
|
||||
}
|
||||
},
|
||||
requestSelectMessages: requestSelectMessages
|
||||
),
|
||||
navigationBarAppearance: .none,
|
||||
statusBarStyle: .ignore,
|
||||
@ -703,6 +715,8 @@ public final class ContentReportScreen: ViewControllerComponentContainer {
|
||||
|
||||
(navigationController?.viewControllers.last as? ViewController)?.present(UndoOverlayController(presentationData: presentationData, content: .emoji(name: "PoliceCar", text: presentationData.strings.Report_Succeed), elevatedLayout: false, action: { _ in return true }), in: .current)
|
||||
})
|
||||
case .requestedMessageSelection:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -308,6 +308,7 @@ final class GiftSetupScreenComponent: Component {
|
||||
hasStickers: false,
|
||||
hasGifs: false,
|
||||
hideBackground: true,
|
||||
forceHasPremium: true,
|
||||
sendGif: nil
|
||||
)
|
||||
)
|
||||
|
@ -6674,15 +6674,23 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
}
|
||||
}
|
||||
|
||||
private func openChatForReporting(_ reason: ReportReason) {
|
||||
private func openChatForReporting(title: String, option: Data, message: String?) {
|
||||
if let peer = self.data?.peer, let navigationController = (self.controller?.navigationController as? NavigationController) {
|
||||
if let channel = peer as? TelegramChannel, channel.flags.contains(.isForum) {
|
||||
let _ = self.context.engine.peers.reportPeer(peerId: peer.id, reason: reason, message: "").startStandalone()
|
||||
|
||||
self.controller?.present(UndoOverlayController(presentationData: self.presentationData, content: .emoji(name: "PoliceCar", text: self.presentationData.strings.Report_Succeed), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||
//let _ = self.context.engine.peers.reportPeer(peerId: peer.id, reason: reason, message: "").startStandalone()
|
||||
//self.controller?.present(UndoOverlayController(presentationData: self.presentationData, content: .emoji(name: "PoliceCar", text: self.presentationData.strings.Report_Succeed), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||
} else {
|
||||
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(EnginePeer(peer)), keepStack: .default, reportReason: reason, completion: { _ in
|
||||
}))
|
||||
self.context.sharedContext.navigateToChatController(
|
||||
NavigateToChatControllerParams(
|
||||
navigationController: navigationController,
|
||||
context: self.context,
|
||||
chatLocation: .peer(EnginePeer(peer)),
|
||||
keepStack: .default,
|
||||
reportReason: NavigateToChatControllerParams.ReportReason(title: title, option: option, message: message),
|
||||
completion: { _ in
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8293,23 +8301,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
self.context.sharedContext.makeContentReportScreen(context: self.context, subject: .peer(self.peerId), forceDark: false, present: { [weak self] controller in
|
||||
self?.controller?.push(controller)
|
||||
}, completion: {
|
||||
|
||||
}, requestSelectMessages: { [weak self] title, option, message in
|
||||
self?.openChatForReporting(title: title, option: option, message: message)
|
||||
})
|
||||
|
||||
// let options: [PeerReportOption]
|
||||
// if case .user = type {
|
||||
// options = [.spam, .fake, .violence, .pornography, .childAbuse]
|
||||
// } else {
|
||||
// options = [.spam, .fake, .violence, .pornography, .childAbuse, .copyright, .other]
|
||||
// }
|
||||
//
|
||||
// presentPeerReportOptions(context: self.context, parent: controller, contextController: contextController, backAction: backAction, subject: .peer(self.peerId), options: options, passthrough: true, completion: { [weak self] reason, _ in
|
||||
// if let reason = reason {
|
||||
// DispatchQueue.main.async {
|
||||
// self?.openChatForReporting(reason)
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
||||
@ -11633,7 +11627,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
|
||||
strongSelf.context.sharedContext.makeContentReportScreen(context: strongSelf.context, subject: .messages(Array(messageIds).sorted()), forceDark: false, present: { [weak self] controller in
|
||||
self?.controller?.push(controller)
|
||||
}, completion: {})
|
||||
}, completion: {}, requestSelectMessages: nil)
|
||||
}, displayCopyProtectionTip: { [weak self] node, save in
|
||||
if let strongSelf = self, let peer = strongSelf.data?.peer, let messageIds = strongSelf.state.selectedMessageIds, !messageIds.isEmpty {
|
||||
let _ = (strongSelf.context.engine.data.get(EngineDataMap(
|
||||
|
@ -6984,7 +6984,8 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
}
|
||||
self.isReporting = false
|
||||
self.updateIsProgressPaused()
|
||||
}
|
||||
},
|
||||
requestSelectMessages: nil
|
||||
)
|
||||
|
||||
// let options: [PeerReportOption] = [.spam, .violence, .pornography, .childAbuse, .copyright, .illegalDrugs, .personalDetails, .other]
|
||||
|
@ -1928,40 +1928,27 @@ extension ChatControllerImpl {
|
||||
}
|
||||
}, reportSelectedMessages: { [weak self] in
|
||||
if let strongSelf = self, let messageIds = strongSelf.presentationInterfaceState.interfaceState.selectionState?.selectedIds, !messageIds.isEmpty {
|
||||
if let reportReason = strongSelf.presentationInterfaceState.reportReason {
|
||||
if let (_, option, message) = strongSelf.presentationInterfaceState.reportReason {
|
||||
let presentationData = strongSelf.presentationData
|
||||
let controller = ActionSheetController(presentationData: presentationData, allowInputInset: true)
|
||||
let dismissAction: () -> Void = { [weak self, weak controller] in
|
||||
self?.view.window?.endEditing(true)
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
var message = ""
|
||||
var items: [ActionSheetItem] = []
|
||||
items.append(ReportPeerHeaderActionSheetItem(context: strongSelf.context, text: presentationData.strings.Report_AdditionalDetailsText))
|
||||
items.append(ReportPeerDetailsActionSheetItem(context: strongSelf.context, theme: presentationData.theme, placeholderText: presentationData.strings.Report_AdditionalDetailsPlaceholder, textUpdated: { text in
|
||||
message = text
|
||||
}))
|
||||
items.append(ActionSheetButtonItem(title: presentationData.strings.Report_Report, color: .accent, font: .bold, enabled: true, action: {
|
||||
dismissAction()
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } }, completion: { _ in
|
||||
let _ = (strongSelf.context.engine.peers.reportPeerMessages(messageIds: Array(messageIds), reason: reportReason, message: message)
|
||||
|> deliverOnMainQueue).startStandalone(completed: {
|
||||
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .emoji(name: "PoliceCar", text: presentationData.strings.Report_Succeed), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||
})
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } }, completion: { _ in
|
||||
let _ = (strongSelf.context.engine.messages.reportContent(subject: .messages(Array(messageIds)), option: option, message: message)
|
||||
|> deliverOnMainQueue).startStandalone(completed: {
|
||||
strongSelf.present(UndoOverlayController(presentationData: presentationData, content: .emoji(name: "PoliceCar", text: presentationData.strings.Report_Succeed), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||
})
|
||||
}))
|
||||
|
||||
controller.setItemGroups([
|
||||
ActionSheetItemGroup(items: items),
|
||||
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
|
||||
])
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
} else {
|
||||
strongSelf.context.sharedContext.makeContentReportScreen(context: strongSelf.context, subject: .messages(Array(messageIds).sorted()), forceDark: false, present: { [weak self] controller in
|
||||
self?.push(controller)
|
||||
}, completion: { [weak self] in
|
||||
self?.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
})
|
||||
} else {
|
||||
strongSelf.context.sharedContext.makeContentReportScreen(
|
||||
context: strongSelf.context,
|
||||
subject: .messages(Array(messageIds).sorted()),
|
||||
forceDark: false,
|
||||
present: { [weak self] controller in
|
||||
self?.push(controller)
|
||||
},
|
||||
completion: { [weak self] in
|
||||
self?.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
},
|
||||
requestSelectMessages: nil
|
||||
)
|
||||
}
|
||||
}
|
||||
}, reportMessages: { [weak self] messages, contextController in
|
||||
@ -1979,7 +1966,8 @@ extension ChatControllerImpl {
|
||||
}
|
||||
self.push(controller)
|
||||
},
|
||||
completion: {}
|
||||
completion: {},
|
||||
requestSelectMessages: nil
|
||||
)
|
||||
}, blockMessageAuthor: { [weak self] message, contextController in
|
||||
contextController?.dismiss(completion: {
|
||||
|
@ -5389,30 +5389,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
if selectionState.selectedIds.count > 0 {
|
||||
strongSelf.chatTitleView?.titleContent = .custom(presentationInterfaceState.strings.Conversation_SelectedMessages(Int32(selectionState.selectedIds.count)), nil, false)
|
||||
} else {
|
||||
if let reportReason = presentationInterfaceState.reportReason {
|
||||
let title: String
|
||||
switch reportReason {
|
||||
case .spam:
|
||||
title = presentationInterfaceState.strings.ReportPeer_ReasonSpam
|
||||
case .fake:
|
||||
title = presentationInterfaceState.strings.ReportPeer_ReasonFake
|
||||
case .violence:
|
||||
title = presentationInterfaceState.strings.ReportPeer_ReasonViolence
|
||||
case .porno:
|
||||
title = presentationInterfaceState.strings.ReportPeer_ReasonPornography
|
||||
case .childAbuse:
|
||||
title = presentationInterfaceState.strings.ReportPeer_ReasonChildAbuse
|
||||
case .copyright:
|
||||
title = presentationInterfaceState.strings.ReportPeer_ReasonCopyright
|
||||
case .illegalDrugs:
|
||||
title = presentationInterfaceState.strings.ReportPeer_ReasonIllegalDrugs
|
||||
case .personalDetails:
|
||||
title = presentationInterfaceState.strings.ReportPeer_ReasonPersonalDetails
|
||||
case .custom:
|
||||
title = presentationInterfaceState.strings.ReportPeer_ReasonOther
|
||||
case .irrelevantLocation:
|
||||
title = ""
|
||||
}
|
||||
if let (title, _, _) = presentationInterfaceState.reportReason {
|
||||
strongSelf.chatTitleView?.titleContent = .custom(title, presentationInterfaceState.strings.Conversation_SelectMessages, false)
|
||||
} else {
|
||||
strongSelf.chatTitleView?.titleContent = .custom(presentationInterfaceState.strings.Conversation_SelectMessages, nil, false)
|
||||
@ -9878,8 +9855,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.interfaceInteraction?.beginMessageSearch(.everything, query)
|
||||
}
|
||||
|
||||
public func beginReportSelection(reason: ReportReason) {
|
||||
self.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedReportReason(reason).updatedInterfaceState { $0.withUpdatedSelectedMessages([]) } })
|
||||
public func beginReportSelection(reason: NavigateToChatControllerParams.ReportReason) {
|
||||
self.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedReportReason((reason.title, reason.option, reason.message)).updatedInterfaceState { $0.withUpdatedSelectedMessages([]) } })
|
||||
}
|
||||
|
||||
func displayMediaRecordingTooltip() {
|
||||
|
@ -2811,11 +2811,11 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
return GiftViewScreen(context: context, subject: .message(message))
|
||||
}
|
||||
|
||||
public func makeContentReportScreen(context: AccountContext, subject: ReportContentSubject, forceDark: Bool, present: @escaping (ViewController) -> Void, completion: @escaping () -> Void) {
|
||||
public func makeContentReportScreen(context: AccountContext, subject: ReportContentSubject, forceDark: Bool, present: @escaping (ViewController) -> Void, completion: @escaping () -> Void, requestSelectMessages: ((String, Data, String?) -> Void)?) {
|
||||
let _ = (context.engine.messages.reportContent(subject: subject, option: nil, message: nil)
|
||||
|> deliverOnMainQueue).startStandalone(next: { result in
|
||||
if case let .options(title, options) = result {
|
||||
present(ContentReportScreen(context: context, subject: subject, title: title, options: options, forceDark: forceDark, completed: completion))
|
||||
present(ContentReportScreen(context: context, subject: subject, title: title, options: options, forceDark: forceDark, completed: completion, requestSelectMessages: requestSelectMessages))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user