Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchAttachments build fix #765

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Build fixes for latest SDK API changes.
  • Loading branch information
mhdostal committed Jun 21, 2024
commit d3ebd309c0a656aac5312db1c775dd45a4688ef8
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ struct AttachmentsFeatureElementView: View {
func onDelete(attachmentModel: AttachmentModel) -> Void {
if let element = featureElement as? AttachmentsFormElement,
let attachment = attachmentModel.attachment as? FormAttachment {
element.deleteAttachment(attachment)
element.delete(attachment)
guard case .initialized(var models) = attachmentModelsState else { return }
models.removeAll { $0 == attachmentModel }
attachmentModelsState = .initialized(models)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ struct AttachmentImportMenu: View {
if let presetFileName = newAttachmentImportData.fileName {
fileName = presetFileName
} else {
let attachmentNumber = element.attachments.count + 1
// `element.attachments` is now marked `async throws`, so this
// needs to be modified. We can address it as part of
// Apollo #682. Temporarily, just use a random Int.
// let attachmentNumber = element.attachments.count + 1
let attachmentNumber = Int.random(in: 0...99)
Comment on lines +145 to +149
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #758, I accessed the attachments up above as apart of the first guard. Here's the commit.

I'll close that PR out but would you just want to change this to do the same?

if let fileExtension = newAttachmentImportData.fileExtension {
fileName = "Attachment \(attachmentNumber).\(fileExtension)"
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ extension AttachmentsFormElement : AttachmentsFeatureElement {
/// This property will be empty if the element has not yet been evaluated.
public var featureAttachments: [FeatureAttachment] {
get async throws {
try await fetchAttachments()
return attachments.map { $0 as FeatureAttachment }
try await attachments.map { $0 as FeatureAttachment }
}
}

Expand Down