mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-06 00:39:31 +00:00
Refactoring
This commit is contained in:
parent
f99b74dd98
commit
cb74fd42be
2 changed files with 9 additions and 9 deletions
|
@ -6,10 +6,9 @@ import Mastodon
|
|||
import ServiceLayer
|
||||
|
||||
public final class StatusViewModel: AttachmentsRenderingViewModel, ObservableObject {
|
||||
public let accountViewModel: AccountViewModel
|
||||
public let content: NSAttributedString
|
||||
public let contentEmojis: [Emoji]
|
||||
public let displayName: String
|
||||
public let displayNameEmojis: [Emoji]
|
||||
public let spoilerText: String
|
||||
public let isReblog: Bool
|
||||
public let rebloggedByDisplayName: String
|
||||
|
@ -29,12 +28,13 @@ public final class StatusViewModel: AttachmentsRenderingViewModel, ObservableObj
|
|||
self.statusService = statusService
|
||||
self.identityContext = identityContext
|
||||
self.eventsSubject = eventsSubject
|
||||
accountViewModel = AccountViewModel(
|
||||
accountService: statusService.navigationService
|
||||
.accountService(account: statusService.status.displayStatus.account),
|
||||
identityContext: identityContext,
|
||||
eventsSubject: eventsSubject)
|
||||
content = statusService.status.displayStatus.content.attributed
|
||||
contentEmojis = statusService.status.displayStatus.emojis
|
||||
displayName = statusService.status.displayStatus.account.displayName.isEmpty
|
||||
? statusService.status.displayStatus.account.username
|
||||
: statusService.status.displayStatus.account.displayName
|
||||
displayNameEmojis = statusService.status.displayStatus.account.emojis
|
||||
spoilerText = statusService.status.displayStatus.spoilerText
|
||||
isReblog = statusService.status.reblog != nil
|
||||
rebloggedByDisplayName = statusService.status.account.displayName.isEmpty
|
||||
|
|
|
@ -341,7 +341,7 @@ private extension StatusView {
|
|||
func applyStatusConfiguration() {
|
||||
let viewModel = statusConfiguration.viewModel
|
||||
let isContextParent = viewModel.configuration.isContextParent
|
||||
let mutableDisplayName = NSMutableAttributedString(string: viewModel.displayName)
|
||||
let mutableDisplayName = NSMutableAttributedString(string: viewModel.accountViewModel.displayName)
|
||||
let isAuthenticated = viewModel.identityContext.identity.authenticated
|
||||
&& !viewModel.identityContext.identity.pending
|
||||
|
||||
|
@ -350,7 +350,7 @@ private extension StatusView {
|
|||
avatarImageView.kf.setImage(with: viewModel.avatarURL)
|
||||
avatarButton.accessibilityLabel = String.localizedStringWithFormat(
|
||||
NSLocalizedString("account.avatar.accessibility-label-%@", comment: ""),
|
||||
viewModel.displayName)
|
||||
viewModel.accountViewModel.displayName)
|
||||
|
||||
sideStackView.isHidden = isContextParent
|
||||
avatarImageView.removeFromSuperview()
|
||||
|
@ -406,7 +406,7 @@ private extension StatusView {
|
|||
infoIcon.isHidden = true
|
||||
}
|
||||
|
||||
mutableDisplayName.insert(emojis: viewModel.displayNameEmojis, view: displayNameLabel)
|
||||
mutableDisplayName.insert(emojis: viewModel.accountViewModel.emojis, view: displayNameLabel)
|
||||
mutableDisplayName.resizeAttachments(toLineHeight: displayNameLabel.font.lineHeight)
|
||||
displayNameLabel.attributedText = mutableDisplayName
|
||||
|
||||
|
|
Loading…
Reference in a new issue