|
@@ -226,7 +226,48 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
|
|
|
|
private func setRightButtonItem() {
|
|
|
navigationItem.rightBarButtonItems = nil
|
|
|
- var menu = UIMenu()
|
|
|
+ var menu = UIMenu(title: "", children: [
|
|
|
+ UIAction(title: "Search".localized(), handler: {(_) in
|
|
|
+ self.isSearching = true
|
|
|
+ if self.reffId != nil {
|
|
|
+ self.deleteReplyView()
|
|
|
+ }
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
|
|
|
+ let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
|
|
|
+ if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
|
|
|
+ self.navigationItem.rightBarButtonItems = nil
|
|
|
+ }
|
|
|
+ self.navigationItem.rightBarButtonItem = cancelButton
|
|
|
+ if self.isContactCenter || self.fromNotification {
|
|
|
+ self.navigationItem.leftBarButtonItem = nil
|
|
|
+ }
|
|
|
+ self.changeAppBar()
|
|
|
+ self.addMultipleSelectSession()
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ UIAction(title: "Delete Conversation".localized(), handler: {(_) in
|
|
|
+ if !self.isContactCenter {
|
|
|
+ let alert = UIAlertController(title: "", message: "Are you sure to delete all message in this conversation?".localized(), preferredStyle: .alert)
|
|
|
+ alert.addAction(UIAlertAction(title: "Cancel".localized(), style: UIAlertAction.Style.default, handler: nil))
|
|
|
+ alert.addAction(UIAlertAction(title: "Delete".localized(), style: .destructive, handler: {(_) in
|
|
|
+ Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
+ _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE", _where: "(f_pin='\(self.dataPerson["f_pin"]!!)' or l_pin='\(self.dataPerson["f_pin"]!!)') and (message_scope_id='3' or message_scope_id='18') and is_call_center = 0")
|
|
|
+ _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE_SUMMARY", _where: "l_pin='\(self.dataPerson["f_pin"]!!)'")
|
|
|
+ })
|
|
|
+ NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
|
|
|
+ if self.fromNotification {
|
|
|
+ self.didTapExit()
|
|
|
+ } else {
|
|
|
+ self.navigationController?.popViewController(animated: true)
|
|
|
+ }
|
|
|
+// self.dataMessages.removeAll()
|
|
|
+// self.dataDates.removeAll()
|
|
|
+// self.tableChatView.reloadData()
|
|
|
+ }))
|
|
|
+ self.present(alert, animated: true, completion: nil)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ])
|
|
|
let exblock = User.getData(pin: self.dataPerson["f_pin"]!!)?.ex_block
|
|
|
blocking = exblock == nil ? "0" : exblock!.isEmpty ? "0" : exblock!
|
|
|
if blocking == "1" && self.dataPerson["f_pin"]!! != "-999" {
|
|
@@ -3084,7 +3125,10 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
|
|
|
if self.viewAttachment.isHidden {
|
|
|
self.viewAttachment.isHidden = false
|
|
|
}
|
|
|
- if !self.isSearching {
|
|
|
+ if self.containerAction.isHidden {
|
|
|
+ self.containerAction.isHidden = false
|
|
|
+ }
|
|
|
+ if !self.isSearching && (self.copySession || self.forwardSession || self.deleteSession){
|
|
|
self.constraintBottomTableViewWithTextfield.constant = self.constraintBottomTableViewWithTextfield.constant + 70
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
|
|
|
if (self.currentIndexpath != nil) {
|
|
@@ -3116,6 +3160,7 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
|
|
|
private func addMultipleSelectSession() {
|
|
|
viewTextfield.isHidden = true
|
|
|
viewAttachment.isHidden = true
|
|
|
+ containerAction.isHidden = true
|
|
|
constraintBottomTableViewWithTextfield.constant = constraintBottomTableViewWithTextfield.constant - 70
|
|
|
view.addSubview(containerMultpileSelectSession)
|
|
|
containerMultpileSelectSession.translatesAutoresizingMaskIntoConstraints = false
|
|
@@ -5320,7 +5365,7 @@ extension UIImage {
|
|
|
extension EditorPersonal: UISearchBarDelegate {
|
|
|
|
|
|
public func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
|
|
|
- textSearch = searchText
|
|
|
+ textSearch = searchText.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
|
countMatchesSearch = 0
|
|
|
titleSearchMatches.isHidden = true
|
|
|
tableChatView.reloadData()
|