Skip to content

Commit f9b871d

Browse files
Merge pull request #435 from woocommerce/issue/19-filtering-active-site-notifications
Filtering Active Site's Notifications
2 parents 85205c4 + 8205bb7 commit f9b871d

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

Storage/Storage/Model/MIGRATIONS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
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 6
6+
- @jleandroperez 2018-11-15
7+
- New `Note.siteID` property
8+
69
- @jleandroperez 2018-11-12
710
- New `Note.subtype` property (optional type)
811

Storage/Storage/Model/Note+CoreDataProperties.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ extension Note {
1010

1111
@NSManaged public var noteID: Int64
1212
@NSManaged public var noteHash: Int64
13+
@NSManaged public var siteID: Int64
1314
@NSManaged public var read: Bool
1415
@NSManaged public var icon: String?
1516
@NSManaged public var noticon: String?

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<attribute name="noteID" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
1717
<attribute name="noticon" optional="YES" attributeType="String" syncable="YES"/>
1818
<attribute name="read" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
19+
<attribute name="siteID" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
1920
<attribute name="subject" optional="YES" attributeType="Binary" syncable="YES"/>
2021
<attribute name="subtype" optional="YES" attributeType="String" syncable="YES"/>
2122
<attribute name="timestamp" attributeType="String" syncable="YES"/>
@@ -176,7 +177,7 @@
176177
</entity>
177178
<elements>
178179
<element name="Account" positionX="-200.9765625" positionY="63.5625" width="128" height="120"/>
179-
<element name="Note" positionX="-162" positionY="180" width="128" height="255"/>
180+
<element name="Note" positionX="-162" positionY="180" width="128" height="270"/>
180181
<element name="Order" positionX="-20" positionY="27" width="128" height="690"/>
181182
<element name="OrderCoupon" positionX="-206.01953125" positionY="379.74609375" width="128" height="120"/>
182183
<element name="OrderItem" positionX="-364.890625" positionY="379.453125" width="128" height="225"/>

WooCommerce/Classes/ViewRelated/Notifications/NotificationsViewController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ class NotificationsViewController: UIViewController {
3030
/// Store Notifications CoreData Filter.
3131
///
3232
private var filter: NSPredicate {
33-
return NSPredicate(format: "type == %@ OR subtype == %@", Note.Kind.storeOrder.rawValue, Note.Subkind.storeReview.rawValue)
33+
let typePredicate = NSPredicate(format: "type == %@ OR subtype == %@", Note.Kind.storeOrder.rawValue, Note.Subkind.storeReview.rawValue)
34+
let sitePredicate = NSPredicate(format: "siteID == %lld", StoresManager.shared.sessionManager.defaultStoreID ?? Int.min)
35+
36+
return NSCompoundPredicate(andPredicateWithSubpredicates: [typePredicate, sitePredicate])
3437
}
3538

3639
/// Pull To Refresh Support.

Yosemite/Yosemite/Model/Storage/Note+ReadOnlyConvertible.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ extension Storage.Note: ReadOnlyConvertible {
88
/// Updates the Storage.Note with the a ReadOnly.
99
///
1010
public func update(with note: Yosemite.Note) {
11+
let theSiteID = note.meta.identifier(forKey: .site) ?? Int.min
12+
13+
siteID = Int64(theSiteID)
1114
noteID = Int64(note.noteId)
1215
noteHash = Int64(note.hash)
1316
read = note.read

0 commit comments

Comments
 (0)