From 6508d2fa4b00c04af445af902786b4efecdbe56b Mon Sep 17 00:00:00 2001 From: Bea <1123bmac@gmail.com> Date: Wed, 8 Jan 2025 22:17:48 -0800 Subject: [PATCH 1/3] use `short_name` instead of `name` in PeopleList --- Core/Core/People/PeopleListViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Core/People/PeopleListViewController.swift b/Core/Core/People/PeopleListViewController.swift index fa71d5e07a..34b413585a 100644 --- a/Core/Core/People/PeopleListViewController.swift +++ b/Core/Core/People/PeopleListViewController.swift @@ -274,7 +274,7 @@ class PeopleListCell: UITableViewCell { selectedBackgroundView = ContextCellBackgroundView.create(color: color) avatarView.name = user?.name ?? "" avatarView.url = isOffline ? nil : user?.avatarURL - let nameText = user.flatMap { User.displayName($0.name, pronouns: $0.pronouns) } + let nameText = user.flatMap { User.displayName($0.shortName, pronouns: $0.pronouns) } nameLabel.setText(nameText, style: .textCellTitle) nameLabel.accessibilityIdentifier = "\(self.accessibilityIdentifier ?? "").name-label" let courseEnrollments = user?.enrollments.filter { From 93d91ce6cd49386caedd4e94a686402ad3987b64 Mon Sep 17 00:00:00 2001 From: Bea <1123bmac@gmail.com> Date: Wed, 8 Jan 2025 22:17:55 -0800 Subject: [PATCH 2/3] use `short_name` instead of `name` in PeopleDetails --- Core/Core/People/ContextCard/Course/ContextCardHeaderView.swift | 2 +- Core/Core/People/ContextCard/Group/GroupContextCardView.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Core/People/ContextCard/Course/ContextCardHeaderView.swift b/Core/Core/People/ContextCard/Course/ContextCardHeaderView.swift index a6bda7a4c8..7a5c9922a1 100644 --- a/Core/Core/People/ContextCard/Course/ContextCardHeaderView.swift +++ b/Core/Core/People/ContextCard/Course/ContextCardHeaderView.swift @@ -29,7 +29,7 @@ struct ContextCardHeaderView: View { VStack(spacing: 10) { Avatar(name: user.name, url: user.avatar_url?.rawValue, size: 80) .padding(20) - Text(User.displayName(user.name, pronouns: user.pronouns)) + Text(User.displayName(user.shortName, pronouns: user.pronouns)) .font(.bold20) .foregroundColor(.textDarkest) .identifier("ContextCard.userNameLabel") diff --git a/Core/Core/People/ContextCard/Group/GroupContextCardView.swift b/Core/Core/People/ContextCard/Group/GroupContextCardView.swift index e098c7cf7a..dd8a5276cc 100644 --- a/Core/Core/People/ContextCard/Group/GroupContextCardView.swift +++ b/Core/Core/People/ContextCard/Group/GroupContextCardView.swift @@ -55,7 +55,7 @@ public struct GroupContextCardView: View { VStack(spacing: 10) { Avatar(name: user.name, url: user.avatarURL, size: 80) .padding(20) - Text(User.displayName(user.name, pronouns: user.pronouns)) + Text(User.displayName(user.shortName, pronouns: user.pronouns)) .font(.bold20) .foregroundColor(.textDarkest) .identifier("ContextCard.userNameLabel") From 64eb98bf37995dfb15155e6a7436778c22af49a1 Mon Sep 17 00:00:00 2001 From: Bea <1123bmac@gmail.com> Date: Wed, 8 Jan 2025 23:06:29 -0800 Subject: [PATCH 3/3] only show short names between classmates --- .../ContextCard/Course/ContextCardHeaderView.swift | 9 +++++++-- .../ContextCard/Group/GroupContextCardView.swift | 13 ++++++++++--- Core/Core/People/PeopleListViewController.swift | 12 ++++++++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Core/Core/People/ContextCard/Course/ContextCardHeaderView.swift b/Core/Core/People/ContextCard/Course/ContextCardHeaderView.swift index 7a5c9922a1..2f11e80f37 100644 --- a/Core/Core/People/ContextCard/Course/ContextCardHeaderView.swift +++ b/Core/Core/People/ContextCard/Course/ContextCardHeaderView.swift @@ -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.shortName, 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) diff --git a/Core/Core/People/ContextCard/Group/GroupContextCardView.swift b/Core/Core/People/ContextCard/Group/GroupContextCardView.swift index dd8a5276cc..b623146b49 100644 --- a/Core/Core/People/ContextCard/Group/GroupContextCardView.swift +++ b/Core/Core/People/ContextCard/Group/GroupContextCardView.swift @@ -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() } @@ -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.shortName, pronouns: user.pronouns)) + Text(User.displayName(nameToUse, pronouns: user.pronouns)) .font(.bold20) .foregroundColor(.textDarkest) .identifier("ContextCard.userNameLabel") diff --git a/Core/Core/People/PeopleListViewController.swift b/Core/Core/People/PeopleListViewController.swift index 34b413585a..7792de9c8c 100644 --- a/Core/Core/People/PeopleListViewController.swift +++ b/Core/Core/People/PeopleListViewController.swift @@ -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.shortName, 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 {