Merge pull request #20 from RyanRory/groups-rebuild-fix

Groups rebuild fix
pull/894/head
Morgan Pretty 3 months ago committed by GitHub
commit c5cccad08f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2036,6 +2036,7 @@ extension ConversationVC:
confirmStyle: .danger, confirmStyle: .danger,
cancelTitle: "cancel".localized(), cancelTitle: "cancel".localized(),
cancelStyle: .alert_text, cancelStyle: .alert_text,
dismissOnConfirm: false,
onConfirm: { [weak self, dependencies = viewModel.dependencies] modal in onConfirm: { [weak self, dependencies = viewModel.dependencies] modal in
/// Determine the selected action index /// Determine the selected action index
let selectedIndex: Int = { let selectedIndex: Int = {
@ -2061,26 +2062,31 @@ extension ConversationVC:
.publisherForAction(at: selectedIndex, using: dependencies) .publisherForAction(at: selectedIndex, using: dependencies)
.sinkUntilComplete( .sinkUntilComplete(
receiveCompletion: { result in receiveCompletion: { result in
DispatchQueue.main.async {
self?.viewModel.showToast(
text: {
switch result { switch result {
case .finished: case .finished:
return "deleteMessageDeleted" DispatchQueue.main.async {
self?.viewModel.showToast(
text: "deleteMessageDeleted"
.putNumber(messagesToDelete.count) .putNumber(messagesToDelete.count)
.localized() .localized(),
backgroundColor: .backgroundSecondary,
inset: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing
)
modal.close()
}
case .failure: case .failure:
return "deleteMessageFailed" DispatchQueue.main.async {
self?.viewModel.showToast(
text: "deleteMessageFailed"
.putNumber(messagesToDelete.count) .putNumber(messagesToDelete.count)
.localized() .localized(),
}
}(),
backgroundColor: .backgroundSecondary, backgroundColor: .backgroundSecondary,
inset: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing inset: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing
) )
} }
} }
}
) )
}, },
afterClosed: { [weak self] in afterClosed: { [weak self] in

@ -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<TimestampInfo> { static func idsForTermWithin(threadId: String, pattern: FTS5Pattern) -> SQLRequest<TimestampInfo> {
let interaction: TypedTableAlias<Interaction> = TypedTableAlias() let interaction: TypedTableAlias<Interaction> = TypedTableAlias()
let interactionFullTextSearch: TypedTableAlias<FullTextSearch> = TypedTableAlias(name: Interaction.fullTextSearchTableName) let interactionFullTextSearch: TypedTableAlias<FullTextSearch> = TypedTableAlias(name: Interaction.fullTextSearchTableName)

@ -35,11 +35,11 @@ extension MessageReceiver {
guard guard
let author: String = message.author, let author: String = message.author,
let timestampMs: UInt64 = message.timestamp, let timestampMs: UInt64 = message.timestamp,
let interactionId: Int64 = try Interaction let interactionInfo: Interaction.ThreadInfo = try Interaction
.select(.id) .select(.id, .threadId)
.filter(Interaction.Columns.timestampMs == Int64(timestampMs)) .filter(Interaction.Columns.timestampMs == Int64(timestampMs))
.filter(Interaction.Columns.authorId == author) .filter(Interaction.Columns.authorId == author)
.asRequest(of: Int64.self) .asRequest(of: Interaction.ThreadInfo.self)
.fetchOne(db) .fetchOne(db)
else { return } else { return }
@ -48,20 +48,20 @@ extension MessageReceiver {
/// message content /// message content
let hashes: Set<String> = try Interaction.serverHashesForDeletion( let hashes: Set<String> = try Interaction.serverHashesForDeletion(
db, db,
interactionIds: [interactionId] interactionIds: [interactionInfo.id]
) )
try Interaction.markAsDeleted( try Interaction.markAsDeleted(
db, db,
threadId: threadId, threadId: threadId,
threadVariant: threadVariant, threadVariant: threadVariant,
interactionIds: [interactionId], interactionIds: [interactionInfo.id],
localOnly: false, localOnly: false,
using: dependencies using: dependencies
) )
/// If it's the `Note to Self` conversation then we want to just delete the interaction /// If it's the `Note to Self` conversation then we want to just delete the interaction
if userSessionId.hexString == threadId { if userSessionId.hexString == interactionInfo.threadId {
try Interaction.deleteOne(db, id: interactionId) try Interaction.deleteOne(db, id: interactionInfo.id)
} }
/// Can't delete from the legacy group swarm so only bother for contact conversations /// Can't delete from the legacy group swarm so only bother for contact conversations

@ -309,11 +309,13 @@ public class ConfirmationModal: Modal, UITextFieldDelegate, UITextViewDelegate {
textField.placeholder = inputInfo.placeholder textField.placeholder = inputInfo.placeholder
textField.text = (inputInfo.initialValue ?? "") textField.text = (inputInfo.initialValue ?? "")
textField.clearButtonMode = (inputInfo.clearButton ? .always : .never) textField.clearButtonMode = (inputInfo.clearButton ? .always : .never)
textField.isAccessibilityElement = true
textField.accessibilityIdentifier = inputInfo.accessibility?.identifier textField.accessibilityIdentifier = inputInfo.accessibility?.identifier
textField.accessibilityLabel = inputInfo.accessibility?.label textField.accessibilityLabel = inputInfo.accessibility?.label ?? textField.text
textFieldContainer.isHidden = false textFieldContainer.isHidden = false
internalOnTextChanged = { [weak confirmButton, weak cancelButton] text, _ in internalOnTextChanged = { [weak confirmButton, weak cancelButton] text, _ in
onTextChanged(text) onTextChanged(text)
self.textField.accessibilityLabel = text
confirmButton?.isEnabled = info.confirmEnabled.isValid(with: info) confirmButton?.isEnabled = info.confirmEnabled.isValid(with: info)
cancelButton?.isEnabled = info.cancelEnabled.isValid(with: info) cancelButton?.isEnabled = info.cancelEnabled.isValid(with: info)
} }

Loading…
Cancel
Save