Skip to content

Commit 20348f6

Browse files
committed
WIP - Move more models, build still broken
1 parent fe3ce87 commit 20348f6

File tree

10 files changed

+124
-45
lines changed

10 files changed

+124
-45
lines changed

WordPress/Classes/Models/Notifications/Notification.swift

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import Foundation
2+
import CocoaLumberjackSwift
23
import CoreData
34
import WordPressKit
45
import FormattableContentKit
56

67
// MARK: - Notification Entity
78
//
89
@objc(Notification)
9-
class Notification: NSManagedObject {
10+
public class Notification: NSManagedObject {
1011
/// Notification Primary Key!
1112
///
1213
@NSManaged var notificationId: String
@@ -33,7 +34,7 @@ class Notification: NSManagedObject {
3334

3435
/// Notification Type
3536
///
36-
@NSManaged var type: String?
37+
@NSManaged public var type: String?
3738

3839
/// Associated Resource's URL
3940
///
@@ -87,7 +88,7 @@ class Notification: NSManagedObject {
8788
///
8889
fileprivate static let cachedAttributes = Set(arrayLiteral: "body", "header", "subject", "timestamp")
8990

90-
override func awakeFromFetch() {
91+
public override func awakeFromFetch() {
9192
super.awakeFromFetch()
9293

9394
if cachedAttributesObserver == nil {
@@ -351,8 +352,10 @@ extension Notification {
351352
return nil
352353
}
353354

354-
cachedSubjectContentGroup = SubjectContentGroup.createGroup(from: subject, parent: self)
355-
return cachedSubjectContentGroup
355+
// FIXME:
356+
// cachedSubjectContentGroup = SubjectContentGroup.createGroup(from: subject, parent: self)
357+
// return cachedSubjectContentGroup
358+
return nil
356359
}
357360

358361
var headerContentGroup: FormattableContentGroup? {
@@ -364,8 +367,10 @@ extension Notification {
364367
return nil
365368
}
366369

367-
cachedHeaderContentGroup = HeaderContentGroup.createGroup(from: header, parent: self)
368-
return cachedHeaderContentGroup
370+
// FIXME:
371+
// cachedHeaderContentGroup = HeaderContentGroup.createGroup(from: header, parent: self)
372+
// return cachedHeaderContentGroup
373+
return nil
369374
}
370375

371376
var bodyContentGroups: [FormattableContentGroup] {
@@ -511,7 +516,7 @@ extension Notification {
511516
// MARK: - Notifiable
512517

513518
extension Notification: Notifiable {
514-
var notificationIdentifier: String {
519+
public var notificationIdentifier: String {
515520
return notificationId
516521
}
517522
}

WordPress/Classes/Services/NotificationActionsService.swift

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import CocoaLumberjackSwift
12
import Foundation
23
import FormattableContentKit
34

WordPress/Classes/Services/NotificationSyncMediator.swift

-12
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@ import WordPressShared
1919
//
2020
let NotificationSyncMediatorDidUpdateNotifications = "NotificationSyncMediatorDidUpdateNotifications"
2121

22-
protocol NotificationSyncMediatorProtocol {
23-
func updateLastSeen(_ timestamp: String, completion: ((Error?) -> Void)?)
24-
func toggleLikeForPostNotification(isLike: Bool,
25-
postID: UInt,
26-
siteID: UInt,
27-
completion: @escaping (Result<Bool, Swift.Error>) -> Void)
28-
func toggleLikeForCommentNotification(isLike: Bool,
29-
commentID: UInt,
30-
siteID: UInt,
31-
completion: @escaping (Result<Bool, Swift.Error>) -> Void)
32-
}
33-
3422
// MARK: - NotificationSyncMediator
3523
//
3624
final class NotificationSyncMediator: NotificationSyncMediatorProtocol {

WordPress/Classes/ViewRelated/Notifications/FormattableContent/Groups/BodyContentGroup.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import FormattableContentKit
22

3-
class BodyContentGroup: FormattableContentGroup {
3+
public class BodyContentGroup: FormattableContentGroup {
44
class func create(from body: [[String: AnyObject]], parent: Notification) -> [FormattableContentGroup] {
55
let blocks = NotificationContentFactory.content(from: body, actionsParser: NotificationActionParser(), parent: parent)
66

WordPress/Classes/ViewRelated/Notifications/FormattableContent/Groups/FooterContentGroup.swift

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import FormattableContentKit
32

43
class FooterContentGroup: FormattableContentGroup {
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import FormattableContentKit
22

3-
extension HeaderContentGroup {
4-
class func createGroup(from header: [[String: AnyObject]], parent: Notification) -> FormattableContentGroup {
5-
let blocks = NotificationContentFactory.content(from: header, actionsParser: NotificationActionParser(), parent: parent)
6-
return FormattableContentGroup(blocks: blocks, kind: .header)
7-
}
8-
}
3+
// FIXME: Not sure why the compiler cannot find HeaderContentGroup
4+
//extension HeaderContentGroup {
5+
// class func createGroup(from header: [[String: AnyObject]], parent: Notification) -> FormattableContentGroup {
6+
// let blocks = NotificationContentFactory.content(from: header, actionsParser: NotificationActionParser(), parent: parent)
7+
// return FormattableContentGroup(blocks: blocks, kind: .header)
8+
// }
9+
//}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import FormattableContentKit
22

3-
extension SubjectContentGroup {
4-
5-
class func createGroup(from subject: [[String: AnyObject]], parent: Notification) -> FormattableContentGroup {
6-
let blocks = NotificationContentFactory.content(from: subject, actionsParser: NotificationActionParser(), parent: parent)
7-
return FormattableContentGroup(blocks: blocks, kind: .subject)
8-
}
9-
}
3+
// FIXME: Not sure why the compiler cannot find SubjectContentGroup
4+
//extension SubjectContentGroup {
5+
//
6+
// class func createGroup(from subject: [[String: AnyObject]], parent: Notification) -> FormattableContentGroup {
7+
// let blocks = NotificationContentFactory.content(from: subject, actionsParser: NotificationActionParser(), parent: parent)
8+
// return FormattableContentGroup(blocks: blocks, kind: .subject)
9+
// }
10+
//}

WordPress/Classes/ViewRelated/Notifications/Style/WPStyleGuide+Notifications.swift

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import Foundation
2-
3-
import Gridicons
42
import WordPressShared
53
import WordPressUI
64

WordPress/WordPress.xcodeproj/project.pbxproj

+77
Original file line numberDiff line numberDiff line change
@@ -3153,17 +3153,40 @@
31533153
"Models/Gutenberg/BlockEditorSettings+CoreDataClass.swift",
31543154
"Models/Gutenberg/BlockEditorSettings+CoreDataProperties.swift",
31553155
"Models/Gutenberg/BlockEditorSettings+GutenbergEditorSettings.swift",
3156+
Models/Notifications/Actions/ApproveComment.swift,
3157+
Models/Notifications/Actions/EditComment.swift,
3158+
Models/Notifications/Actions/Follow.swift,
3159+
Models/Notifications/Actions/LikeComment.swift,
3160+
Models/Notifications/Actions/LikePost.swift,
3161+
Models/Notifications/Actions/MarkAsSpam.swift,
3162+
Models/Notifications/Actions/NotificationAction.swift,
3163+
Models/Notifications/Actions/NotificationActionParser.swift,
3164+
Models/Notifications/Actions/ReplyToComment.swift,
3165+
Models/Notifications/Actions/TrashComment.swift,
31563166
"Models/Notifications/Likes/LikeUser+CoreDataClass.swift",
31573167
"Models/Notifications/Likes/LikeUser+CoreDataProperties.swift",
31583168
"Models/Notifications/Likes/LikeUserPreferredBlog+CoreDataClass.swift",
31593169
"Models/Notifications/Likes/LikeUserPreferredBlog+CoreDataProperties.swift",
3170+
Models/Notifications/Notification.swift,
3171+
Models/Notifications/Types/CommentNotification.swift,
3172+
Models/Notifications/Types/LikeableNotification.swift,
3173+
Models/Notifications/Types/NewPostNotification.swift,
3174+
Models/SiteInfo.swift,
3175+
Services/AccountService.m,
3176+
Services/BlogService.m,
3177+
Services/CommentService.m,
3178+
Services/NotificationActionsService.swift,
31603179
"ViewRelated/Me/All Domains/Coordinators/AllDomainsAddDomainCoordinator.swift",
31613180
"ViewRelated/Me/All Domains/View Models/AllDomainsListViewModel.swift",
31623181
"ViewRelated/Me/All Domains/View Models/AllDomainsListViewModel+Strings.swift",
31633182
"ViewRelated/Me/All Domains/Views/AllDomainsListActivityIndicatorTableViewCell.swift",
31643183
"ViewRelated/Me/All Domains/Views/AllDomainsListEmptyView.swift",
31653184
"ViewRelated/Me/All Domains/Views/AllDomainsListTableViewCell.swift",
31663185
"ViewRelated/Me/All Domains/Views/AllDomainsListViewController.swift",
3186+
ViewRelated/Notifications/FormattableContent/Groups/BodyContentGroup.swift,
3187+
ViewRelated/Notifications/FormattableContent/Groups/FooterContentGroup.swift,
3188+
ViewRelated/Notifications/FormattableContent/Groups/HeaderContentGroup.swift,
3189+
ViewRelated/Notifications/FormattableContent/Groups/SubjectContentGroup.swift,
31673190
);
31683191
target = 1D6058900D05DD3D006BFB54 /* WordPress */;
31693192
};
@@ -3244,13 +3267,36 @@
32443267
"Models/Gutenberg/BlockEditorSettings+CoreDataClass.swift",
32453268
"Models/Gutenberg/BlockEditorSettings+CoreDataProperties.swift",
32463269
"Models/Gutenberg/BlockEditorSettings+GutenbergEditorSettings.swift",
3270+
Models/Notifications/Actions/ApproveComment.swift,
3271+
Models/Notifications/Actions/EditComment.swift,
3272+
Models/Notifications/Actions/Follow.swift,
3273+
Models/Notifications/Actions/LikeComment.swift,
3274+
Models/Notifications/Actions/LikePost.swift,
3275+
Models/Notifications/Actions/MarkAsSpam.swift,
3276+
Models/Notifications/Actions/NotificationAction.swift,
3277+
Models/Notifications/Actions/NotificationActionParser.swift,
3278+
Models/Notifications/Actions/ReplyToComment.swift,
3279+
Models/Notifications/Actions/TrashComment.swift,
32473280
"Models/Notifications/Likes/LikeUser+CoreDataClass.swift",
32483281
"Models/Notifications/Likes/LikeUser+CoreDataProperties.swift",
32493282
"Models/Notifications/Likes/LikeUserPreferredBlog+CoreDataClass.swift",
32503283
"Models/Notifications/Likes/LikeUserPreferredBlog+CoreDataProperties.swift",
3284+
Models/Notifications/Notification.swift,
3285+
Models/Notifications/Types/CommentNotification.swift,
3286+
Models/Notifications/Types/LikeableNotification.swift,
3287+
Models/Notifications/Types/NewPostNotification.swift,
3288+
Models/SiteInfo.swift,
3289+
Services/AccountService.m,
3290+
Services/BlogService.m,
3291+
Services/CommentService.m,
3292+
Services/NotificationActionsService.swift,
32513293
"Utility/App Configuration/AppConfiguration.swift",
32523294
"Utility/App Configuration/AppConstants.swift",
32533295
"Utility/App Configuration/AppDependency.swift",
3296+
ViewRelated/Notifications/FormattableContent/Groups/BodyContentGroup.swift,
3297+
ViewRelated/Notifications/FormattableContent/Groups/FooterContentGroup.swift,
3298+
ViewRelated/Notifications/FormattableContent/Groups/HeaderContentGroup.swift,
3299+
ViewRelated/Notifications/FormattableContent/Groups/SubjectContentGroup.swift,
32543300
);
32553301
target = FABB1F8F2602FC2C00C8785C /* Jetpack */;
32563302
};
@@ -3346,10 +3392,41 @@
33463392
"Models/Gutenberg/BlockEditorSettings+CoreDataClass.swift",
33473393
"Models/Gutenberg/BlockEditorSettings+CoreDataProperties.swift",
33483394
"Models/Gutenberg/BlockEditorSettings+GutenbergEditorSettings.swift",
3395+
Models/Notifications/Actions/ApproveComment.swift,
3396+
Models/Notifications/Actions/EditComment.swift,
3397+
Models/Notifications/Actions/Follow.swift,
3398+
Models/Notifications/Actions/LikeComment.swift,
3399+
Models/Notifications/Actions/LikePost.swift,
3400+
Models/Notifications/Actions/MarkAsSpam.swift,
3401+
Models/Notifications/Actions/NotificationAction.swift,
3402+
Models/Notifications/Actions/NotificationActionParser.swift,
3403+
Models/Notifications/Actions/ReplyToComment.swift,
3404+
Models/Notifications/Actions/TrashComment.swift,
33493405
"Models/Notifications/Likes/LikeUser+CoreDataClass.swift",
33503406
"Models/Notifications/Likes/LikeUser+CoreDataProperties.swift",
33513407
"Models/Notifications/Likes/LikeUserPreferredBlog+CoreDataClass.swift",
33523408
"Models/Notifications/Likes/LikeUserPreferredBlog+CoreDataProperties.swift",
3409+
Models/Notifications/Notification.swift,
3410+
Models/Notifications/Types/CommentNotification.swift,
3411+
Models/Notifications/Types/LikeableNotification.swift,
3412+
Models/Notifications/Types/NewPostNotification.swift,
3413+
Models/SiteInfo.swift,
3414+
Services/AccountService.h,
3415+
Services/AccountService.m,
3416+
Services/BlogService.h,
3417+
Services/BlogService.m,
3418+
Services/CommentService.h,
3419+
Services/CommentService.m,
3420+
Services/NotificationActionsService.swift,
3421+
ViewRelated/Notifications/FormattableContent/Groups/BodyContentGroup.swift,
3422+
ViewRelated/Notifications/FormattableContent/Groups/FooterContentGroup.swift,
3423+
ViewRelated/Notifications/FormattableContent/Groups/HeaderContentGroup.swift,
3424+
ViewRelated/Notifications/FormattableContent/Groups/SubjectContentGroup.swift,
3425+
);
3426+
publicHeaders = (
3427+
Services/AccountService.h,
3428+
Services/BlogService.h,
3429+
Services/CommentService.h,
33533430
);
33543431
target = 3F2AA3E22D81457F002A4E94 /* WordPressData */;
33553432
};

WordPress/WordPressData/Swift/NotificationSyncMediatorProtocol.swift

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
//
2-
// NotificationSyncMediatorProtocol.swift
3-
// WordPressData
4-
//
5-
// Created by Gio Lodi on 20/3/2025.
6-
// Copyright © 2025 WordPress. All rights reserved.
7-
//
1+
public protocol NotificationSyncMediatorProtocol {
2+
func updateLastSeen(_ timestamp: String, completion: ((Error?) -> Void)?)
3+
4+
func toggleLikeForPostNotification(
5+
isLike: Bool,
6+
postID: UInt,
7+
siteID: UInt,
8+
completion: @escaping (Result<Bool, Error>) -> Void
9+
)
10+
11+
func toggleLikeForCommentNotification(
12+
isLike: Bool,
13+
commentID: UInt,
14+
siteID: UInt,
15+
completion: @escaping (Result<Bool, Error>) -> Void
16+
)
17+
}
818

9-
import Foundation

0 commit comments

Comments
 (0)