Remove unused code
This commit is contained in:
parent
0f3c50ba8a
commit
86d30887b6
|
@ -22,29 +22,16 @@ extension APIService {
|
||||||
record: MastodonStatus,
|
record: 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 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 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 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>
|
||||||
|
|
|
@ -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 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 me = authentication.user(in: managedObjectContext)
|
|
||||||
else {
|
|
||||||
throw APIError.implicit(.badRequest)
|
|
||||||
}
|
|
||||||
|
|
||||||
let _status = status.reblog ?? status
|
let favoriteContext = MastodonFavoriteContext(
|
||||||
let isFavorited = _status.entity.favourited == true
|
statusID: _status.id,
|
||||||
let favoritedCount = Int64(_status.entity.favouritesCount)
|
isFavorited: isFavorited,
|
||||||
|
favoritedCount: favoritedCount
|
||||||
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>
|
||||||
|
|
|
@ -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 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 reblogContext = MastodonReblogContext(
|
let reblogContext = MastodonReblogContext(
|
||||||
statusID: _status.id,
|
statusID: _status.id,
|
||||||
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(
|
||||||
|
|
Loading…
Reference in New Issue