Skip to content

Commit b16d901

Browse files
authored
Merge pull request #390 from woocommerce/issue/19-notifications-storage
Update Storage to include Notifications
2 parents 0fae7e1 + 64f776d commit b16d901

File tree

7 files changed

+78
-6
lines changed

7 files changed

+78
-6
lines changed

Storage/Storage.xcodeproj/project.pbxproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
74938ECB216FA9B200540BA1 /* OrderStats+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74938EC7216FA9B200540BA1 /* OrderStats+CoreDataProperties.swift */; };
3232
74B7D6AD20F90CBB002667AC /* OrderNote+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B7D6AB20F90CBB002667AC /* OrderNote+CoreDataClass.swift */; };
3333
74B7D6AE20F90CBB002667AC /* OrderNote+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B7D6AC20F90CBB002667AC /* OrderNote+CoreDataProperties.swift */; };
34+
74F009C02183B99B002B4566 /* Note+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F009BE2183B99B002B4566 /* Note+CoreDataClass.swift */; };
35+
74F009C12183B99B002B4566 /* Note+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F009BF2183B99B002B4566 /* Note+CoreDataProperties.swift */; };
3436
B505255420EE6914008090F5 /* StorageType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505255320EE6914008090F5 /* StorageType+Extensions.swift */; };
3537
B505F6DA20BEEA3200BB1B69 /* Account+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505F6D820BEEA3100BB1B69 /* Account+CoreDataProperties.swift */; };
3638
B505F6DB20BEEA3200BB1B69 /* Account+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505F6D920BEEA3200BB1B69 /* Account+CoreDataClass.swift */; };
@@ -95,6 +97,8 @@
9597
74B053702153090F0068EB85 /* Model 3.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 3.xcdatamodel"; sourceTree = "<group>"; };
9698
74B7D6AB20F90CBB002667AC /* OrderNote+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderNote+CoreDataClass.swift"; sourceTree = "<group>"; };
9799
74B7D6AC20F90CBB002667AC /* OrderNote+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderNote+CoreDataProperties.swift"; sourceTree = "<group>"; };
100+
74F009BE2183B99B002B4566 /* Note+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Note+CoreDataClass.swift"; sourceTree = "<group>"; };
101+
74F009BF2183B99B002B4566 /* Note+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Note+CoreDataProperties.swift"; sourceTree = "<group>"; };
98102
7C81935EDD982072BBDCC837 /* Pods-Storage.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Storage.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Storage/Pods-Storage.release.xcconfig"; sourceTree = "<group>"; };
99103
A3821B262583F14863740A37 /* Pods-Storage.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Storage.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-Storage/Pods-Storage.debug.xcconfig"; sourceTree = "<group>"; };
100104
B505255320EE6914008090F5 /* StorageType+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StorageType+Extensions.swift"; sourceTree = "<group>"; };
@@ -295,10 +299,8 @@
295299
B59E11D820A9D00C004121A4 /* WooCommerce.xcdatamodeld */,
296300
B505F6D920BEEA3200BB1B69 /* Account+CoreDataClass.swift */,
297301
B505F6D820BEEA3100BB1B69 /* Account+CoreDataProperties.swift */,
298-
B5B914C320EFF03500F2F832 /* Site+CoreDataClass.swift */,
299-
B5B914C420EFF03500F2F832 /* Site+CoreDataProperties.swift */,
300-
7492FAD4217FA9C100ED2C69 /* SiteSetting+CoreDataClass.swift */,
301-
7492FAD5217FA9C100ED2C69 /* SiteSetting+CoreDataProperties.swift */,
302+
74F009BE2183B99B002B4566 /* Note+CoreDataClass.swift */,
303+
74F009BF2183B99B002B4566 /* Note+CoreDataProperties.swift */,
302304
7426A04320F68F27002A4E07 /* Order+CoreDataClass.swift */,
303305
7426A04420F68F27002A4E07 /* Order+CoreDataProperties.swift */,
304306
7426A04E20F69D00002A4E07 /* OrderCoupon+CoreDataClass.swift */,
@@ -307,6 +309,10 @@
307309
7426A05320F69DA4002A4E07 /* OrderItem+CoreDataProperties.swift */,
308310
74B7D6AB20F90CBB002667AC /* OrderNote+CoreDataClass.swift */,
309311
74B7D6AC20F90CBB002667AC /* OrderNote+CoreDataProperties.swift */,
312+
B5B914C320EFF03500F2F832 /* Site+CoreDataClass.swift */,
313+
B5B914C420EFF03500F2F832 /* Site+CoreDataProperties.swift */,
314+
7492FAD4217FA9C100ED2C69 /* SiteSetting+CoreDataClass.swift */,
315+
7492FAD5217FA9C100ED2C69 /* SiteSetting+CoreDataProperties.swift */,
310316
7471A518216CF12900219F7E /* Stats */,
311317
);
312318
path = Model;
@@ -523,6 +529,7 @@
523529
7492FAD6217FA9C100ED2C69 /* SiteSetting+CoreDataClass.swift in Sources */,
524530
B505F6E020BEEA8100BB1B69 /* StorageType.swift in Sources */,
525531
746A9D22214078080013F6FF /* TopEarnerStats+CoreDataProperties.swift in Sources */,
532+
74F009C12183B99B002B4566 /* Note+CoreDataProperties.swift in Sources */,
526533
B54CA5C920A4C17800F38CD1 /* NSObject+Storage.swift in Sources */,
527534
7471A516216CF0FE00219F7E /* SiteVisitStatsItem+CoreDataClass.swift in Sources */,
528535
B505F6DA20BEEA3200BB1B69 /* Account+CoreDataProperties.swift in Sources */,
@@ -531,6 +538,7 @@
531538
B52B0F7B20AA28A800477698 /* Object.swift in Sources */,
532539
7426A05020F69D00002A4E07 /* OrderCoupon+CoreDataClass.swift in Sources */,
533540
746A9D23214078080013F6FF /* TopEarnerStatsItem+CoreDataClass.swift in Sources */,
541+
74F009C02183B99B002B4566 /* Note+CoreDataClass.swift in Sources */,
534542
B505F6DE20BEEA4F00BB1B69 /* CoreDataManager.swift in Sources */,
535543
7492FAD7217FA9C100ED2C69 /* SiteSetting+CoreDataProperties.swift in Sources */,
536544
746A9D24214078080013F6FF /* TopEarnerStatsItem+CoreDataProperties.swift in Sources */,

Storage/Storage/Model/MIGRATIONS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Core Data Migrations
22

3-
This file documents changes in the extensions data model. Please explain any changes to the data model as well as any custom migrations.
3+
This file documents changes in the WCiOS Storage data model. Please explain any changes to the data model as well as any custom migrations.
44

55
## Model 5
6+
- @bummytime 2018-10-26
7+
- Added new entity: `Note`, to encapsulate all things notifications
8+
69
- @bummytime 2018-10-23
710
- Added new entity: `SiteSetting`, to encapsulate all of the site settings
811

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Foundation
2+
import CoreData
3+
4+
5+
@objc(Note)
6+
public class Note: NSManagedObject {
7+
8+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Foundation
2+
import CoreData
3+
4+
5+
extension Note {
6+
7+
@nonobjc public class func fetchRequest() -> NSFetchRequest<Note> {
8+
return NSFetchRequest<Note>(entityName: "Note")
9+
}
10+
11+
@NSManaged public var noteID: Int64
12+
@NSManaged public var noteHash: Int64
13+
@NSManaged public var read: Bool
14+
@NSManaged public var icon: String?
15+
@NSManaged public var noticon: String?
16+
@NSManaged public var timestamp: String?
17+
@NSManaged public var type: String?
18+
@NSManaged public var url: String?
19+
@NSManaged public var title: String?
20+
@NSManaged public var subject: [AnyObject]?
21+
@NSManaged public var header: [AnyObject]?
22+
@NSManaged public var body: [AnyObject]?
23+
@NSManaged public var meta: AnyObject?
24+
}

Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 5.xcdatamodel/contents

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
<attribute name="userID" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
88
<attribute name="username" attributeType="String" syncable="YES"/>
99
</entity>
10+
<entity name="Note" representedClassName="Note" syncable="YES">
11+
<attribute name="body" optional="YES" attributeType="Transformable" syncable="YES"/>
12+
<attribute name="header" optional="YES" attributeType="Transformable" syncable="YES"/>
13+
<attribute name="icon" optional="YES" attributeType="String" syncable="YES"/>
14+
<attribute name="meta" optional="YES" attributeType="Transformable" syncable="YES"/>
15+
<attribute name="noteHash" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
16+
<attribute name="noteID" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
17+
<attribute name="noticon" optional="YES" attributeType="String" syncable="YES"/>
18+
<attribute name="read" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
19+
<attribute name="subject" optional="YES" attributeType="Transformable" syncable="YES"/>
20+
<attribute name="timestamp" attributeType="String" syncable="YES"/>
21+
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
22+
<attribute name="type" optional="YES" attributeType="String" syncable="YES"/>
23+
<attribute name="url" optional="YES" attributeType="String" syncable="YES"/>
24+
</entity>
1025
<entity name="Order" representedClassName="Order" syncable="YES">
1126
<attribute name="billingAddress1" optional="YES" attributeType="String" syncable="YES"/>
1227
<attribute name="billingAddress2" optional="YES" attributeType="String" syncable="YES"/>
@@ -165,10 +180,11 @@
165180
<element name="OrderStats" positionX="137.859375" positionY="388.33203125" width="128" height="225"/>
166181
<element name="OrderStatsItem" positionX="321.74609375" positionY="425.51171875" width="128" height="330"/>
167182
<element name="Site" positionX="-203.6875" positionY="208.0703125" width="128" height="135"/>
183+
<element name="SiteSetting" positionX="-362.54296875" positionY="217.9921875" width="128" height="120"/>
168184
<element name="SiteVisitStats" positionX="134.515625" positionY="224.62109375" width="128" height="90"/>
169185
<element name="SiteVisitStatsItem" positionX="308.1328125" positionY="251.91796875" width="128" height="90"/>
170186
<element name="TopEarnerStats" positionX="135.3828125" positionY="28.91015625" width="128" height="105"/>
171187
<element name="TopEarnerStatsItem" positionX="308.53125" positionY="29.1484375" width="128" height="165"/>
172-
<element name="SiteSetting" positionX="-362.54296875" positionY="217.9921875" width="128" height="120"/>
188+
<element name="Note" positionX="-162" positionY="180" width="128" height="240"/>
173189
</elements>
174190
</model>

Storage/Storage/Tools/StorageType+Extensions.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,11 @@ public extension StorageType {
8989
let predicate = NSPredicate(format: "siteID = %ld AND settingID ==[c] %@", siteID, settingID)
9090
return firstObject(ofType: SiteSetting.self, matching: predicate)
9191
}
92+
93+
/// Retrieves the Notification.
94+
///
95+
public func loadNotification(noteID: Int, noteHash: Int) -> Note? {
96+
let predicate = NSPredicate(format: "noteID = %ld AND noteHash = %ld", noteID, noteHash)
97+
return firstObject(ofType: Note.self, matching: predicate)
98+
}
9299
}

Yosemite/Yosemite/Model/Model.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import Storage
99
public typealias Account = Networking.Account
1010
public typealias Address = Networking.Address
1111
public typealias Credentials = Networking.Credentials
12+
public typealias MetaContainer = Networking.MetaContainer
13+
public typealias Note = Networking.Note
14+
public typealias NoteBlock = Networking.NoteBlock
15+
public typealias NoteMedia = Networking.NoteMedia
16+
public typealias NoteRange = Networking.NoteRange
1217
public typealias Order = Networking.Order
1318
public typealias OrderItem = Networking.OrderItem
1419
public typealias OrderStatus = Networking.OrderStatus
@@ -28,6 +33,7 @@ public typealias TopEarnerStatsItem = Networking.TopEarnerStatsItem
2833
// MARK: - Exported Storage Symbols
2934

3035
public typealias StorageAccount = Storage.Account
36+
public typealias StorageNote = Storage.Note
3137
public typealias StorageOrder = Storage.Order
3238
public typealias StorageOrderStats = Storage.OrderStats
3339
public typealias StorageOrderStatsItem = Storage.OrderStatsItem

0 commit comments

Comments
 (0)