Skip to content

Commit

Permalink
feat(Array+Extension): Use toArray to transform LazyFilterSequence
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeWeidmann committed Jan 12, 2023
1 parent 6c1788d commit 889f460
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Mail/Views/New Message/ComposeMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ struct ComposeMessageView: View {
.focused($focusedField, equals: .subject)
}

if let attachments = draft.attachments.filter { $0.contentId == nil }, !attachments.isEmpty {
if let attachments = draft.attachments.filter { $0.contentId == nil }.toArray(),
!attachments.isEmpty {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 8) {
ForEach(Array(attachments)) { attachment in
ForEach(attachments) { attachment in
AttachmentCell(attachment: attachment, isNewMessage: true) { attachmentRemoved in
removeAttachment(attachmentRemoved)
}
Expand Down
8 changes: 7 additions & 1 deletion MailCore/Utils/Array+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ public extension Array where Element: RealmCollectionValue {
list.append(objectsIn: self)
return list
}

func toRealmSet() -> MutableSet<Element> {
let set = MutableSet<Element>()
set.insert(objectsIn: self)
return set
}
}

public extension LazyFilterSequence {
func toArray() -> [Base.Element] {
return Array(self)
}
}

0 comments on commit 889f460

Please sign in to comment.