Skip to content

Commit bee2b31

Browse files
committed
Display author for P2 posts
1 parent 6ffe710 commit bee2b31

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

WordPress/Classes/ViewRelated/Reader/ReaderPostCellViewModel.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@ final class ReaderPostCellViewModel {
2222
weak var viewController: ReaderStreamViewController?
2323

2424
let post: ReaderPost?
25-
private var followCommentsService: FollowCommentsService?
2625
private var faviconTask: Task<Void, Never>?
2726

2827
deinit {
2928
faviconTask?.cancel()
3029
}
3130

32-
init(post: ReaderPost) {
31+
init(post: ReaderPost, topic: ReaderAbstractTopic?) {
3332
self.post = post
3433

35-
self.author = post.blogNameForDisplay() ?? ""
34+
let isP2 = (topic as? ReaderSiteTopic)?.isP2Type == true
35+
36+
if isP2 {
37+
self.author = post.authorDisplayName ?? ""
38+
} else {
39+
self.author = post.blogNameForDisplay() ?? ""
40+
}
3641
self.time = post.dateForDisplay()?.toShortString() ?? ""
3742
self.title = post.titleForDisplay() ?? ""
3843
self.details = post.contentPreviewForDisplay() ?? ""
@@ -47,8 +52,10 @@ final class ReaderPostCellViewModel {
4752
self.likeCount = post.likeCount?.intValue ?? 0
4853
self.isLiked = post.isLiked()
4954

50-
if let avatarURL = post.siteIconForDisplay(ofSize: Int(ReaderPostCell.avatarSize)) {
51-
self.avatarURL = avatarURL
55+
if isP2 {
56+
self.avatarURL = post.authorAvatarURL.flatMap(URL.init)
57+
} else if let avatarURL = post.siteIconForDisplay(ofSize: Int(ReaderPostCell.avatarSize)) {
58+
self.avatarURL = avatarURL
5259
} else if let blogURL = post.blogURL.flatMap(URL.init) {
5360
if let faviconURL = FaviconService.shared.cachedFavicon(forURL: blogURL) {
5461
self.avatarURL = faviconURL

WordPress/Classes/ViewRelated/Reader/ReaderStreamViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ extension ReaderStreamViewController: WPTableViewHandlerDelegate {
15271527
}
15281528

15291529
let cell = tableConfiguration.postCell(in: tableView, for: indexPath)
1530-
let viewModel = ReaderPostCellViewModel(post: post)
1530+
let viewModel = ReaderPostCellViewModel(post: post, topic: readerTopic)
15311531
viewModel.viewController = self
15321532
cell.configure(with: viewModel, isCompact: traitCollection.horizontalSizeClass == .compact, isSeparatorHidden: !showsSeparator)
15331533
return cell

0 commit comments

Comments
 (0)