fix: author name missing emoji issue in compose scene

This commit is contained in:
CMK 2021-06-29 20:00:58 +08:00
parent 9858a39f3d
commit 6aa91dbcfa
3 changed files with 8 additions and 4 deletions

View File

@ -25,6 +25,7 @@ extension ComposeStatusItem {
let avatarURL = CurrentValueSubject<URL?, Never>(nil)
let displayName = CurrentValueSubject<String?, Never>(nil)
let emojiDict = CurrentValueSubject<MastodonStatusContent.EmojiDict, Never>([:])
let username = CurrentValueSubject<String?, Never>(nil)
let composeContent = CurrentValueSubject<String?, Never>(nil)
@ -34,6 +35,7 @@ extension ComposeStatusItem {
static func == (lhs: ComposeStatusAttribute, rhs: ComposeStatusAttribute) -> Bool {
return lhs.avatarURL.value == rhs.avatarURL.value &&
lhs.displayName.value == rhs.displayName.value &&
lhs.emojiDict.value == rhs.emojiDict.value &&
lhs.username.value == rhs.username.value &&
lhs.composeContent.value == rhs.composeContent.value &&
lhs.isContentWarningComposing.value == rhs.isContentWarningComposing.value &&

View File

@ -43,13 +43,14 @@ extension ComposeStatusSection {
}
.store(in: &cell.disposeBag)
// set display name and username
Publishers.CombineLatest(
attribute.displayName.eraseToAnyPublisher(),
Publishers.CombineLatest3(
attribute.displayName,
attribute.emojiDict,
attribute.username.eraseToAnyPublisher()
)
.receive(on: DispatchQueue.main)
.sink { displayName, username in
cell.statusView.nameLabel.text = displayName
.sink { displayName, emojiDict, username in
cell.statusView.nameLabel.configure(content: displayName ?? " ", emojiDict: emojiDict)
cell.statusView.usernameLabel.text = username.flatMap { "@" + $0 } ?? " "
}
.store(in: &cell.disposeBag)

View File

@ -181,6 +181,7 @@ final class ComposeViewModel: NSObject {
}
return displayName
}()
self.composeStatusAttribute.emojiDict.value = mastodonUser?.emojiDict ?? [:]
self.composeStatusAttribute.username.value = username
}
.store(in: &disposeBag)