Fix account name would be blank when DisplayName is empty. (#1169)

This commit is contained in:
Keita Watanabe 2023-03-05 15:24:59 +09:00 committed by GitHub
parent e3ab57ea1c
commit ef7c216d3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,12 +99,16 @@ public struct AppAccountsSelectorView: View {
if let image = viewModel.roundedAvatar {
Image(uiImage: image)
}
let name = viewModel.account.flatMap { account in
account.displayName?.isEmpty != false ? "@\(account.acct)" : account.displayName
} ?? ""
if let token = viewModel.appAccount.oauthToken,
preferences.getNotificationsCount(for: token) > 0
{
Text("\(viewModel.account?.displayName ?? "") (\(preferences.getNotificationsCount(for: token)))")
Text("\(name) (\(preferences.getNotificationsCount(for: token)))")
} else {
Text("\(viewModel.account?.displayName ?? "")")
Text("\(name)")
}
}
}