This repository was archived by the owner on Sep 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +5
-18
lines changed Expand file tree Collapse file tree 1 file changed +5
-18
lines changed Original file line number Diff line number Diff line change @@ -14,19 +14,11 @@ public class AnnouncementServiceRemote: ServiceRemoteWordPressComREST {
1414 }
1515
1616 let path = self . path ( forEndpoint: endPoint, withVersion: . _2_0)
17-
18- wordPressComRestApi. GETData ( path, parameters: nil ) { result in
19- switch result {
20- case . success( ( let data, _) ) :
21- do {
22- let announcements = try self . decodeAnnouncements ( from: data)
23- completion ( . success( announcements) )
24- } catch {
25- completion ( . failure( error) )
26- }
27- case . failure( let error) :
28- completion ( . failure( error) )
29- }
17+ Task { @MainActor [ wordPressComRestApi] in
18+ await wordPressComRestApi. perform ( . get, URLString: path, type: AnnouncementsContainer . self)
19+ . map { $0. body. announcements }
20+ . eraseToError ( )
21+ . execute ( completion)
3022 }
3123 }
3224}
@@ -45,11 +37,6 @@ private extension AnnouncementServiceRemote {
4537 path? . queryItems = makeQueryItems ( appId: appId, appVersion: appVersion, locale: locale)
4638 return path? . string
4739 }
48-
49- func decodeAnnouncements( from data: Data ) throws -> [ Announcement ] {
50- let container = try JSONDecoder ( ) . decode ( AnnouncementsContainer . self, from: data)
51- return container. announcements
52- }
5340}
5441
5542// MARK: - Constants
You can’t perform that action at this time.
0 commit comments