FIX: Pass `siteSettings` through in more places

This commit is contained in:
Robin Ward 2020-07-23 14:57:03 -04:00
parent f8aa304c7d
commit 808b5aa5ba
4 changed files with 11 additions and 5 deletions

View File

@ -340,7 +340,8 @@ const Report = EmberObject.extend({
const avatarImg = renderAvatar(user, { const avatarImg = renderAvatar(user, {
imageSize: "tiny", imageSize: "tiny",
ignoreTitle: true ignoreTitle: true,
siteSettings: this.siteSettings
}); });
return `<a href='${href}'>${avatarImg}<span class='username'>${user.name}</span></a>`; return `<a href='${href}'>${avatarImg}<span class='username'>${user.name}</span></a>`;

View File

@ -21,7 +21,10 @@ export default Component.extend({
name, name,
username, username,
userPath: userPath(username), userPath: userPath(username),
avatar: renderAvatar(user, { imageSize: "large" }), avatar: renderAvatar(user, {
imageSize: "large",
siteSettings: this.siteSettings
}),
title: user.title || "", title: user.title || "",
formatedUsername: formatUsername(username), formatedUsername: formatUsername(username),
prioritizeName, prioritizeName,

View File

@ -1,5 +1,5 @@
import { get } from "@ember/object"; import { get } from "@ember/object";
import { registerUnbound } from "discourse-common/lib/helpers"; import { registerUnbound, helperContext } from "discourse-common/lib/helpers";
import { avatarImg, formatUsername } from "discourse/lib/utilities"; import { avatarImg, formatUsername } from "discourse/lib/utilities";
import { prioritizeNameInUx } from "discourse/lib/settings"; import { prioritizeNameInUx } from "discourse/lib/settings";
import { htmlSafe } from "@ember/template"; import { htmlSafe } from "@ember/template";
@ -32,6 +32,7 @@ export function classesForUser(u) {
function renderAvatar(user, options) { function renderAvatar(user, options) {
options = options || {}; options = options || {};
let siteSettings = helperContext().siteSettings;
if (user) { if (user) {
const name = get(user, options.namePath || "name"); const name = get(user, options.namePath || "name");
const username = get(user, options.usernamePath || "username"); const username = get(user, options.usernamePath || "username");
@ -44,7 +45,7 @@ function renderAvatar(user, options) {
return ""; return "";
} }
let displayName = prioritizeNameInUx(name) let displayName = prioritizeNameInUx(name, siteSettings)
? name ? name
: formatUsername(username); : formatUsername(username);

View File

@ -479,7 +479,8 @@ createWidget("post-notice", {
html(attrs) { html(attrs) {
const user = const user =
this.siteSettings.display_name_on_posts && prioritizeNameInUx(attrs.name) this.siteSettings.display_name_on_posts &&
prioritizeNameInUx(attrs.name, this.siteSettings)
? attrs.name ? attrs.name
: attrs.username; : attrs.username;
let text, icon; let text, icon;