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

@ -22,29 +22,16 @@ extension APIService {
record: MastodonStatus,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
let managedObjectContext = backgroundManagedObjectContext
// 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 = _status.reblog ?? _status
let isBookmarked = status.bookmarked == true
let _status = record.entity
let status = _status.reblog ?? _status
let isBookmarked = status.bookmarked == true
let context = MastodonBookmarkContext(
statusID: status.id,
isBookmarked: isBookmarked
)
return context
}
let bookmarkContext = MastodonBookmarkContext(
statusID: status.id,
isBookmarked: isBookmarked
)
// request bookmark or undo bookmark
let result: Result<Mastodon.Response.Content<Mastodon.Entity.Status>, Error>

View File

@ -23,30 +23,17 @@ extension APIService {
status: MastodonStatus,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
let managedObjectContext = backgroundManagedObjectContext
// 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 isFavorited = _status.entity.favourited == true
let favoritedCount = Int64(_status.entity.favouritesCount)
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
}
let favoriteContext = MastodonFavoriteContext(
statusID: _status.id,
isFavorited: isFavorited,
favoritedCount: favoritedCount
)
// request like or undo like
let result: Result<Mastodon.Response.Content<Mastodon.Entity.Status>, Error>

View File

@ -23,30 +23,17 @@ extension APIService {
status: MastodonStatus,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Status> {
let managedObjectContext = backgroundManagedObjectContext
// 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 isReblogged = _status.entity.reblogged == true
let rebloggedCount = Int64(_status.entity.reblogsCount)
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)
}
let reblogContext = MastodonReblogContext(
statusID: _status.id,
isReblogged: isReblogged,
rebloggedCount: rebloggedCount
)
// request repost or undo repost
let result: Result<Mastodon.Response.Content<Mastodon.Entity.Status>, Error>
@ -86,7 +73,6 @@ extension APIService {
authorization: authenticationBox.userAuthorization
).singleOutput()
#warning("Is this still required?")
try await managedObjectContext.performChanges {
for entity in response.value {
_ = Persistence.MastodonUser.createOrMerge(