mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
- Story search UI
- Delete message confirmation
This commit is contained in:
@@ -319,88 +319,31 @@ extension ChatControllerImpl {
|
||||
))
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
func beginDeleteMessagesWithUndo(messageIds: Set<MessageId>, type: InteractiveMessagesDeletionType) {
|
||||
self.chatDisplayNode.historyNode.ignoreMessageIds = Set(messageIds)
|
||||
|
||||
/*do {
|
||||
self.navigationActionDisposable.set((self.context.engine.peers.fetchChannelParticipant(peerId: peerId, participantId: author.id)
|
||||
|> deliverOnMainQueue).startStrict(next: {
|
||||
if let strongSelf = self {
|
||||
if "".isEmpty {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let canBan = participant?.canBeBannedBy(peerId: accountPeerId) ?? true
|
||||
|
||||
let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
|
||||
var items: [ActionSheetItem] = []
|
||||
|
||||
var actions = Set<Int>([0])
|
||||
|
||||
let toggleCheck: (Int, Int) -> Void = { [weak actionSheet] category, itemIndex in
|
||||
if actions.contains(category) {
|
||||
actions.remove(category)
|
||||
} else {
|
||||
actions.insert(category)
|
||||
}
|
||||
actionSheet?.updateItem(groupIndex: 0, itemIndex: itemIndex, { item in
|
||||
if let item = item as? ActionSheetCheckboxItem {
|
||||
return ActionSheetCheckboxItem(title: item.title, label: item.label, value: !item.value, action: item.action)
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
|
||||
var itemIndex = 0
|
||||
var categories: [Int] = [0]
|
||||
if canBan {
|
||||
categories.append(1)
|
||||
}
|
||||
categories.append(contentsOf: [2, 3])
|
||||
|
||||
for categoryId in categories as [Int] {
|
||||
var title = ""
|
||||
if categoryId == 0 {
|
||||
title = strongSelf.presentationData.strings.Conversation_Moderate_Delete
|
||||
} else if categoryId == 1 {
|
||||
title = strongSelf.presentationData.strings.Conversation_Moderate_Ban
|
||||
} else if categoryId == 2 {
|
||||
title = strongSelf.presentationData.strings.Conversation_Moderate_Report
|
||||
} else if categoryId == 3 {
|
||||
title = strongSelf.presentationData.strings.Conversation_Moderate_DeleteAllMessages(EnginePeer(author).displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)).string
|
||||
}
|
||||
let index = itemIndex
|
||||
items.append(ActionSheetCheckboxItem(title: title, label: "", value: actions.contains(categoryId), action: { value in
|
||||
toggleCheck(categoryId, index)
|
||||
}))
|
||||
itemIndex += 1
|
||||
}
|
||||
|
||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Done, action: { [weak self, weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
if actions.contains(3) {
|
||||
let _ = strongSelf.context.engine.messages.deleteAllMessagesWithAuthor(peerId: peerId, authorId: author.id, namespace: Namespaces.Message.Cloud).startStandalone()
|
||||
let _ = strongSelf.context.engine.messages.clearAuthorHistory(peerId: peerId, memberId: author.id).startStandalone()
|
||||
} else if actions.contains(0) {
|
||||
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: .forEveryone).startStandalone()
|
||||
}
|
||||
if actions.contains(1) {
|
||||
let _ = strongSelf.context.engine.peers.removePeerMember(peerId: peerId, memberId: author.id).startStandalone()
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
})
|
||||
])])
|
||||
strongSelf.chatDisplayNode.dismissInput()
|
||||
strongSelf.present(actionSheet, in: .window(.root))
|
||||
}
|
||||
}))
|
||||
}*/
|
||||
//TODO:localize
|
||||
let undoTitle: String
|
||||
if messageIds.count == 1 {
|
||||
undoTitle = "Message Deleted"
|
||||
} else {
|
||||
undoTitle = "\(messageIds.count) Messages Deleted"
|
||||
}
|
||||
self.present(UndoOverlayController(presentationData: self.context.sharedContext.currentPresentationData.with { $0 }, content: .removedChat(title: undoTitle, text: nil), elevatedLayout: false, position: .top, action: { [weak self] value in
|
||||
guard let self else {
|
||||
return false
|
||||
}
|
||||
if value == .commit {
|
||||
let _ = self.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: type).startStandalone()
|
||||
return true
|
||||
} else if value == .undo {
|
||||
self.chatDisplayNode.historyNode.ignoreMessageIds = Set()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}), in: .current)
|
||||
}
|
||||
|
||||
func presentDeleteMessageOptions(messageIds: Set<MessageId>, options: ChatAvailableMessageActionOptions, contextController: ContextControllerProtocol?, completion: @escaping (ContextMenuActionResult) -> Void) {
|
||||
@@ -429,7 +372,7 @@ extension ChatControllerImpl {
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: .forEveryone).startStandalone()
|
||||
strongSelf.beginDeleteMessagesWithUndo(messageIds: messageIds, type: .forEveryone)
|
||||
}
|
||||
}))
|
||||
}
|
||||
@@ -466,7 +409,8 @@ extension ChatControllerImpl {
|
||||
}
|
||||
let commit = {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: .forEveryone).startStandalone()
|
||||
|
||||
strongSelf.beginDeleteMessagesWithUndo(messageIds: messageIds, type: .forEveryone)
|
||||
}
|
||||
if let giveaway {
|
||||
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||
@@ -501,7 +445,8 @@ extension ChatControllerImpl {
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: .forEveryone).startStandalone()
|
||||
|
||||
strongSelf.beginDeleteMessagesWithUndo(messageIds: messageIds, type: .forEveryone)
|
||||
}
|
||||
}))
|
||||
}
|
||||
@@ -534,7 +479,7 @@ extension ChatControllerImpl {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: unsendPersonalMessages ? .forEveryone : .forLocalPeer).startStandalone()
|
||||
strongSelf.beginDeleteMessagesWithUndo(messageIds: messageIds, type: unsendPersonalMessages ? .forEveryone : .forLocalPeer)
|
||||
}
|
||||
|
||||
if "".isEmpty {
|
||||
@@ -553,8 +498,8 @@ extension ChatControllerImpl {
|
||||
actionSheet?.dismissAnimated()
|
||||
if let strongSelf = self {
|
||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } })
|
||||
let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: unsendPersonalMessages ? .forEveryone : .forLocalPeer).startStandalone()
|
||||
|
||||
strongSelf.beginDeleteMessagesWithUndo(messageIds: messageIds, type: unsendPersonalMessages ? .forEveryone : .forLocalPeer)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user