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,
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
)
}
}
}
)

@ -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> {
let interaction: TypedTableAlias<Interaction> = TypedTableAlias()
let interactionFullTextSearch: TypedTableAlias<FullTextSearch> = TypedTableAlias(name: Interaction.fullTextSearchTableName)

@ -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<String> = 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

@ -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)
}

Loading…
Cancel
Save