mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-25 01:22:41 +00:00
Autoremove improvements
This commit is contained in:
parent
33dc13f2d5
commit
c077f75e73
@ -8396,7 +8396,10 @@ Sorry for the inconvenience.";
|
||||
"GlobalAutodeleteSettings.SetConfirmToastEnabled" = "Messages in all new chats you start will be automatically deleted after %@.";
|
||||
"GlobalAutodeleteSettings.SetConfirmToastDisabled" = "Messages in all new chats you start will not be automatically deleted.";
|
||||
"GlobalAutodeleteSettings.ApplyChatsTitle" = "Select Chats";
|
||||
"GlobalAutodeleteSettings.ApplyChatsPlaceholder" = "Select chats to apply the %@ self-destruct timer";
|
||||
"GlobalAutodeleteSettings.ApplyChatsPlaceholder" = "Select chats to apply a %@ self-destruct timer";
|
||||
"GlobalAutodeleteSettings.ApplyChatsToast" = "You applied the %1$@ self-destruct timer to %2$@.";
|
||||
"GlobalAutodeleteSettings.ApplyChatsSubject_1" = "%@ chat";
|
||||
"GlobalAutodeleteSettings.ApplyChatsSubject_any" = "%@ chats";
|
||||
"GlobalAutodeleteSettings.AttemptDisabledGroupSelection" = "You need admin rights in this group to enable auto-delete.";
|
||||
"GlobalAutodeleteSettings.AttemptDisabledChannelSelection" = "You need admin rights in this channel to enable auto-delete.";
|
||||
"GlobalAutodeleteSettings.AttemptDisabledGenericSelection" = "You can't enable auto-delete in this chat.";
|
||||
|
||||
@ -80,17 +80,19 @@ public final class ContactMultiselectionControllerParams {
|
||||
public let options: [ContactListAdditionalOption]
|
||||
public let filters: [ContactListFilter]
|
||||
public let isPeerEnabled: ((EnginePeer) -> Bool)?
|
||||
public let attemptDisabledItemSelection: ((EnginePeer) -> Void)?
|
||||
public let alwaysEnabled: Bool
|
||||
public let limit: Int32?
|
||||
public let reachedLimit: ((Int32) -> Void)?
|
||||
|
||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, mode: ContactMultiselectionControllerMode, options: [ContactListAdditionalOption], filters: [ContactListFilter] = [.excludeSelf], isPeerEnabled: ((EnginePeer) -> Bool)? = nil, alwaysEnabled: Bool = false, limit: Int32? = nil, reachedLimit: ((Int32) -> Void)? = nil) {
|
||||
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, mode: ContactMultiselectionControllerMode, options: [ContactListAdditionalOption], filters: [ContactListFilter] = [.excludeSelf], isPeerEnabled: ((EnginePeer) -> Bool)? = nil, attemptDisabledItemSelection: ((EnginePeer) -> Void)? = nil, alwaysEnabled: Bool = false, limit: Int32? = nil, reachedLimit: ((Int32) -> Void)? = nil) {
|
||||
self.context = context
|
||||
self.updatedPresentationData = updatedPresentationData
|
||||
self.mode = mode
|
||||
self.options = options
|
||||
self.filters = filters
|
||||
self.isPeerEnabled = isPeerEnabled
|
||||
self.attemptDisabledItemSelection = attemptDisabledItemSelection
|
||||
self.alwaysEnabled = alwaysEnabled
|
||||
self.limit = limit
|
||||
self.reachedLimit = reachedLimit
|
||||
|
||||
@ -326,6 +326,31 @@ public func globalAutoremoveScreen(context: AccountContext, initialValue: Int32,
|
||||
canManage = channel.hasPermission(.changeInfo)
|
||||
}
|
||||
return canManage
|
||||
},
|
||||
attemptDisabledItemSelection: { peer in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
let text: String
|
||||
if case let .channel(channel) = peer {
|
||||
if case .group = channel.info {
|
||||
text = presentationData.strings.GlobalAutodeleteSettings_AttemptDisabledGroupSelection
|
||||
} else {
|
||||
text = presentationData.strings.GlobalAutodeleteSettings_AttemptDisabledChannelSelection
|
||||
}
|
||||
} else if case .legacyGroup = peer {
|
||||
text = presentationData.strings.GlobalAutodeleteSettings_AttemptDisabledGroupSelection
|
||||
} else {
|
||||
text = presentationData.strings.GlobalAutodeleteSettings_AttemptDisabledGenericSelection
|
||||
}
|
||||
|
||||
presentControllerImpl?(standardTextAlertController(
|
||||
theme: AlertControllerTheme(presentationData: presentationData),
|
||||
title: nil,
|
||||
text: text,
|
||||
actions: [
|
||||
TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})
|
||||
]
|
||||
), nil)
|
||||
}
|
||||
))
|
||||
selectionController.navigationPresentation = .modal
|
||||
|
||||
@ -29,6 +29,7 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
|
||||
private let context: AccountContext
|
||||
private let mode: ContactMultiselectionControllerMode
|
||||
private let isPeerEnabled: ((EnginePeer) -> Bool)?
|
||||
private let attemptDisabledItemSelection: ((EnginePeer) -> Void)?
|
||||
|
||||
private let titleView: CounterContollerTitleView
|
||||
|
||||
@ -85,6 +86,7 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
|
||||
self.context = params.context
|
||||
self.mode = params.mode
|
||||
self.isPeerEnabled = params.isPeerEnabled
|
||||
self.attemptDisabledItemSelection = params.attemptDisabledItemSelection
|
||||
self.options = params.options
|
||||
self.filters = params.filters
|
||||
self.limit = params.limit
|
||||
@ -222,7 +224,7 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
|
||||
}
|
||||
|
||||
override func loadDisplayNode() {
|
||||
self.displayNode = ContactMultiselectionControllerNode(navigationBar: self.navigationBar, context: self.context, presentationData: self.presentationData, mode: self.mode, isPeerEnabled: self.isPeerEnabled, options: self.options, filters: self.filters, limit: self.limit, reachedSelectionLimit: self.params.reachedLimit)
|
||||
self.displayNode = ContactMultiselectionControllerNode(navigationBar: self.navigationBar, context: self.context, presentationData: self.presentationData, mode: self.mode, isPeerEnabled: self.isPeerEnabled, attemptDisabledItemSelection: self.attemptDisabledItemSelection, options: self.options, filters: self.filters, limit: self.limit, reachedSelectionLimit: self.params.reachedLimit)
|
||||
switch self.contactsNode.contentNode {
|
||||
case let .contacts(contactsNode):
|
||||
self._listReady.set(contactsNode.ready)
|
||||
|
||||
@ -71,7 +71,7 @@ final class ContactMultiselectionControllerNode: ASDisplayNode {
|
||||
private let animationCache: AnimationCache
|
||||
private let animationRenderer: MultiAnimationRenderer
|
||||
|
||||
init(navigationBar: NavigationBar?, context: AccountContext, presentationData: PresentationData, mode: ContactMultiselectionControllerMode, isPeerEnabled: ((EnginePeer) -> Bool)?, options: [ContactListAdditionalOption], filters: [ContactListFilter], limit: Int32?, reachedSelectionLimit: ((Int32) -> Void)?) {
|
||||
init(navigationBar: NavigationBar?, context: AccountContext, presentationData: PresentationData, mode: ContactMultiselectionControllerMode, isPeerEnabled: ((EnginePeer) -> Bool)?, attemptDisabledItemSelection: ((EnginePeer) -> Void)?, options: [ContactListAdditionalOption], filters: [ContactListFilter], limit: Int32?, reachedSelectionLimit: ((Int32) -> Void)?) {
|
||||
self.navigationBar = navigationBar
|
||||
|
||||
self.context = context
|
||||
@ -102,6 +102,9 @@ final class ContactMultiselectionControllerNode: ASDisplayNode {
|
||||
|
||||
placeholder = placeholderValue
|
||||
let chatListNode = ChatListNode(context: context, location: .chatList(groupId: .root), previewing: false, fillPreloadItems: false, mode: .peers(filter: [.excludeSecretChats], isSelecting: true, additionalCategories: additionalCategories?.categories ?? [], chatListFilters: chatListFilters, displayAutoremoveTimeout: chatSelection.displayAutoremoveTimeout), isPeerEnabled: isPeerEnabled, theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, animationCache: self.animationCache, animationRenderer: self.animationRenderer, disableAnimations: true, isInlineMode: false)
|
||||
chatListNode.disabledPeerSelected = { peer, _ in
|
||||
attemptDisabledItemSelection?(peer)
|
||||
}
|
||||
if let limit = limit {
|
||||
chatListNode.selectionLimit = limit
|
||||
chatListNode.reachedSelectionLimit = reachedSelectionLimit
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user