Skip to content

Commit cf3f96e

Browse files
committed
Use the new writer API in BloggingPromptsService.swift
1 parent 2c30808 commit cf3f96e

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

WordPress/Classes/Services/BloggingPromptsService.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,17 +330,13 @@ private extension BloggingPromptsService {
330330
/// - Parameters:
331331
/// - remoteSettings: The blogging prompt settings from the remote.
332332
/// - completion: Closure to be called on completion.
333-
func saveSettings(_ remoteSettings: RemoteBloggingPromptsSettings, completion: @escaping () -> Void) {
334-
let derivedContext = contextManager.newDerivedContext()
335-
derivedContext.perform {
336-
let settings = self.loadSettings(context: derivedContext) ?? BloggingPromptSettings(context: derivedContext)
337-
settings.configure(with: remoteSettings, siteID: self.siteID.int32Value, context: derivedContext)
338-
339-
self.contextManager.save(derivedContext) {
340-
DispatchQueue.main.async {
341-
completion()
342-
}
333+
func saveSettings(_ remoteSettings: RemoteBloggingPromptsSettings, completion: @MainActor @escaping () -> Void) {
334+
Task {
335+
await contextManager.save { derivedContext in
336+
let settings = self.loadSettings(context: derivedContext) ?? BloggingPromptSettings(context: derivedContext)
337+
settings.configure(with: remoteSettings, siteID: self.siteID.int32Value, context: derivedContext)
343338
}
339+
await completion()
344340
}
345341
}
346342

0 commit comments

Comments
 (0)