diff --git a/app/assets/javascripts/discourse/app/components/group-flair-inputs.js b/app/assets/javascripts/discourse/app/components/group-flair-inputs.js index b6a9cbaec04..8413569c918 100644 --- a/app/assets/javascripts/discourse/app/components/group-flair-inputs.js +++ b/app/assets/javascripts/discourse/app/components/group-flair-inputs.js @@ -8,9 +8,7 @@ import { action } from "@ember/object"; import { ajax } from "discourse/lib/ajax"; import { convertIconClass } from "discourse-common/lib/icon-library"; import discourseDebounce from "discourse-common/lib/debounce"; -import { escapeExpression } from "discourse/lib/utilities"; import getURL from "discourse-common/lib/get-url"; -import { htmlSafe } from "@ember/template"; export default Component.extend({ classNames: ["group-flair-inputs"], @@ -39,6 +37,10 @@ export default Component.extend({ }, _loadIcon() { + if (!this.model.flair_icon) { + return; + } + const icon = convertIconClass(this.model.flair_icon), c = "#svg-sprites", h = "ajax-icon-holder", @@ -71,42 +73,6 @@ export default Component.extend({ return flairUrl && flairUrl.includes("/") ? flairUrl : null; }, - @discourseComputed( - "model.flair_url", - "flairPreviewImage", - "model.flairBackgroundHexColor", - "model.flairHexColor" - ) - flairPreviewStyle( - flairUrl, - flairPreviewImage, - flairBackgroundHexColor, - flairHexColor - ) { - let style = ""; - - if (flairPreviewImage) { - style += `background-image: url(${escapeExpression(flairUrl)});`; - } - - if (flairBackgroundHexColor) { - style += `background-color: #${flairBackgroundHexColor};`; - } - - if (flairHexColor) { - style += `color: #${flairHexColor};`; - } - - return htmlSafe(style); - }, - - @discourseComputed("model.flairBackgroundHexColor") - flairPreviewClasses(flairBackgroundHexColor) { - if (flairBackgroundHexColor) { - return "rounded"; - } - }, - @discourseComputed("flairPreviewImage") flairPreviewLabel(flairPreviewImage) { const key = flairPreviewImage ? "image" : "icon"; diff --git a/app/assets/javascripts/discourse/app/templates/components/group-flair-inputs.hbs b/app/assets/javascripts/discourse/app/templates/components/group-flair-inputs.hbs index 94f140f845b..390f48ac059 100644 --- a/app/assets/javascripts/discourse/app/templates/components/group-flair-inputs.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/group-flair-inputs.hbs @@ -61,12 +61,13 @@ - {{#if flairPreviewImage}} -
- {{else if flairPreviewIcon}} - + {{#if (or model.flair_icon flairImageUrl model.flairBackgroundHexColor)}} + {{avatar-flair + flairName=model.name + flairUrl=(if flairPreviewIcon model.flair_icon (if flairPreviewImage flairImageUrl "")) + flairBgColor=model.flairBackgroundHexColor + flairColor=model.flairHexColor + }} {{/if}} diff --git a/app/assets/javascripts/discourse/app/templates/group.hbs b/app/assets/javascripts/discourse/app/templates/group.hbs index b3a03b7b451..282b821a5f2 100644 --- a/app/assets/javascripts/discourse/app/templates/group.hbs +++ b/app/assets/javascripts/discourse/app/templates/group.hbs @@ -9,16 +9,16 @@
- {{#if model.flair_url}} -
+
+ {{#if (or model.flair_icon model.flair_url model.flair_bg_color)}} {{avatar-flair flairName=model.name - flairUrl=model.flair_url + flairUrl=(or model.flair_icon model.flair_url) flairBgColor=model.flair_bg_color flairColor=model.flair_color }} -
- {{/if}} + {{/if}} +
{{groupName}}