chore: Don't recursively iterate through blocks/mutes
This commit is contained in:
parent
12cb8cf8d6
commit
b1d92c69bd
|
@ -26,12 +26,12 @@ extension APIService {
|
|||
public func getBlocked(
|
||||
authenticationBox: MastodonAuthenticationBox
|
||||
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
||||
try await _getBlocked(sinceID: nil, limit: 40, authenticationBox: authenticationBox)
|
||||
try await _getBlocked(sinceID: nil, limit: nil, authenticationBox: authenticationBox)
|
||||
}
|
||||
|
||||
private func _getBlocked(
|
||||
sinceID: Mastodon.Entity.Status.ID?,
|
||||
limit: Int,
|
||||
limit: Int?,
|
||||
authenticationBox: MastodonAuthenticationBox
|
||||
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
||||
let managedObjectContext = backgroundManagedObjectContext
|
||||
|
@ -57,13 +57,8 @@ extension APIService {
|
|||
managedObjectContext.delete(account)
|
||||
}
|
||||
}
|
||||
|
||||
/// only try to paginate if retrieved userIDs count is larger than the set limit and if we get a prev linkId that's different than the currently used one
|
||||
guard userIDs.count == limit, let prevSinceId = response.link?.linkIDs[.linkPrev]?.sinceId, sinceID != prevSinceId else {
|
||||
return response
|
||||
}
|
||||
|
||||
return try await _getBlocked(sinceID: prevSinceId, limit: limit, authenticationBox: authenticationBox)
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
public func toggleBlock(
|
||||
|
|
|
@ -25,12 +25,12 @@ extension APIService {
|
|||
public func getMutes(
|
||||
authenticationBox: MastodonAuthenticationBox
|
||||
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
||||
try await _getMutes(sinceID: nil, limit: 40, authenticationBox: authenticationBox)
|
||||
try await _getMutes(sinceID: nil, limit: nil, authenticationBox: authenticationBox)
|
||||
}
|
||||
|
||||
private func _getMutes(
|
||||
sinceID: Mastodon.Entity.Status.ID?,
|
||||
limit: Int,
|
||||
limit: Int?,
|
||||
authenticationBox: MastodonAuthenticationBox
|
||||
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
||||
let managedObjectContext = backgroundManagedObjectContext
|
||||
|
@ -56,13 +56,8 @@ extension APIService {
|
|||
managedObjectContext.delete(account)
|
||||
}
|
||||
}
|
||||
|
||||
/// only try to paginate if retrieved userIDs count is larger than the set limit and if we get a prev linkId that's different than the currently used one
|
||||
guard userIDs.count == limit, let prevSinceId = response.link?.linkIDs[.linkPrev]?.sinceId, sinceID != prevSinceId else {
|
||||
return response
|
||||
}
|
||||
|
||||
return try await _getMutes(sinceID: prevSinceId, limit: limit, authenticationBox: authenticationBox)
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
public func toggleMute(
|
||||
|
|
|
@ -239,8 +239,8 @@ public extension Mastodon.API.Account {
|
|||
static func blocks(
|
||||
session: URLSession,
|
||||
domain: String,
|
||||
sinceID: Mastodon.Entity.Status.ID? = nil,
|
||||
limit: Int,
|
||||
sinceID: Mastodon.Entity.Status.ID?,
|
||||
limit: Int?,
|
||||
authorization: Mastodon.API.OAuth.Authorization
|
||||
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Account]>, Error> {
|
||||
let request = Mastodon.API.get(
|
||||
|
|
Loading…
Reference in New Issue