Remove unused code

This commit is contained in:
Marcus Kida 2023-12-04 14:36:31 +01:00
parent 0f3c50ba8a
commit 86d30887b6
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
3 changed files with 24 additions and 64 deletions

View File

@ -23,28 +23,15 @@ extension APIService {
authenticationBox: MastodonAuthenticationBox authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> { ) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
let managedObjectContext = backgroundManagedObjectContext
// update bookmark state and retrieve bookmark context // update bookmark state and retrieve bookmark context
let bookmarkContext: MastodonBookmarkContext = try await managedObjectContext.performChanges { let _status = record.entity
let authentication = authenticationBox.authentication let status = _status.reblog ?? _status
let isBookmarked = status.bookmarked == true
guard let bookmarkContext = MastodonBookmarkContext(
let me = authentication.user(in: managedObjectContext) statusID: status.id,
else { isBookmarked: isBookmarked
throw APIError.implicit(.badRequest) )
}
let _status = record.entity
let status = _status.reblog ?? _status
let isBookmarked = status.bookmarked == true
let context = MastodonBookmarkContext(
statusID: status.id,
isBookmarked: isBookmarked
)
return context
}
// request bookmark or undo bookmark // request bookmark or undo bookmark
let result: Result<Mastodon.Response.Content<Mastodon.Entity.Status>, Error> let result: Result<Mastodon.Response.Content<Mastodon.Entity.Status>, Error>

View File

@ -24,29 +24,16 @@ extension APIService {
authenticationBox: MastodonAuthenticationBox authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> { ) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
let managedObjectContext = backgroundManagedObjectContext
// update like state and retrieve like context // update like state and retrieve like context
let favoriteContext: MastodonFavoriteContext = try await managedObjectContext.performChanges { let _status = status.reblog ?? status
let authentication = authenticationBox.authentication let isFavorited = _status.entity.favourited == true
let favoritedCount = Int64(_status.entity.favouritesCount)
guard let favoriteContext = MastodonFavoriteContext(
let me = authentication.user(in: managedObjectContext) statusID: _status.id,
else { isFavorited: isFavorited,
throw APIError.implicit(.badRequest) favoritedCount: favoritedCount
} )
let _status = status.reblog ?? status
let isFavorited = _status.entity.favourited == true
let favoritedCount = Int64(_status.entity.favouritesCount)
let context = MastodonFavoriteContext(
statusID: _status.id,
isFavorited: isFavorited,
favoritedCount: favoritedCount
)
return context
}
// request like or undo like // request like or undo like
let result: Result<Mastodon.Response.Content<Mastodon.Entity.Status>, Error> let result: Result<Mastodon.Response.Content<Mastodon.Entity.Status>, Error>

View File

@ -23,30 +23,17 @@ extension APIService {
status: MastodonStatus, status: MastodonStatus,
authenticationBox: MastodonAuthenticationBox authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> { ) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
let managedObjectContext = backgroundManagedObjectContext
// update repost state and retrieve repost context // update repost state and retrieve repost context
let _reblogContext: MastodonReblogContext? = try await managedObjectContext.performChanges { let _status = status.reblog ?? status
let authentication = authenticationBox.authentication let isReblogged = _status.entity.reblogged == true
let rebloggedCount = Int64(_status.entity.reblogsCount)
guard let reblogContext = MastodonReblogContext(
let me = authentication.user(in: managedObjectContext) statusID: _status.id,
else { return nil } isReblogged: isReblogged,
rebloggedCount: rebloggedCount
let _status = status.reblog ?? status )
let isReblogged = _status.entity.reblogged == true
let rebloggedCount = Int64(_status.entity.reblogsCount)
let reblogContext = MastodonReblogContext(
statusID: _status.id,
isReblogged: isReblogged,
rebloggedCount: rebloggedCount
)
return reblogContext
}
guard let reblogContext = _reblogContext else {
throw APIError.implicit(.badRequest)
}
// request repost or undo repost // request repost or undo repost
let result: Result<Mastodon.Response.Content<Mastodon.Entity.Status>, Error> let result: Result<Mastodon.Response.Content<Mastodon.Entity.Status>, Error>
@ -86,7 +73,6 @@ extension APIService {
authorization: authenticationBox.userAuthorization authorization: authenticationBox.userAuthorization
).singleOutput() ).singleOutput()
#warning("Is this still required?")
try await managedObjectContext.performChanges { try await managedObjectContext.performChanges {
for entity in response.value { for entity in response.value {
_ = Persistence.MastodonUser.createOrMerge( _ = Persistence.MastodonUser.createOrMerge(