|
@@ -861,7 +861,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
}
|
|
}
|
|
row["chat_date"] = chatDate(stringDate: row["server_date"] as! String)
|
|
row["chat_date"] = chatDate(stringDate: row["server_date"] as! String)
|
|
row["isSelected"] = false
|
|
row["isSelected"] = false
|
|
- if row["credential"] as! String == "1" {
|
|
|
|
|
|
+ if row["credential"] != nil && row["credential"] as! String == "1" {
|
|
let idMe = UserDefaults.standard.string(forKey: "me")!
|
|
let idMe = UserDefaults.standard.string(forKey: "me")!
|
|
if row["f_pin"] as! String == idMe {
|
|
if row["f_pin"] as! String == idMe {
|
|
let second = getSecondsDifferenceFromTwoDates(start: Date.init(milliseconds: Int64(row["server_date"] as! String)!), end: Date())
|
|
let second = getSecondsDifferenceFromTwoDates(start: Date.init(milliseconds: Int64(row["server_date"] as! String)!), end: Date())
|
|
@@ -1019,7 +1019,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
}
|
|
}
|
|
row["chat_date"] = chatDate(stringDate: row["server_date"] as! String)
|
|
row["chat_date"] = chatDate(stringDate: row["server_date"] as! String)
|
|
row["isSelected"] = false
|
|
row["isSelected"] = false
|
|
- if row["credential"] as! String == "1" {
|
|
|
|
|
|
+ if row["credential"] != nil && row["credential"] as! String == "1" {
|
|
let idMe = UserDefaults.standard.string(forKey: "me")!
|
|
let idMe = UserDefaults.standard.string(forKey: "me")!
|
|
if row["f_pin"] as! String == idMe {
|
|
if row["f_pin"] as! String == idMe {
|
|
let second = getSecondsDifferenceFromTwoDates(start: Date.init(milliseconds: Int64(row["server_date"] as! String)!), end: Date())
|
|
let second = getSecondsDifferenceFromTwoDates(start: Date.init(milliseconds: Int64(row["server_date"] as! String)!), end: Date())
|
|
@@ -1468,12 +1468,12 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
row["chat_date"] = "Today".localized()
|
|
row["chat_date"] = "Today".localized()
|
|
row["blog_id"] = chatData[CoreMessage_TMessageKey.BLOG_ID]
|
|
row["blog_id"] = chatData[CoreMessage_TMessageKey.BLOG_ID]
|
|
self.counter += 1
|
|
self.counter += 1
|
|
- if row["credential"] as! String == "1" {
|
|
|
|
|
|
+ if row["credential"] != nil && row["credential"] as! String == "1" {
|
|
self.listTimerCredential[row["message_id"] as! String] = 60
|
|
self.listTimerCredential[row["message_id"] as! String] = 60
|
|
}
|
|
}
|
|
self.dataMessages.append(row)
|
|
self.dataMessages.append(row)
|
|
self.tableChatView.insertRows(at: [IndexPath(row: self.dataMessages.filter({ $0["chat_date"] as! String == self.dataDates[self.dataDates.count - 1]}).count - 1, section: self.dataDates.count - 1)], with: .none)
|
|
self.tableChatView.insertRows(at: [IndexPath(row: self.dataMessages.filter({ $0["chat_date"] as! String == self.dataDates[self.dataDates.count - 1]}).count - 1, section: self.dataDates.count - 1)], with: .none)
|
|
- if row["credential"] as! String == "1" {
|
|
|
|
|
|
+ if row["credential"] != nil && row["credential"] as! String == "1" {
|
|
var timer = Timer()
|
|
var timer = Timer()
|
|
var minute = 60
|
|
var minute = 60
|
|
self.timerCredential[row["message_id"] as! String] = timer
|
|
self.timerCredential[row["message_id"] as! String] = timer
|
|
@@ -3011,15 +3011,22 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
currentIndexpath = tableView.indexPathsForVisibleRows?.last
|
|
currentIndexpath = tableView.indexPathsForVisibleRows?.last
|
|
- if currentIndexpath != nil {
|
|
|
|
|
|
+ let indexFirst = tableView.indexPathsForVisibleRows?.first
|
|
|
|
+ if indexFirst != nil {
|
|
let dataMessages = dataMessages.filter({ $0["chat_date"] as! String == dataDates[currentIndexpath!.section] })
|
|
let dataMessages = dataMessages.filter({ $0["chat_date"] as! String == dataDates[currentIndexpath!.section] })
|
|
if dataMessages.count == 0 || dataMessages.count - 1 < currentIndexpath!.row {
|
|
if dataMessages.count == 0 || dataMessages.count - 1 < currentIndexpath!.row {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if currentIndexpath!.section == dataDates.count - 1 && currentIndexpath!.row != dataMessages.count - 1 && currentIndexpath!.row != dataMessages.count - 2 && !buttonScrollToBottom.isDescendant(of: self.view) {
|
|
|
|
- addButtonScrollToBottom()
|
|
|
|
- addCounterAtButttonScrollToBottom()
|
|
|
|
- } else if currentIndexpath!.section == dataDates.count - 1 && currentIndexpath!.row == dataMessages.count - 1 {
|
|
|
|
|
|
+ let contentHeight = tableView.contentSize.height
|
|
|
|
+ let scrollViewHeight = tableView.frame.height
|
|
|
|
+ let fullContentOffset = contentHeight - scrollViewHeight
|
|
|
|
+ let contentOffsetY = tableView.contentOffset.y
|
|
|
|
+ if ((currentIndexpath!.section == dataDates.count - 1 && indexFirst!.row != dataMessages.count - 1) || indexFirst!.section != dataDates.count - 1) && fullContentOffset - contentOffsetY > 100 {
|
|
|
|
+ if !buttonScrollToBottom.isDescendant(of: self.view) {
|
|
|
|
+ addButtonScrollToBottom()
|
|
|
|
+ addCounterAtButttonScrollToBottom()
|
|
|
|
+ }
|
|
|
|
+ } else if (indexFirst!.section == dataDates.count - 1 && indexFirst!.row == dataMessages.count - 1) || fullContentOffset - contentOffsetY < 50 {
|
|
if buttonScrollToBottom.isDescendant(of: self.view) {
|
|
if buttonScrollToBottom.isDescendant(of: self.view) {
|
|
buttonScrollToBottom.removeConstraints(buttonScrollToBottom.constraints)
|
|
buttonScrollToBottom.removeConstraints(buttonScrollToBottom.constraints)
|
|
buttonScrollToBottom.removeFromSuperview()
|
|
buttonScrollToBottom.removeFromSuperview()
|
|
@@ -3243,7 +3250,10 @@ extension EditorPersonal: UITextViewDelegate {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- let slp = SwiftLinkPreview(session: URLSession.shared,
|
|
|
|
|
|
+ let urlConfig = URLSessionConfiguration.default
|
|
|
|
+ let sessionDelegate = SelfSignedURLSessionDelegate()
|
|
|
|
+ let session = URLSession(configuration: urlConfig, delegate: sessionDelegate, delegateQueue: nil)
|
|
|
|
+ let slp = SwiftLinkPreview(session: session,
|
|
workQueue: SwiftLinkPreview.defaultWorkQueue,
|
|
workQueue: SwiftLinkPreview.defaultWorkQueue,
|
|
responseQueue: DispatchQueue.main,
|
|
responseQueue: DispatchQueue.main,
|
|
cache: DisabledCache.instance)
|
|
cache: DisabledCache.instance)
|
|
@@ -5034,6 +5044,20 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
}
|
|
}
|
|
|
|
|
|
func modifyText() {
|
|
func modifyText() {
|
|
|
|
+
|
|
|
|
+ func ranges(of word: String, in string: String) -> [NSRange] {
|
|
|
|
+ var result: [NSRange] = []
|
|
|
|
+ var startIndex = string.startIndex
|
|
|
|
+
|
|
|
|
+ while let range = string[startIndex...].range(of: word) {
|
|
|
|
+ let nsRange = NSRange(range, in: string)
|
|
|
|
+ result.append(nsRange)
|
|
|
|
+ startIndex = range.upperBound
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result
|
|
|
|
+ }
|
|
|
|
+
|
|
messageText.isUserInteractionEnabled = false
|
|
messageText.isUserInteractionEnabled = false
|
|
if !textChat.isEmpty {
|
|
if !textChat.isEmpty {
|
|
if textChat.contains("■"){
|
|
if textChat.contains("■"){
|
|
@@ -5043,12 +5067,26 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
let listTextEnter = textChat.split(separator: "\n")
|
|
let listTextEnter = textChat.split(separator: "\n")
|
|
let finalAtribute = textChat.richText()
|
|
let finalAtribute = textChat.richText()
|
|
var containsLink = false
|
|
var containsLink = false
|
|
|
|
+ var listRange: [NSRange] = []
|
|
for j in 0...listTextEnter.count - 1 {
|
|
for j in 0...listTextEnter.count - 1 {
|
|
let listText = listTextEnter[j].split(separator: " ")
|
|
let listText = listTextEnter[j].split(separator: " ")
|
|
if listText.count > 0 {
|
|
if listText.count > 0 {
|
|
for i in 0...listText.count - 1 {
|
|
for i in 0...listText.count - 1 {
|
|
if listText[i].lowercased().checkStartWithLink() {
|
|
if listText[i].lowercased().checkStartWithLink() {
|
|
- let rangeTapLink = (finalAtribute.string as NSString).range(of: String(listText[i]))
|
|
|
|
|
|
+ var rangeTapLink = (finalAtribute.string as NSString).range(of: String(listText[i]))
|
|
|
|
+ func checkContainsRange() {
|
|
|
|
+ if listRange.contains(rangeTapLink) {
|
|
|
|
+ let allRanges = ranges(of: String(listText[i]), in: finalAtribute.string)
|
|
|
|
+ for allRange in allRanges {
|
|
|
|
+ if !listRange.contains(allRange) {
|
|
|
|
+ rangeTapLink = allRange
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ listRange.append(rangeTapLink)
|
|
|
|
+ }
|
|
|
|
+ checkContainsRange()
|
|
finalAtribute.addAttributes([.foregroundColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue], range: rangeTapLink)
|
|
finalAtribute.addAttributes([.foregroundColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue], range: rangeTapLink)
|
|
if !containsLink {
|
|
if !containsLink {
|
|
containsLink = true
|
|
containsLink = true
|
|
@@ -5559,7 +5597,10 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
if dataURL.isEmpty {
|
|
if dataURL.isEmpty {
|
|
- let slp = SwiftLinkPreview(session: URLSession.shared,
|
|
|
|
|
|
+ let urlConfig = URLSessionConfiguration.default
|
|
|
|
+ let sessionDelegate = SelfSignedURLSessionDelegate()
|
|
|
|
+ let session = URLSession(configuration: urlConfig, delegate: sessionDelegate, delegateQueue: nil)
|
|
|
|
+ let slp = SwiftLinkPreview(session: session,
|
|
workQueue: SwiftLinkPreview.defaultWorkQueue,
|
|
workQueue: SwiftLinkPreview.defaultWorkQueue,
|
|
responseQueue: DispatchQueue.main,
|
|
responseQueue: DispatchQueue.main,
|
|
cache: DisabledCache.instance)
|
|
cache: DisabledCache.instance)
|