Skip to content

Commit

Permalink
Fix an issue with post list not reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed May 20, 2024
1 parent 561db0d commit 002c6ab
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions WordPress/Classes/Models/Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,12 @@ class Post: AbstractPost {
}
}

private var cachedContentPreviewForDisplay: String?

// MARK: - NSManagedObject

override class func entityName() -> String {
return "Post"
}

override func didChangeValue(forKey key: String) {
super.didChangeValue(forKey: key)

if key == "mt_excerpt" || key == "content" {
cachedContentPreviewForDisplay = nil
}
}

// MARK: - Format

@objc func postFormatText() -> String? {
Expand Down Expand Up @@ -258,15 +248,12 @@ class Post: AbstractPost {
// MARK: - BasePost

override func contentPreviewForDisplay() -> String {
if let cachedContentPreviewForDisplay {
return cachedContentPreviewForDisplay
}
if let excerpt = mt_excerpt, excerpt.count > 0 {
cachedContentPreviewForDisplay = excerpt.makePlainText()
return excerpt.makePlainText()
} else if let content = content {
cachedContentPreviewForDisplay = content.summarized()
return content.summarized()
}
return cachedContentPreviewForDisplay ?? ""
return ""
}

override func hasLocalChanges() -> Bool {
Expand Down

0 comments on commit 002c6ab

Please sign in to comment.