Continue refactoring StatusView+Configuration
This commit is contained in:
parent
afd5144c54
commit
21ed593882
@ -123,46 +123,66 @@ extension StatusView {
|
|||||||
return header
|
return header
|
||||||
}
|
}
|
||||||
|
|
||||||
if let replyTo = status.replyTo {
|
if let replyTo = status.inReplyToID, let authBox = viewModel.authContext?.mastodonAuthenticationBox {
|
||||||
// A. replyTo status exist
|
Task {
|
||||||
let header = createHeader(name: replyTo.author.displayNameWithFallback, emojis: replyTo.author.emojis.asDictionary)
|
let replyStatus = try await Mastodon.API.Statuses.status(
|
||||||
viewModel.header = header
|
session: URLSession.shared,
|
||||||
} else {
|
domain: authBox.domain,
|
||||||
|
statusID: replyTo,
|
||||||
|
authorization: authBox.userAuthorization
|
||||||
|
).singleOutput().value
|
||||||
|
|
||||||
|
// A. replyTo status exist
|
||||||
|
let header = createHeader(name: replyStatus.account.displayNameWithFallback, emojis: replyStatus.account.emojis?.asDictionary ?? [:])
|
||||||
|
viewModel.header = header
|
||||||
|
}
|
||||||
|
} else if let authBox = viewModel.authContext?.mastodonAuthenticationBox {
|
||||||
// B. replyTo status not exist
|
// B. replyTo status not exist
|
||||||
|
|
||||||
let request = MastodonUser.sortedFetchRequest
|
Task {
|
||||||
request.predicate = MastodonUser.predicate(domain: status.domain, id: inReplyToAccountID)
|
let user = try await Mastodon.API.Account.accountInfo(
|
||||||
if let user = status.managedObjectContext?.safeFetch(request).first {
|
session: URLSession.shared,
|
||||||
// B1. replyTo user exist
|
domain: authBox.domain,
|
||||||
let header = createHeader(name: user.displayNameWithFallback, emojis: user.emojis.asDictionary)
|
userID: inReplyToAccountID,
|
||||||
viewModel.header = header
|
authorization: authBox.userAuthorization
|
||||||
} else {
|
).singleOutput().value
|
||||||
// B2. replyTo user not exist
|
|
||||||
let header = createHeader(name: nil, emojis: nil)
|
|
||||||
viewModel.header = header
|
|
||||||
|
|
||||||
if let authenticationBox = viewModel.authContext?.mastodonAuthenticationBox {
|
let header = createHeader(name: user.displayNameWithFallback, emojis: user.emojis?.asDictionary ?? [:])
|
||||||
Just(inReplyToAccountID)
|
viewModel.header = header
|
||||||
.asyncMap { userID in
|
}
|
||||||
return try await Mastodon.API.Account.accountInfo(
|
|
||||||
session: .shared,
|
// let request = MastodonUser.sortedFetchRequest
|
||||||
domain: authenticationBox.domain,
|
// request.predicate = MastodonUser.predicate(domain: status.domain, id: inReplyToAccountID)
|
||||||
userID: userID,
|
// if let user = status.managedObjectContext?.safeFetch(request).first {
|
||||||
authorization: authenticationBox.userAuthorization
|
// // B1. replyTo user exist
|
||||||
).singleOutput()
|
//
|
||||||
}
|
// } else {
|
||||||
.receive(on: DispatchQueue.main)
|
// // B2. replyTo user not exist
|
||||||
.sink { completion in
|
// let header = createHeader(name: nil, emojis: nil)
|
||||||
// do nothing
|
// viewModel.header = header
|
||||||
} receiveValue: { [weak self] response in
|
//
|
||||||
guard let self = self else { return }
|
// if let authenticationBox = viewModel.authContext?.mastodonAuthenticationBox {
|
||||||
let user = response.value
|
// Just(inReplyToAccountID)
|
||||||
let header = createHeader(name: user.displayNameWithFallback, emojis: user.emojiMeta)
|
// .asyncMap { userID in
|
||||||
self.viewModel.header = header
|
// return try await Mastodon.API.Account.accountInfo(
|
||||||
}
|
// session: .shared,
|
||||||
.store(in: &disposeBag)
|
// domain: authenticationBox.domain,
|
||||||
} // end if let
|
// userID: userID,
|
||||||
} // end else B2.
|
// authorization: authenticationBox.userAuthorization
|
||||||
|
// ).singleOutput()
|
||||||
|
// }
|
||||||
|
// .receive(on: DispatchQueue.main)
|
||||||
|
// .sink { completion in
|
||||||
|
// // do nothing
|
||||||
|
// } receiveValue: { [weak self] response in
|
||||||
|
// guard let self = self else { return }
|
||||||
|
// let user = response.value
|
||||||
|
// let header = createHeader(name: user.displayNameWithFallback, emojis: user.emojiMeta)
|
||||||
|
// self.viewModel.header = header
|
||||||
|
// }
|
||||||
|
// .store(in: &disposeBag)
|
||||||
|
// } // end if let
|
||||||
|
// } // end else B2.
|
||||||
} // end else B.
|
} // end else B.
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user