Address PR Feedback (IOS-102)

This commit is contained in:
Marcus Kida 2024-07-17 12:59:01 +02:00
parent 019f483c0c
commit 21ea90200e
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
3 changed files with 12 additions and 16 deletions

View File

@ -39,7 +39,7 @@ extension APIService {
query: query,
hashtag: hashtag,
authorization: authorization
).singleOutput()
)
return response
}

View File

@ -19,7 +19,7 @@ extension APIService {
query: query,
id: id,
authorization: authorization
).singleOutput()
)
return response
}

View File

@ -112,18 +112,16 @@ extension Mastodon.API.Timeline {
query: HashtagTimelineQuery,
hashtag: String,
authorization: Mastodon.API.OAuth.Authorization?
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Status]>, Error> {
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Status]> {
let request = Mastodon.API.get(
url: hashtagTimelineEndpointURL(domain: domain, hashtag: hashtag),
query: query,
authorization: authorization
)
return session.dataTaskPublisher(for: request)
.tryMap { data, response in
let value = try Mastodon.API.decode(type: [Mastodon.Entity.Status].self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
.eraseToAnyPublisher()
let (data, response) = try await session.data(for: request)
let value = try Mastodon.API.decode(type: [Mastodon.Entity.Status].self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
public static func list(
@ -132,18 +130,16 @@ extension Mastodon.API.Timeline {
query: PublicTimelineQuery,
id: String,
authorization: Mastodon.API.OAuth.Authorization?
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Status]>, Error> {
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Status]> {
let request = Mastodon.API.get(
url: listTimelineEndpointURL(domain: domain, id: id),
query: query,
authorization: authorization
)
return session.dataTaskPublisher(for: request)
.tryMap { data, response in
let value = try Mastodon.API.decode(type: [Mastodon.Entity.Status].self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
.eraseToAnyPublisher()
let (data, response) = try await session.data(for: request)
let value = try Mastodon.API.decode(type: [Mastodon.Entity.Status].self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
}