Skip to content

Commit d86320d

Browse files
committed
Add initial NotificationCommentDetailCoordinator to display the new Comment details view for a comment notification.
1 parent a678dad commit d86320d

2 files changed

Lines changed: 60 additions & 7 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import Foundation
2+
3+
// This facilitates showing the CommentDetailViewController within the context of Notifications.
4+
5+
class NotificationCommentDetailCoordinator: NSObject {
6+
7+
// MARK: - Properties
8+
9+
private let notification: Notification
10+
private var comment: Comment?
11+
private let managedObjectContext = ContextManager.shared.mainContext
12+
private(set) var viewController: CommentDetailViewController?
13+
14+
private lazy var commentService: CommentService = {
15+
return .init(managedObjectContext: managedObjectContext)
16+
}()
17+
18+
// MARK: - Init
19+
20+
init(notification: Notification) {
21+
self.notification = notification
22+
super.init()
23+
loadCommentFromCache()
24+
}
25+
26+
}
27+
28+
// MARK: - Private Extension
29+
30+
private extension NotificationCommentDetailCoordinator {
31+
32+
func loadCommentFromCache() {
33+
guard let siteID = notification.metaSiteID,
34+
let commentID = notification.metaCommentID,
35+
let blog = Blog.lookup(withID: siteID, in: managedObjectContext),
36+
let comment = commentService.findComment(withID: commentID, in: blog) else {
37+
DDLogError("Notification Comment: failed loading comment from cache.")
38+
return
39+
}
40+
41+
self.comment = comment
42+
viewController = CommentDetailViewController(comment: comment,
43+
notification: notification,
44+
managedObjectContext: managedObjectContext)
45+
}
46+
47+
}

WordPress/WordPress.xcodeproj/project.pbxproj

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,8 @@
17271727
988F073A23D0D16700AC67A6 /* WidgetUrlCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988F073323D0CE8800AC67A6 /* WidgetUrlCell.swift */; };
17281728
988F073B23D0D16800AC67A6 /* WidgetUrlCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988F073323D0CE8800AC67A6 /* WidgetUrlCell.swift */; };
17291729
988F073C23D0D16800AC67A6 /* WidgetUrlCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988F073323D0CE8800AC67A6 /* WidgetUrlCell.swift */; };
1730+
988FD74A279B75A400C7E814 /* NotificationCommentDetailCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988FD749279B75A400C7E814 /* NotificationCommentDetailCoordinator.swift */; };
1731+
988FD74B279B75A400C7E814 /* NotificationCommentDetailCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988FD749279B75A400C7E814 /* NotificationCommentDetailCoordinator.swift */; };
17301732
98906502237CC1DF00218CD2 /* WidgetUnconfiguredCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 989064FB237CC1DE00218CD2 /* WidgetUnconfiguredCell.swift */; };
17311733
98906503237CC1DF00218CD2 /* WidgetUnconfiguredCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 989064FB237CC1DE00218CD2 /* WidgetUnconfiguredCell.swift */; };
17321734
98906504237CC1DF00218CD2 /* WidgetUnconfiguredCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 989064FC237CC1DE00218CD2 /* WidgetUnconfiguredCell.xib */; };
@@ -6360,6 +6362,7 @@
63606362
988AD63726B089CE003552B4 /* WordPress 128.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 128.xcdatamodel"; sourceTree = "<group>"; };
63616363
988F073323D0CE8800AC67A6 /* WidgetUrlCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetUrlCell.swift; sourceTree = "<group>"; };
63626364
988F073423D0CE8800AC67A6 /* WidgetUrlCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WidgetUrlCell.xib; sourceTree = "<group>"; };
6365+
988FD749279B75A400C7E814 /* NotificationCommentDetailCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationCommentDetailCoordinator.swift; sourceTree = "<group>"; };
63636366
989064FB237CC1DE00218CD2 /* WidgetUnconfiguredCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WidgetUnconfiguredCell.swift; sourceTree = "<group>"; };
63646367
989064FC237CC1DE00218CD2 /* WidgetUnconfiguredCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WidgetUnconfiguredCell.xib; sourceTree = "<group>"; };
63656368
989064FD237CC1DE00218CD2 /* WidgetTwoColumnCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WidgetTwoColumnCell.swift; sourceTree = "<group>"; };
@@ -12961,9 +12964,10 @@
1296112964
B5E23BD919AD0CED000D6879 /* Tools */ = {
1296212965
isa = PBXGroup;
1296312966
children = (
12964-
B54E1DF31A0A7BBF00807537 /* NotificationMediaDownloader.swift */,
1296512967
B54075D31D3D7D5B0095C318 /* IntrinsicTableView.swift */,
1296612968
B56695AF1D411EEB007E342F /* KeyboardDismissHelper.swift */,
12969+
988FD749279B75A400C7E814 /* NotificationCommentDetailCoordinator.swift */,
12970+
B54E1DF31A0A7BBF00807537 /* NotificationMediaDownloader.swift */,
1296712971
B5C0CF3C204DA41000DB0362 /* NotificationReplyStore.swift */,
1296812972
);
1296912973
path = Tools;
@@ -13043,15 +13047,15 @@
1304313047
B5FD453E199D0F2800286FBB /* Controllers */ = {
1304413048
isa = PBXGroup;
1304513049
children = (
13046-
B5DBE4FD1D21A700002E81D3 /* NotificationsViewController.swift */,
13047-
4388FEFD20A4E0B900783948 /* NotificationsViewController+AppRatings.swift */,
13048-
B5120B371D47CC6C0059361A /* NotificationDetailsViewController.swift */,
1304913050
7E987F552108017B00CAFB88 /* NotificationContentRouter.swift */,
13050-
B522C4F71B3DA79B00E47B59 /* NotificationSettingsViewController.swift */,
13051-
B52F8CD71B43260C00D36025 /* NotificationSettingStreamsViewController.swift */,
13051+
B5120B371D47CC6C0059361A /* NotificationDetailsViewController.swift */,
1305213052
B5899ADD1B419C560075A3D6 /* NotificationSettingDetailsViewController.swift */,
13053-
9F8E38BD209C6DE200454E3C /* NotificationSiteSubscriptionViewController.swift */,
13053+
B52F8CD71B43260C00D36025 /* NotificationSettingStreamsViewController.swift */,
13054+
B522C4F71B3DA79B00E47B59 /* NotificationSettingsViewController.swift */,
1305413055
B5F9959F1B59708C00AB0B3E /* NotificationSettingsViewController.xib */,
13056+
9F8E38BD209C6DE200454E3C /* NotificationSiteSubscriptionViewController.swift */,
13057+
B5DBE4FD1D21A700002E81D3 /* NotificationsViewController.swift */,
13058+
4388FEFD20A4E0B900783948 /* NotificationsViewController+AppRatings.swift */,
1305513059
8236EB4F2024ED8C007C7CF9 /* NotificationsViewController+JetpackPrompt.swift */,
1305613060
4388FEFF20A4E19C00783948 /* NotificationsViewController+PushPrimer.swift */,
1305713061
);
@@ -18339,6 +18343,7 @@
1833918343
E61084C01B9B47BA008050C5 /* ReaderListTopic.swift in Sources */,
1834018344
E6374DC11C444D8B00F24720 /* PublicizeService.swift in Sources */,
1834118345
7E4A773C20F80598001C706D /* ActivityContentFactory.swift in Sources */,
18346+
988FD74A279B75A400C7E814 /* NotificationCommentDetailCoordinator.swift in Sources */,
1834218347
C81CCD83243BF7A600A83E27 /* TenorDataLoader.swift in Sources */,
1834318348
98797DBC222F434500128C21 /* OverviewCell.swift in Sources */,
1834418349
1749965F2271BF08007021BD /* WordPressAppDelegate.swift in Sources */,
@@ -20845,6 +20850,7 @@
2084520850
FABB26092602FC2C00C8785C /* PostListFooterView.m in Sources */,
2084620851
FABB260A2602FC2C00C8785C /* ThemeBrowserSearchHeaderView.swift in Sources */,
2084720852
FABB260B2602FC2C00C8785C /* MenuItemInsertionView.m in Sources */,
20853+
988FD74B279B75A400C7E814 /* NotificationCommentDetailCoordinator.swift in Sources */,
2084820854
FABB260C2602FC2C00C8785C /* AllTimeStatsRecordValue+CoreDataClass.swift in Sources */,
2084920855
FABB260D2602FC2C00C8785C /* GutenbergMediaEditorImage.swift in Sources */,
2085020856
FABB260E2602FC2C00C8785C /* NoteBlockHeaderTableViewCell.swift in Sources */,

0 commit comments

Comments
 (0)