Skip to content

Commit

Permalink
refactor: Clean code with Constants
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinperignon committed May 11, 2023
1 parent 670828f commit cd7d566
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Mail/Views/Thread/WebViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import WebKit
class WebViewModel: NSObject {
let webView: WKWebView

private let viewportContent = "width=device-width, initial-scale=1.0"
private let style: String = MessageWebViewUtils.generateCSS(for: .message)

override init() {
Expand Down Expand Up @@ -92,9 +91,9 @@ class WebViewModel: NSObject {
private func updateHeadContent(of document: Document) throws {
let head = document.head()
if let viewport = try head?.select("meta[name=\"viewport\"]"), !viewport.isEmpty() {
try viewport.attr("content", viewportContent)
try viewport.attr("content", Constants.viewportContent)
} else {
try head?.append("<meta name=\"viewport\" content=\"\(viewportContent)\">")
try head?.append("<meta name=\"viewport\" content=\"\(Constants.viewportContent)\">")
}
try head?.append(style)
}
Expand Down
1 change: 1 addition & 0 deletions MailCore/Utils/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public enum Constants {
try! NSRegularExpression(pattern: ">\\s*<|>?\\s+<?")
}()

public static let viewportContent = "width=device-width, initial-scale=1.0"
public static let divWrapperId = "kmail-message-content"
public static let styleCSS = {
guard let style = Bundle.main.loadCSS(filename: "style") else { return "" }
Expand Down

0 comments on commit cd7d566

Please sign in to comment.