Merge pull request #96 from loki-project/files

Show Activity Indicator for Proxied File Uploads
pull/98/head
gmbnt 5 years ago committed by GitHub
commit 42a153e6bf

@ -176,7 +176,6 @@ public class ConversationMediaView: UIView {
} }
private func addUploadProgressIfNecessary(_ subview: UIView) -> Bool { private func addUploadProgressIfNecessary(_ subview: UIView) -> Bool {
guard !isProxied else { return false } // Loki: Due to the way proxying works we can't get upload progress for those attachments right now
guard isOutgoing else { return false } guard isOutgoing else { return false }
guard let attachmentStream = attachment as? TSAttachmentStream else { return false } guard let attachmentStream = attachment as? TSAttachmentStream else { return false }
guard let attachmentId = attachmentStream.uniqueId else { guard let attachmentId = attachmentStream.uniqueId else {
@ -184,12 +183,18 @@ public class ConversationMediaView: UIView {
configure(forError: .invalid) configure(forError: .invalid)
return false return false
} }
guard !attachmentStream.isUploaded else { guard !attachmentStream.isUploaded else { return false }
return false let view: UIView
if isProxied { // Loki: Due to the way proxying works we can't get upload progress for those attachments
let activityIndicatorView = UIActivityIndicatorView(style: .white)
activityIndicatorView.isHidden = false
activityIndicatorView.startAnimating()
view = activityIndicatorView
} else {
view = MediaUploadView(attachmentId: attachmentId, radius: maxMessageWidth * 0.1)
} }
let progressView = MediaUploadView(attachmentId: attachmentId, radius: maxMessageWidth * 0.1) addSubview(view)
self.addSubview(progressView) view.autoPinEdgesToSuperviewEdges()
progressView.autoPinEdgesToSuperviewEdges()
return true return true
} }

@ -101,6 +101,8 @@ public class LokiDotNetAPI : NSObject {
} }
let isProxyingRequired = (server == LokiFileServerAPI.server) // Don't proxy open group requests for now let isProxyingRequired = (server == LokiFileServerAPI.server) // Don't proxy open group requests for now
if isProxyingRequired { if isProxyingRequired {
attachment.isUploaded = false
attachment.save()
let _ = LokiFileServerProxy(for: server).performLokiFileServerNSURLRequest(request as NSURLRequest).done { responseObject in let _ = LokiFileServerProxy(for: server).performLokiFileServerNSURLRequest(request as NSURLRequest).done { responseObject in
parseResponse(responseObject) parseResponse(responseObject)
}.catch { error in }.catch { error in

Loading…
Cancel
Save