Skip to content

Commit

Permalink
isLoading was never set correctly (loading took place mostly async af…
Browse files Browse the repository at this point in the history
…terwards)
  • Loading branch information
r10s committed Dec 15, 2023
1 parent f1107f8 commit 159d7dd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
12 changes: 1 addition & 11 deletions DcShare/Controller/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class ShareViewController: SLComposeServiceViewController {
var selectedChat: DcChat?
var shareAttachment: ShareAttachment?
var isAccountConfigured: Bool = true
var isLoading: Bool = false

var previewImageHeightConstraint: NSLayoutConstraint?
var previewImageWidthConstraint: NSLayoutConstraint?
Expand Down Expand Up @@ -135,7 +134,7 @@ class ShareViewController: SLComposeServiceViewController {

override func isContentValid() -> Bool {
// Do validation of contentText and/or NSExtensionContext attachments here
return isAccountConfigured && !isLoading && (!(contentText?.isEmpty ?? true) || !(self.shareAttachment?.isEmpty ?? true))
return isAccountConfigured && (!(contentText?.isEmpty ?? true) || !(self.shareAttachment?.isEmpty ?? true))
}

private func setupNavigationBar() {
Expand Down Expand Up @@ -267,13 +266,4 @@ extension ShareViewController: ShareAttachmentDelegate {
}
}
}

func onLoadingStarted() {
isLoading = true
}

func onLoadingFinished() {
isLoading = false
self.validateContent()
}
}
4 changes: 0 additions & 4 deletions DcShare/Helper/ShareAttachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ protocol ShareAttachmentDelegate: class {
func onAttachmentChanged()
func onThumbnailChanged()
func onUrlShared(url: URL)
func onLoadingStarted()
func onLoadingFinished()
}

class ShareAttachment {
Expand Down Expand Up @@ -48,13 +46,11 @@ class ShareAttachment {

private func createMessages() {
guard let items = inputItems as? [NSExtensionItem] else { return }
delegate?.onLoadingStarted()
for item in items {
if let attachments = item.attachments {
createMessageFromDataRepresentation(attachments)
}
}
delegate?.onLoadingFinished()
}

private func createMessageFromDataRepresentation(_ attachments: [NSItemProvider]) {
Expand Down

0 comments on commit 159d7dd

Please sign in to comment.