WIP: add block button to message request view
This commit is contained in:
parent
92e6f1a356
commit
9657998d7b
|
@ -1728,6 +1728,53 @@ extension ConversationVC {
|
||||||
|
|
||||||
self.present(alertVC, animated: true, completion: nil)
|
self.present(alertVC, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func block() {
|
||||||
|
guard self.viewModel.threadData.threadVariant == .contact else { return }
|
||||||
|
|
||||||
|
let threadId: String = self.viewModel.threadData.threadId
|
||||||
|
let alertVC: UIAlertController = UIAlertController(
|
||||||
|
title: "MESSAGE_REQUESTS_BLOCK_CONFIRMATION_ACTON".localized(),
|
||||||
|
message: nil,
|
||||||
|
preferredStyle: .actionSheet
|
||||||
|
)
|
||||||
|
alertVC.addAction(UIAlertAction(title: "TXT_DELETE_TITLE".localized(), style: .destructive) { _ in
|
||||||
|
// Delete the request
|
||||||
|
Storage.shared.writeAsync(
|
||||||
|
updates: { db in
|
||||||
|
// Update the contact
|
||||||
|
_ = try Contact
|
||||||
|
.fetchOrCreate(db, id: threadId)
|
||||||
|
.with(
|
||||||
|
isApproved: false,
|
||||||
|
isBlocked: true,
|
||||||
|
|
||||||
|
// Note: We set this to true so the current user will be able to send a
|
||||||
|
// message to the person who originally sent them the message request in
|
||||||
|
// the future if they unblock them
|
||||||
|
didApproveMe: true
|
||||||
|
)
|
||||||
|
.saved(db)
|
||||||
|
|
||||||
|
_ = try SessionThread
|
||||||
|
.filter(id: threadId)
|
||||||
|
.deleteAll(db)
|
||||||
|
|
||||||
|
try MessageSender
|
||||||
|
.syncConfiguration(db, forceSyncNow: true)
|
||||||
|
.retainUntilComplete()
|
||||||
|
},
|
||||||
|
completion: { db, _ in
|
||||||
|
DispatchQueue.main.async { [weak self] in
|
||||||
|
self?.navigationController?.popViewController(animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
alertVC.addAction(UIAlertAction(title: "TXT_CANCEL_TITLE".localized(), style: .cancel, handler: nil))
|
||||||
|
|
||||||
|
self.present(alertVC, animated: true, completion: nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MediaPresentationContextProvider
|
// MARK: - MediaPresentationContextProvider
|
||||||
|
|
|
@ -279,6 +279,18 @@ final class ConversationVC: BaseVC, OWSConversationSettingsViewDelegate, Convers
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
private lazy var messageRequestBlockButton: UIButton = {
|
||||||
|
let result: UIButton = UIButton()
|
||||||
|
result.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
result.clipsToBounds = true
|
||||||
|
result.titleLabel?.font = UIFont.boldSystemFont(ofSize: 16)
|
||||||
|
result.setTitle(NSLocalizedString("TXT_BLOCK_USER_TITLE", comment: ""), for: .normal)
|
||||||
|
result.setTitleColor(Colors.destructive, for: .normal)
|
||||||
|
result.addTarget(self, action: #selector(block), for: .touchUpInside)
|
||||||
|
|
||||||
|
return result
|
||||||
|
}()
|
||||||
|
|
||||||
// MARK: - Settings
|
// MARK: - Settings
|
||||||
|
|
||||||
|
@ -339,6 +351,7 @@ final class ConversationVC: BaseVC, OWSConversationSettingsViewDelegate, Convers
|
||||||
view.addSubview(scrollButton)
|
view.addSubview(scrollButton)
|
||||||
view.addSubview(messageRequestView)
|
view.addSubview(messageRequestView)
|
||||||
|
|
||||||
|
messageRequestView.addSubview(messageRequestBlockButton)
|
||||||
messageRequestView.addSubview(messageRequestDescriptionLabel)
|
messageRequestView.addSubview(messageRequestDescriptionLabel)
|
||||||
messageRequestView.addSubview(messageRequestAcceptButton)
|
messageRequestView.addSubview(messageRequestAcceptButton)
|
||||||
messageRequestView.addSubview(messageRequestDeleteButton)
|
messageRequestView.addSubview(messageRequestDeleteButton)
|
||||||
|
@ -351,7 +364,10 @@ final class ConversationVC: BaseVC, OWSConversationSettingsViewDelegate, Convers
|
||||||
self.scrollButtonBottomConstraint?.isActive = false // Note: Need to disable this to avoid a conflict with the other bottom constraint
|
self.scrollButtonBottomConstraint?.isActive = false // Note: Need to disable this to avoid a conflict with the other bottom constraint
|
||||||
self.scrollButtonMessageRequestsBottomConstraint = scrollButton.pin(.bottom, to: .top, of: messageRequestView, withInset: -16)
|
self.scrollButtonMessageRequestsBottomConstraint = scrollButton.pin(.bottom, to: .top, of: messageRequestView, withInset: -16)
|
||||||
|
|
||||||
messageRequestDescriptionLabel.pin(.top, to: .top, of: messageRequestView, withInset: 10)
|
messageRequestBlockButton.pin(.top, to: .top, of: messageRequestView, withInset: 10)
|
||||||
|
messageRequestBlockButton.center(.horizontal, in: messageRequestView)
|
||||||
|
|
||||||
|
messageRequestDescriptionLabel.pin(.top, to: .bottom, of: messageRequestBlockButton, withInset: 20)
|
||||||
messageRequestDescriptionLabel.pin(.left, to: .left, of: messageRequestView, withInset: 40)
|
messageRequestDescriptionLabel.pin(.left, to: .left, of: messageRequestView, withInset: 40)
|
||||||
messageRequestDescriptionLabel.pin(.right, to: .right, of: messageRequestView, withInset: -40)
|
messageRequestDescriptionLabel.pin(.right, to: .right, of: messageRequestView, withInset: -40)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue