Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
miyashi committed Jul 22, 2022
1 parent a3a4bfa commit ce2183b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CopyHistory/CopyHistory/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ struct Row: View, Equatable {
Group {
if let content = item.content, let image = NSImage(data: content) {
Image(nsImage: image).resizable().scaledToFit().frame(maxHeight: 300)
} else if isShowingRTF, item.contentTypeString?.contains("rtf") == true, let attributedString = item.attributeString {
} else if isShowingRTF, let attributedString = item.attributeString {
Text(AttributedString(attributedString))

} else if isShowingHTML, item.contentTypeString?.contains("html") == true, let attributedString = item.htmlString {
} else if isShowingHTML, let attributedString = item.htmlString {
Text(AttributedString(attributedString))
} else if let url = item.fileURL {
// TODO: why images disappear after first
Expand Down
4 changes: 2 additions & 2 deletions CopyHistory/CopyHistory/PasteboardService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ extension CopiedItem {
if let att = rtfStringCached {
return att
}
guard let content = content else { return nil }
guard contentTypeString?.contains("rtf") == true, let content = content else { return nil }

let attributeString = (try? NSAttributedString(data: content, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.rtf], documentAttributes: nil))
rtfStringCached = attributeString
Expand All @@ -201,7 +201,7 @@ extension CopiedItem {
if let att = htmlStringCached {
return att
}
guard let content = content else { return nil }
guard contentTypeString?.contains("html") == true, let content = content else { return nil }

let attributeString = (try? NSAttributedString(data: content, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil))
htmlStringCached = attributeString
Expand Down

0 comments on commit ce2183b

Please sign in to comment.