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(
|
public func getBlocked(
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
) 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(
|
private func _getBlocked(
|
||||||
sinceID: Mastodon.Entity.Status.ID?,
|
sinceID: Mastodon.Entity.Status.ID?,
|
||||||
limit: Int,
|
limit: Int?,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
||||||
let managedObjectContext = backgroundManagedObjectContext
|
let managedObjectContext = backgroundManagedObjectContext
|
||||||
|
@ -58,14 +58,9 @@ extension APIService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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 response
|
||||||
}
|
}
|
||||||
|
|
||||||
return try await _getBlocked(sinceID: prevSinceId, limit: limit, authenticationBox: authenticationBox)
|
|
||||||
}
|
|
||||||
|
|
||||||
public func toggleBlock(
|
public func toggleBlock(
|
||||||
user: ManagedObjectRecord<MastodonUser>,
|
user: ManagedObjectRecord<MastodonUser>,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
|
|
|
@ -25,12 +25,12 @@ extension APIService {
|
||||||
public func getMutes(
|
public func getMutes(
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
) 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(
|
private func _getMutes(
|
||||||
sinceID: Mastodon.Entity.Status.ID?,
|
sinceID: Mastodon.Entity.Status.ID?,
|
||||||
limit: Int,
|
limit: Int?,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
|
||||||
let managedObjectContext = backgroundManagedObjectContext
|
let managedObjectContext = backgroundManagedObjectContext
|
||||||
|
@ -57,14 +57,9 @@ extension APIService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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 response
|
||||||
}
|
}
|
||||||
|
|
||||||
return try await _getMutes(sinceID: prevSinceId, limit: limit, authenticationBox: authenticationBox)
|
|
||||||
}
|
|
||||||
|
|
||||||
public func toggleMute(
|
public func toggleMute(
|
||||||
user: ManagedObjectRecord<MastodonUser>,
|
user: ManagedObjectRecord<MastodonUser>,
|
||||||
authenticationBox: MastodonAuthenticationBox
|
authenticationBox: MastodonAuthenticationBox
|
||||||
|
|
|
@ -239,8 +239,8 @@ public extension Mastodon.API.Account {
|
||||||
static func blocks(
|
static func blocks(
|
||||||
session: URLSession,
|
session: URLSession,
|
||||||
domain: String,
|
domain: String,
|
||||||
sinceID: Mastodon.Entity.Status.ID? = nil,
|
sinceID: Mastodon.Entity.Status.ID?,
|
||||||
limit: Int,
|
limit: Int?,
|
||||||
authorization: Mastodon.API.OAuth.Authorization
|
authorization: Mastodon.API.OAuth.Authorization
|
||||||
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Account]>, Error> {
|
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Account]>, Error> {
|
||||||
let request = Mastodon.API.get(
|
let request = Mastodon.API.get(
|
||||||
|
|
Loading…
Reference in New Issue