@@ -68,6 +68,28 @@ struct PeopleService {
68
68
} )
69
69
}
70
70
71
+ /// Loads a page of Email Followers associated to the current blog, starting at the specified offset.
72
+ ///
73
+ /// - Parameters:
74
+ /// - offset: Number of records to skip.
75
+ /// - count: Number of records to retrieve. By default set to 20.
76
+ /// - success: Closure to be executed on success with the number of followers retrieved and a bool indicating if more are available.
77
+ /// - failure: Closure to be executed on failure.
78
+ ///
79
+ func loadEmailFollowersPage( _ offset: Int = 0 ,
80
+ count: Int = 20 ,
81
+ success: @escaping ( ( _ retrieved: Int , _ shouldLoadMore: Bool ) -> Void ) ,
82
+ failure: ( ( Error ) -> Void ) ? = nil ) {
83
+ let page = ( offset / count) + 1
84
+ remote. getEmailFollowers ( siteID, page: page, max: count, success: { followers, hasMore in
85
+ self . mergePeople ( followers)
86
+ success ( followers. count, hasMore)
87
+ } , failure: { error in
88
+ DDLogError ( String ( describing: error) )
89
+ failure ? ( error)
90
+ } )
91
+ }
92
+
71
93
/// Loads a page of Viewers associated to the current blog, starting at the specified offset.
72
94
///
73
95
/// - Parameters:
@@ -182,6 +204,30 @@ struct PeopleService {
182
204
context. delete ( managedPerson)
183
205
}
184
206
207
+ /// Deletes a given EmailFollower.
208
+ ///
209
+ /// - Parameters:
210
+ /// - person: The email follower that should be deleted
211
+ /// - success: Closure to be executed in case of success.
212
+ /// - failure: Closure to be executed on error
213
+ ///
214
+ func deleteEmailFollower( _ person: EmailFollower , success: ( ( ) -> Void ) ? = nil , failure: ( ( Error ) -> Void ) ? = nil ) {
215
+ guard let managedPerson = managedPersonFromPerson ( person) else {
216
+ return
217
+ }
218
+
219
+ remote. deleteEmailFollower ( siteID, userID: person. ID, success: {
220
+ success ? ( )
221
+ } , failure: { error in
222
+ DDLogError ( " ### Error while deleting follower \( person. ID) from blog \( self . siteID) : \( error) " )
223
+
224
+ self . createManagedPerson ( person)
225
+ failure ? ( error)
226
+ } )
227
+
228
+ context. delete ( managedPerson)
229
+ }
230
+
185
231
/// Deletes a given Viewer.
186
232
///
187
233
/// - Parameters:
0 commit comments