|
@@ -86,10 +86,13 @@ public class EditorGroup: UIViewController {
|
|
var timerCheckLink: Timer?
|
|
var timerCheckLink: Timer?
|
|
var lastPositionCursorMention = 0
|
|
var lastPositionCursorMention = 0
|
|
var timerLongPressLink: Timer?
|
|
var timerLongPressLink: Timer?
|
|
|
|
+ var timerFakeProgress: Timer?
|
|
var lastTouchPoint: CGPoint = .zero
|
|
var lastTouchPoint: CGPoint = .zero
|
|
var isLinkCopied = false
|
|
var isLinkCopied = false
|
|
var touchedSubview = UIView()
|
|
var touchedSubview = UIView()
|
|
var listViewOnSection: [UIView] = []
|
|
var listViewOnSection: [UIView] = []
|
|
|
|
+ var fakeProgMultip = 0
|
|
|
|
+ let maxFakeProgMultip = 2
|
|
|
|
|
|
public override func viewDidDisappear(_ animated: Bool) {
|
|
public override func viewDidDisappear(_ animated: Bool) {
|
|
if self.isMovingFromParent {
|
|
if self.isMovingFromParent {
|
|
@@ -598,12 +601,11 @@ public class EditorGroup: UIViewController {
|
|
viewAppBar.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(seeProfileTapped)))
|
|
viewAppBar.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(seeProfileTapped)))
|
|
}
|
|
}
|
|
|
|
|
|
- @objc func onUploadChat(notification: NSNotification) {
|
|
|
|
- let data:[AnyHashable : Any] = notification.userInfo!
|
|
|
|
|
|
+ func updateProgress(_ data: [AnyHashable: Any]){
|
|
var isImage = false
|
|
var isImage = false
|
|
- var idx = dataMessages.lastIndex(where: { $0["video_id"] as! String == data["name"] as! String })
|
|
|
|
|
|
+ var idx = dataMessages.lastIndex(where: { $0["video_id"] as! String == data["name"] as! String || $0["video_id"] as? String == data["video_id"] as? String })
|
|
if (idx == nil) {
|
|
if (idx == nil) {
|
|
- idx = dataMessages.lastIndex(where: { $0["image_id"] as! String == data["name"] as! String })
|
|
|
|
|
|
+ idx = dataMessages.lastIndex(where: { $0["image_id"] as! String == data["name"] as! String || $0["image_id"] as? String == data["image_id"] as? String })
|
|
isImage = true
|
|
isImage = true
|
|
}
|
|
}
|
|
if (idx != nil) {
|
|
if (idx != nil) {
|
|
@@ -617,6 +619,14 @@ public class EditorGroup: UIViewController {
|
|
}
|
|
}
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
let indexPath = IndexPath(row: row!, section: section!)
|
|
let indexPath = IndexPath(row: row!, section: section!)
|
|
|
|
+ if(self.fakeProgMultip < self.maxFakeProgMultip){
|
|
|
|
+ self.fakeProgMultip = self.fakeProgMultip + 1
|
|
|
|
+ }
|
|
|
|
+ let fakeProgress = Double(self.fakeProgMultip) * (100.0 / Double(self.maxFakeProgMultip))
|
|
|
|
+ let progress = max(data["progress"] as! Double, fakeProgress)
|
|
|
|
+ if(data["progress"] as! Double == 100.0){
|
|
|
|
+ self.fakeProgMultip = 0
|
|
|
|
+ }
|
|
if let cell = self.tableChatView.cellForRow(at: indexPath) {
|
|
if let cell = self.tableChatView.cellForRow(at: indexPath) {
|
|
for view in cell.contentView.subviews {
|
|
for view in cell.contentView.subviews {
|
|
if !(view is UILabel) && !(view is UIImageView) {
|
|
if !(view is UILabel) && !(view is UIImageView) {
|
|
@@ -625,17 +635,18 @@ public class EditorGroup: UIViewController {
|
|
if viewInContainer.subviews.count == 0 {
|
|
if viewInContainer.subviews.count == 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- var containerView = UIView()
|
|
|
|
|
|
+ var containerView : UIView?
|
|
if (isImage) {
|
|
if (isImage) {
|
|
containerView = viewInContainer.subviews[0]
|
|
containerView = viewInContainer.subviews[0]
|
|
- } else {
|
|
|
|
|
|
+ } else if viewInContainer.subviews.count > 1 {
|
|
containerView = viewInContainer.subviews[1]
|
|
containerView = viewInContainer.subviews[1]
|
|
}
|
|
}
|
|
- let loading = containerView.layer.sublayers![1] as! CAShapeLayer
|
|
|
|
- loading.strokeEnd = CGFloat(data["progress"] as! Double / 100)
|
|
|
|
- if (data["progress"] as! Double == 100.0) {
|
|
|
|
- self.dataMessages[idx!]["progress"] = data["progress"]
|
|
|
|
- self.tableChatView.reloadRows(at: [indexPath], with: .none)
|
|
|
|
|
|
+ if let loading = containerView?.layer.sublayers?[1] as? CAShapeLayer {
|
|
|
|
+ loading.strokeEnd = CGFloat(progress / 100)
|
|
|
|
+ if (progress == 100.0) {
|
|
|
|
+ self.dataMessages[idx!]["progress"] = progress
|
|
|
|
+ self.tableChatView.reloadRows(at: [indexPath], with: .none)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -644,11 +655,19 @@ public class EditorGroup: UIViewController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- idx = dataMessages.lastIndex(where: { $0["file_id"] as! String == data["name"] as! String })
|
|
|
|
|
|
+ idx = dataMessages.lastIndex(where: { $0["file_id"] as! String == data["name"] as! String || $0["file_id"] as? String == data["file_id"] as? String })
|
|
if (idx != nil) {
|
|
if (idx != nil) {
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
let section = 0
|
|
let section = 0
|
|
let indexPath = IndexPath(row: idx!, section: section)
|
|
let indexPath = IndexPath(row: idx!, section: section)
|
|
|
|
+ if(self.fakeProgMultip < self.maxFakeProgMultip){
|
|
|
|
+ self.fakeProgMultip = self.fakeProgMultip + 1
|
|
|
|
+ }
|
|
|
|
+ let fakeProgress = Double(self.fakeProgMultip) * (100.0 / Double(self.maxFakeProgMultip))
|
|
|
|
+ let progress = max(data["progress"] as! Double, fakeProgress)
|
|
|
|
+ if(data["progress"] as! Double == 100.0){
|
|
|
|
+ self.fakeProgMultip = 0
|
|
|
|
+ }
|
|
if let cell = self.tableChatView.cellForRow(at: indexPath) {
|
|
if let cell = self.tableChatView.cellForRow(at: indexPath) {
|
|
for view in cell.contentView.subviews {
|
|
for view in cell.contentView.subviews {
|
|
if !(view is UILabel) && !(view is UIImageView) {
|
|
if !(view is UILabel) && !(view is UIImageView) {
|
|
@@ -660,9 +679,9 @@ public class EditorGroup: UIViewController {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
let loading = viewInContainer.layer.sublayers![1] as! CAShapeLayer
|
|
let loading = viewInContainer.layer.sublayers![1] as! CAShapeLayer
|
|
- loading.strokeEnd = CGFloat(data["progress"] as! Double / 100)
|
|
|
|
- if (data["progress"] as! Double == 100.0) {
|
|
|
|
- self.dataMessages[idx!]["progress"] = data["progress"]
|
|
|
|
|
|
+ loading.strokeEnd = CGFloat(progress / 100)
|
|
|
|
+ if (progress == 100.0) {
|
|
|
|
+ self.dataMessages[idx!]["progress"] = progress
|
|
self.tableChatView.reloadRows(at: [indexPath], with: .none)
|
|
self.tableChatView.reloadRows(at: [indexPath], with: .none)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -677,6 +696,11 @@ public class EditorGroup: UIViewController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @objc func onUploadChat(notification: NSNotification) {
|
|
|
|
+ let data:[AnyHashable : Any] = notification.userInfo!
|
|
|
|
+ updateProgress(data)
|
|
|
|
+ }
|
|
|
|
+
|
|
@objc func onReceiveMessage(notification: NSNotification) {
|
|
@objc func onReceiveMessage(notification: NSNotification) {
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
let data:[AnyHashable : Any] = notification.userInfo!
|
|
let data:[AnyHashable : Any] = notification.userInfo!
|
|
@@ -1326,6 +1350,15 @@ public class EditorGroup: UIViewController {
|
|
self.tableChatView.endUpdates()
|
|
self.tableChatView.endUpdates()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
|
|
|
+ // self.timerFakeProgress = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
|
|
|
|
+ // self.updateProgress(row as [AnyHashable : Any])
|
|
|
|
+ // if self.fakeProgMultip == self.maxFakeProgMultip {
|
|
|
|
+ // self.timerFakeProgress?.invalidate()
|
|
|
|
+ // self.fakeProgMultip = 0
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
|
|
|
|
private func getCounter() {
|
|
private func getCounter() {
|
|
@@ -1485,30 +1518,53 @@ public class EditorGroup: UIViewController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
DispatchQueue.main.async { [self] in
|
|
DispatchQueue.main.async { [self] in
|
|
- let section = self.dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
|
|
|
|
- let row = self.dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
|
|
|
|
|
|
+ let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
|
|
|
|
+ let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
|
|
if row != nil && section != nil{
|
|
if row != nil && section != nil{
|
|
tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .automatic)
|
|
tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .automatic)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else if dataMessages[index]["video_id"] as? String != nil && !((dataMessages[index]["video_id"] as? String)!.isEmpty){
|
|
|
|
- let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
|
|
|
|
- let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
|
|
|
|
- if row != nil && section != nil{
|
|
|
|
- let indexPath = IndexPath(row: row!, section: section!)
|
|
|
|
- if let cell = tableChatView.cellForRow(at: indexPath) {
|
|
|
|
- for view in cell.contentView.subviews {
|
|
|
|
- if view is UIImageView {
|
|
|
|
- let objectTap = ObjectGesture()
|
|
|
|
- objectTap.video_id = dataMessages[index]["video_id"] as! String
|
|
|
|
- objectTap.imageView = view as! UIImageView
|
|
|
|
- objectTap.indexPath = indexPath
|
|
|
|
- contentMessageTapped(objectTap)
|
|
|
|
- break
|
|
|
|
|
|
+ } else if dataMessages[index]["video_id"] as? String != nil && !((dataMessages[index]["video_id"] as? String)!.isEmpty){
|
|
|
|
+ Download().startHTTP(forKey: dataMessages[index]["video_id"] as! String) { (name, progress) in
|
|
|
|
+ guard progress == 100 else {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
|
|
|
|
+ let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
|
|
|
|
+ let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
|
|
|
|
+ if let dirPath = paths.first {
|
|
|
|
+ let videoURL = URL(fileURLWithPath: dirPath).appendingPathComponent(self.dataMessages[index]["video_id"] as! String)
|
|
|
|
+ let save = UserDefaults.standard.bool(forKey: "saveToGallery")
|
|
|
|
+ if save {
|
|
|
|
+ PHPhotoLibrary.shared().performChanges({
|
|
|
|
+ PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: videoURL)
|
|
|
|
+ }) { saved, error in
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ DispatchQueue.main.async { [self] in
|
|
|
|
+ let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
|
|
|
|
+ let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
|
|
|
|
+ if row != nil && section != nil{
|
|
|
|
+ tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .automatic)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if dataMessages[index]["file_id"] as? String != nil && !((dataMessages[index]["file_id"] as? String)!.isEmpty) {
|
|
|
|
+ Download().startHTTP(forKey: dataMessages[index]["file_id"] as! String) { (name, progress) in
|
|
|
|
+ guard progress == 100 else {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ DispatchQueue.main.async { [self] in
|
|
|
|
+ let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
|
|
|
|
+ let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
|
|
|
|
+ if row != nil && section != nil{
|
|
|
|
+ tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .automatic)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|