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 authentication = authenticationBox.authentication
guard
let me = authentication.user(in: managedObjectContext)
else {
throw APIError.implicit(.badRequest)
}
let _status = record.entity let _status = record.entity
let status = _status.reblog ?? _status let status = _status.reblog ?? _status
let isBookmarked = status.bookmarked == true let isBookmarked = status.bookmarked == true
let context = MastodonBookmarkContext( let bookmarkContext = MastodonBookmarkContext(
statusID: status.id, statusID: status.id,
isBookmarked: isBookmarked 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 authentication = authenticationBox.authentication
guard
let me = authentication.user(in: managedObjectContext)
else {
throw APIError.implicit(.badRequest)
}
let _status = status.reblog ?? status let _status = status.reblog ?? status
let isFavorited = _status.entity.favourited == true let isFavorited = _status.entity.favourited == true
let favoritedCount = Int64(_status.entity.favouritesCount) let favoritedCount = Int64(_status.entity.favouritesCount)
let context = MastodonFavoriteContext( let favoriteContext = MastodonFavoriteContext(
statusID: _status.id, statusID: _status.id,
isFavorited: isFavorited, isFavorited: isFavorited,
favoritedCount: favoritedCount 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,16 +23,8 @@ 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 authentication = authenticationBox.authentication
guard
let me = authentication.user(in: managedObjectContext)
else { return nil }
let _status = status.reblog ?? status let _status = status.reblog ?? status
let isReblogged = _status.entity.reblogged == true let isReblogged = _status.entity.reblogged == true
let rebloggedCount = Int64(_status.entity.reblogsCount) let rebloggedCount = Int64(_status.entity.reblogsCount)
@ -42,11 +34,6 @@ extension APIService {
isReblogged: isReblogged, isReblogged: isReblogged,
rebloggedCount: rebloggedCount 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(