Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use short_name instead of name for student-student interactions #3053

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ struct ContextCardHeaderView: View {

var body: some View {
VStack(spacing: 10) {
Avatar(name: user.name, url: user.avatar_url?.rawValue, size: 80)
// Show short name (nickname) if user is not a teacher
let nameToUse = (user.email ?? "").isEmpty ? user.short_name : user.name

Avatar(name: nameToUse, url: user.avatar_url?.rawValue, size: 80)
.padding(20)
Text(User.displayName(user.name, pronouns: user.pronouns))
Text(User.displayName(nameToUse, pronouns: user.pronouns))
.font(.bold20)
.foregroundColor(.textDarkest)
.identifier("ContextCard.userNameLabel")
// Only teachers can see user email addresses
if let email = user.email {


Text(email)
.font(.regular14)
.foregroundColor(.textDarkest)
Expand Down
13 changes: 10 additions & 3 deletions Core/Core/People/ContextCard/Group/GroupContextCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ public struct GroupContextCardView: View {
}

public var body: some View {
// Show short name (nickname) if user is not a teacher
let user = model.user.first
let nameToUse = (user?.email ?? "").isEmpty ? user?.short_name : user?.name

contextCard
.navigationBarItems(trailing: emailButton)
.navigationTitle(model.user.first?.name ?? "", subtitle: model.group.first?.name)
.navigationTitle(nameToUse ?? "", subtitle: model.group.first?.name)
.onAppear {
model.viewAppeared()
}
Expand All @@ -53,9 +57,12 @@ public struct GroupContextCardView: View {
} else {
if let user = model.user.first, let group = model.group.first {
VStack(spacing: 10) {
Avatar(name: user.name, url: user.avatarURL, size: 80)
// Show short name (nickname) if user is not a teacher
let nameToUse = (user.email ?? "").isEmpty ? user.short_name : user.name

Avatar(name: nameToUse, url: user.avatarURL, size: 80)
.padding(20)
Text(User.displayName(user.name, pronouns: user.pronouns))
Text(User.displayName(nameToUse, pronouns: user.pronouns))
.font(.bold20)
.foregroundColor(.textDarkest)
.identifier("ContextCard.userNameLabel")
Expand Down
12 changes: 10 additions & 2 deletions Core/Core/People/PeopleListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,17 @@ class PeopleListCell: UITableViewCell {
func update(user: PeopleListUser?, color: UIColor?, isOffline: Bool) {
backgroundColor = .backgroundLightest
selectedBackgroundView = ContextCellBackgroundView.create(color: color)
avatarView.name = user?.name ?? ""
avatarView.name = user?.shortName ?? ""
avatarView.url = isOffline ? nil : user?.avatarURL
let nameText = user.flatMap { User.displayName($0.name, pronouns: $0.pronouns) }

let nameText = user.flatMap {
User.displayName(
// Students should be shown short name (nicknames) for classmates, but teachers should see real names
($0.email ?? "").isEmpty ? $0.shortName : $0.name,
pronouns: $0.pronouns
)
}

nameLabel.setText(nameText, style: .textCellTitle)
nameLabel.accessibilityIdentifier = "\(self.accessibilityIdentifier ?? "").name-label"
let courseEnrollments = user?.enrollments.filter {
Expand Down