diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index 585f18583..10e80dcee 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -2036,6 +2036,7 @@ extension ConversationVC: confirmStyle: .danger, cancelTitle: "cancel".localized(), cancelStyle: .alert_text, + dismissOnConfirm: false, onConfirm: { [weak self, dependencies = viewModel.dependencies] modal in /// Determine the selected action index let selectedIndex: Int = { @@ -2061,24 +2062,29 @@ extension ConversationVC: .publisherForAction(at: selectedIndex, using: dependencies) .sinkUntilComplete( receiveCompletion: { result in - DispatchQueue.main.async { - self?.viewModel.showToast( - text: { - switch result { - case .finished: - return "deleteMessageDeleted" - .putNumber(messagesToDelete.count) - .localized() - - case .failure: - return "deleteMessageFailed" - .putNumber(messagesToDelete.count) - .localized() - } - }(), - backgroundColor: .backgroundSecondary, - inset: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing - ) + switch result { + case .finished: + DispatchQueue.main.async { + self?.viewModel.showToast( + text: "deleteMessageDeleted" + .putNumber(messagesToDelete.count) + .localized(), + backgroundColor: .backgroundSecondary, + inset: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing + ) + + modal.close() + } + case .failure: + DispatchQueue.main.async { + self?.viewModel.showToast( + text: "deleteMessageFailed" + .putNumber(messagesToDelete.count) + .localized(), + backgroundColor: .backgroundSecondary, + inset: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing + ) + } } } ) diff --git a/SessionMessagingKit/Database/Models/Interaction.swift b/SessionMessagingKit/Database/Models/Interaction.swift index 8a13afb04..11eed2dff 100644 --- a/SessionMessagingKit/Database/Models/Interaction.swift +++ b/SessionMessagingKit/Database/Models/Interaction.swift @@ -812,6 +812,19 @@ public extension Interaction { } } + struct ThreadInfo: FetchableRecord, Codable { + public let id: Int64 + public let threadId: String + + public init( + id: Int64, + threadId: String + ) { + self.id = id + self.threadId = threadId + } + } + static func idsForTermWithin(threadId: String, pattern: FTS5Pattern) -> SQLRequest { let interaction: TypedTableAlias = TypedTableAlias() let interactionFullTextSearch: TypedTableAlias = TypedTableAlias(name: Interaction.fullTextSearchTableName) diff --git a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+UnsendRequests.swift b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+UnsendRequests.swift index e1f954627..44cfb7908 100644 --- a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+UnsendRequests.swift +++ b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+UnsendRequests.swift @@ -35,11 +35,11 @@ extension MessageReceiver { guard let author: String = message.author, let timestampMs: UInt64 = message.timestamp, - let interactionId: Int64 = try Interaction - .select(.id) + let interactionInfo: Interaction.ThreadInfo = try Interaction + .select(.id, .threadId) .filter(Interaction.Columns.timestampMs == Int64(timestampMs)) .filter(Interaction.Columns.authorId == author) - .asRequest(of: Int64.self) + .asRequest(of: Interaction.ThreadInfo.self) .fetchOne(db) else { return } @@ -48,20 +48,20 @@ extension MessageReceiver { /// message content let hashes: Set = try Interaction.serverHashesForDeletion( db, - interactionIds: [interactionId] + interactionIds: [interactionInfo.id] ) try Interaction.markAsDeleted( db, threadId: threadId, threadVariant: threadVariant, - interactionIds: [interactionId], + interactionIds: [interactionInfo.id], localOnly: false, using: dependencies ) /// If it's the `Note to Self` conversation then we want to just delete the interaction - if userSessionId.hexString == threadId { - try Interaction.deleteOne(db, id: interactionId) + if userSessionId.hexString == interactionInfo.threadId { + try Interaction.deleteOne(db, id: interactionInfo.id) } /// Can't delete from the legacy group swarm so only bother for contact conversations diff --git a/SessionUIKit/Components/ConfirmationModal.swift b/SessionUIKit/Components/ConfirmationModal.swift index 8007f55b6..f7d2d8eaf 100644 --- a/SessionUIKit/Components/ConfirmationModal.swift +++ b/SessionUIKit/Components/ConfirmationModal.swift @@ -309,11 +309,13 @@ public class ConfirmationModal: Modal, UITextFieldDelegate, UITextViewDelegate { textField.placeholder = inputInfo.placeholder textField.text = (inputInfo.initialValue ?? "") textField.clearButtonMode = (inputInfo.clearButton ? .always : .never) + textField.isAccessibilityElement = true textField.accessibilityIdentifier = inputInfo.accessibility?.identifier - textField.accessibilityLabel = inputInfo.accessibility?.label + textField.accessibilityLabel = inputInfo.accessibility?.label ?? textField.text textFieldContainer.isHidden = false internalOnTextChanged = { [weak confirmButton, weak cancelButton] text, _ in onTextChanged(text) + self.textField.accessibilityLabel = text confirmButton?.isEnabled = info.confirmEnabled.isValid(with: info) cancelButton?.isEnabled = info.cancelEnabled.isValid(with: info) }