@@ -236,10 +236,7 @@ extension PlanService {
236236
237237struct PlanStorage {
238238 static func activatePlan( _ planID: Int , forSite siteID: Int ) {
239- let manager = ContextManager . sharedInstance ( )
240- let context = manager. newDerivedContext ( )
241-
242- context. performAndWait {
239+ ContextManager . shared. performAndSave { context in
243240 guard let blog = try ? Blog . lookup ( withID: siteID, in: context) else {
244241 let error = " Tried to activate a plan for a non-existing site (ID: \( siteID) ) "
245242 assertionFailure ( error)
@@ -248,16 +245,12 @@ struct PlanStorage {
248245 }
249246 if blog. planID? . intValue != planID {
250247 blog. planID = NSNumber ( value: planID)
251- manager. saveContextAndWait ( context)
252248 }
253249 }
254250 }
255251
256252 static func updateHasDomainCredit( _ planID: Int , forSite siteID: Int , hasDomainCredit: Bool ) {
257- let manager = ContextManager . sharedInstance ( )
258- let context = manager. newDerivedContext ( )
259-
260- context. performAndWait {
253+ ContextManager . shared. performAndSave { context in
261254 guard let blog = try ? Blog . lookup ( withID: siteID, in: context) else {
262255 let error = " Tried to update a plan for a non-existing site (ID: \( siteID) ) "
263256 assertionFailure ( error)
@@ -266,7 +259,6 @@ struct PlanStorage {
266259 }
267260 if blog. hasDomainCredit != hasDomainCredit {
268261 blog. hasDomainCredit = hasDomainCredit
269- manager. saveContextAndWait ( context)
270262 }
271263 }
272264 }
0 commit comments