Skip to content

Commit 959c2d7

Browse files
committed
Update ReaderCrossPostCell
1 parent f4da7f9 commit 959c2d7

27 files changed

+291
-529
lines changed

WordPress/Classes/Models/ReaderPost+Searchable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extension ReaderPost: SearchableItemConvertable {
3434

3535
var searchDescription: String? {
3636
guard let readerPostPreview = contentPreviewForDisplay(), !readerPostPreview.isEmpty else {
37-
return siteURLForDisplay() ?? contentForDisplay()
37+
return blogURL ?? contentForDisplay()
3838
}
3939
return readerPostPreview
4040
}

WordPress/Classes/Models/ReaderPost.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#import <Foundation/Foundation.h>
22
#import <CoreData/CoreData.h>
33
#import "BasePost.h"
4-
#import "ReaderPostContentProvider.h"
4+
5+
typedef NS_ENUM(NSUInteger, SourceAttributionStyle) {
6+
SourceAttributionStyleNone,
7+
SourceAttributionStylePost,
8+
SourceAttributionStyleSite,
9+
};
510

611
@class ReaderAbstractTopic;
712
@class ReaderCrossPostMeta;
@@ -13,7 +18,7 @@
1318
extern NSString * const ReaderPostStoredCommentIDKey;
1419
extern NSString * const ReaderPostStoredCommentTextKey;
1520

16-
@interface ReaderPost : BasePost <ReaderPostContentProvider>
21+
@interface ReaderPost : BasePost
1722

1823
@property (nonatomic, strong) NSString *authorDisplayName;
1924
@property (nonatomic, strong) NSString *authorEmail;
@@ -78,10 +83,14 @@ extern NSString * const ReaderPostStoredCommentTextKey;
7883
+ (instancetype)createOrReplaceFromRemotePost:(RemoteReaderPost *)remotePost forTopic:(ReaderAbstractTopic *)topic context:(NSManagedObjectContext *) managedObjectContext;
7984

8085
- (BOOL)isCrossPost;
81-
- (BOOL)isPrivate;
8286
- (BOOL)isP2Type;
8387
- (NSString *)authorString;
8488
- (BOOL)contentIncludesFeaturedImage;
89+
- (NSURL *)siteIconForDisplayOfSize:(NSInteger)size;
90+
- (SourceAttributionStyle)sourceAttributionStyle;
91+
- (NSString *)sourceAuthorNameForDisplay;
92+
- (NSURL *)sourceAvatarURLForDisplay;
93+
- (NSString *)sourceBlogNameForDisplay;
8594
- (BOOL)isSourceAttributionWPCom;
8695
- (NSDictionary *)railcarDictionary;
8796

WordPress/Classes/Models/ReaderPost.m

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,6 @@ - (BOOL)isCrossPost
237237
return self.crossPostMeta != nil;
238238
}
239239

240-
- (BOOL)isAtomic
241-
{
242-
return self.isBlogAtomic;
243-
}
244-
245-
- (BOOL)isPrivate
246-
{
247-
return self.isBlogPrivate;
248-
}
249-
250240
- (BOOL)isP2Type
251241
{
252242
NSInteger orgID = [self.organizationID intValue];
@@ -393,14 +383,6 @@ - (NSString *)sourceAuthorNameForDisplay
393383
return self.sourceAttribution.authorName;
394384
}
395385

396-
- (NSURL *)sourceAuthorURLForDisplay
397-
{
398-
if (!self.sourceAttribution) {
399-
return nil;
400-
}
401-
return [NSURL URLWithString:self.sourceAttribution.authorURL];
402-
}
403-
404386
- (NSURL *)sourceAvatarURLForDisplay
405387
{
406388
if (!self.sourceAttribution) {
@@ -414,14 +396,6 @@ - (NSString *)sourceBlogNameForDisplay
414396
return self.sourceAttribution.blogName;
415397
}
416398

417-
- (NSURL *)sourceBlogURLForDisplay
418-
{
419-
if (!self.sourceAttribution) {
420-
return nil;
421-
}
422-
return [NSURL URLWithString:self.sourceAttribution.blogURL];
423-
}
424-
425399
- (BOOL)isSourceAttributionWPCom
426400
{
427401
return (self.sourceAttribution.blogID) ? YES : NO;
@@ -432,26 +406,6 @@ - (NSURL *)avatarURLForDisplay
432406
return [NSURL URLWithString:self.authorAvatarURL];
433407
}
434408

435-
- (NSString *)siteURLForDisplay
436-
{
437-
return self.blogURL;
438-
}
439-
440-
- (NSString *)siteHostNameForDisplay
441-
{
442-
return self.blogURL.hostname;
443-
}
444-
445-
- (NSString *)crossPostOriginSiteURLForDisplay
446-
{
447-
return self.crossPostMeta.siteURL;
448-
}
449-
450-
- (BOOL)isCommentCrossPost
451-
{
452-
return self.crossPostMeta.commentURL.length > 0;
453-
}
454-
455409
- (NSDictionary *)railcarDictionary
456410
{
457411
if (!self.railcar) {
@@ -467,7 +421,7 @@ - (NSDictionary *)railcarDictionary
467421
return nil;
468422
}
469423

470-
- (void) didSave {
424+
- (void)didSave {
471425
[super didSave];
472426

473427
// A ReaderCard can have either a post, or a list of topics, but not both.

WordPress/Classes/Models/ReaderPostContentProvider.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

WordPress/Classes/Networking/MediaHost+ReaderPostContentProvider.swift renamed to WordPress/Classes/Networking/MediaHost+ReaderPost.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import Foundation
44
/// initialize it from a given `Blog`.
55
///
66
extension MediaHost {
7-
enum ReaderPostContentProviderError: Swift.Error {
7+
enum ReaderPostError: Swift.Error {
88
case baseInitializerError(error: Error)
99
}
1010

11-
init(with readerPostContentProvider: ReaderPostContentProvider, failure: (ReaderPostContentProviderError) -> ()) {
12-
let isAccessibleThroughWPCom = readerPostContentProvider.isWPCom() || readerPostContentProvider.isJetpack()
11+
init(with post: ReaderPost, failure: (ReaderPostError) -> ()) {
12+
let isAccessibleThroughWPCom = post.isWPCom || post.isJetpack
1313

1414
// This is the only way in which we can obtain the username and authToken here.
1515
// It'd be nice if all data was associated with an account instead, for transparency
@@ -22,14 +22,13 @@ extension MediaHost {
2222

2323
self.init(
2424
isAccessibleThroughWPCom: isAccessibleThroughWPCom,
25-
isPrivate: readerPostContentProvider.isPrivate(),
26-
isAtomic: readerPostContentProvider.isAtomic(),
27-
siteID: readerPostContentProvider.siteID()?.intValue,
25+
isPrivate: post.isBlogPrivate,
26+
isAtomic: post.isBlogAtomic,
27+
siteID: post.siteID?.intValue,
2828
username: username,
2929
authToken: authToken,
3030
failure: { error in
31-
// We just associate a ReaderPostContentProvider with the underlying error for simpler debugging.
32-
failure(ReaderPostContentProviderError.baseInitializerError(error: error))
31+
failure(ReaderPostError.baseInitializerError(error: error))
3332
}
3433
)
3534
}

WordPress/Classes/Services/CommentService.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ - (void)replyToPost:(ReaderPost *)post
684684
{
685685
// Create and optimistically save a comment, based on the current wpcom acct
686686
// post and content provided.
687-
BOOL isPrivateSite = post.isPrivate;
687+
BOOL isPrivateSite = post.isBlogPrivate;
688688
[self createHierarchicalCommentWithContent:content withParent:nil postObjectID:post.objectID siteID:post.siteID completion:^(NSManagedObjectID *commentID) {
689689
if (!commentID) {
690690
NSError *error = [NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:@{NSDebugDescriptionErrorKey: @"Failed to create a comment for a post"}];
@@ -737,7 +737,7 @@ - (void)replyToHierarchicalCommentWithID:(NSNumber *)commentID
737737
{
738738
// Create and optimistically save a comment, based on the current wpcom acct
739739
// post and content provided.
740-
BOOL isPrivateSite = post.isPrivate;
740+
BOOL isPrivateSite = post.isBlogPrivate;
741741
[self createHierarchicalCommentWithContent:content withParent:nil postObjectID:post.objectID siteID:post.siteID completion:^(NSManagedObjectID *commentObjectID) {
742742
if (!commentObjectID) {
743743
NSError *error = [NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:@{NSDebugDescriptionErrorKey: @"Failed to create a comment for a post"}];
@@ -1204,7 +1204,7 @@ - (BOOL)mergeHierarchicalComments:(NSArray *)comments forPage:(NSUInteger)page f
12041204

12051205
comment.depth = ancestors.count;
12061206
comment.post = post;
1207-
comment.content = [self sanitizeCommentContent:comment.content isPrivateSite:post.isPrivate];
1207+
comment.content = [self sanitizeCommentContent:comment.content isPrivateSite:post.isBlogPrivate];
12081208
[commentsToKeep addObject:comment];
12091209
}
12101210

WordPress/Classes/System/WordPress-Bridging-Header.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#import "ReaderCommentsViewController.h"
5151
#import "ReaderGapMarker.h"
5252
#import "ReaderPost.h"
53-
#import "ReaderPostContentProvider.h"
5453
#import "ReaderPostService.h"
5554
#import "ReaderSiteService.h"
5655
#import "ReaderSiteService_Internal.h"

WordPress/Classes/Utility/Media/ImageView.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ final class ImageView: UIView {
1919
var isErrorViewEnabled = true
2020
var loadingStyle = LoadingStyle.background
2121

22-
/// The background color to use when the image is loaded.
23-
var successBackgroundColor = UIColor.clear
24-
2522
override init(frame: CGRect) {
2623
super.init(frame: frame)
2724

@@ -72,7 +69,7 @@ final class ImageView: UIView {
7269
case .success(let image):
7370
imageView.configure(image: image)
7471
imageView.isHidden = false
75-
backgroundColor = successBackgroundColor
72+
backgroundColor = .clear
7673
case .failure:
7774
if isErrorViewEnabled {
7875
makeErrorView().isHidden = false

WordPress/Classes/ViewRelated/Comments/Views/Detail/ContentRenderer/RichCommentContentRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private extension RichCommentContentRenderer {
7575
// We'll log the error, so we know it's there, but we won't halt execution.
7676
WordPressAppDelegate.crashLogging?.logError(error)
7777
})
78-
} else if let post = comment.post as? ReaderPost, post.isPrivate() {
78+
} else if let post = comment.post as? ReaderPost, post.isBlogPrivate {
7979
return MediaHost(with: post, failure: { error in
8080
// We'll log the error, so we know it's there, but we won't halt execution.
8181
WordPressAppDelegate.crashLogging?.logError(error)

WordPress/Classes/ViewRelated/Reader/Cards/ReaderBlockedSiteCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ open class ReaderBlockedSiteCell: UITableViewCell {
1212

1313
fileprivate func applyStyles() {
1414
contentView.backgroundColor = .systemGroupedBackground
15-
borderedContentView.layer.borderColor = WPStyleGuide.readerCardCellBorderColor().cgColor
15+
borderedContentView.layer.borderColor = UIColor.separator.cgColor
1616
borderedContentView.layer.borderWidth = .hairlineBorderWidth
1717
label.font = WPStyleGuide.subtitleFont()
1818
label.textColor = .secondaryLabel

0 commit comments

Comments
 (0)