DEV: DRY up wavingHandUrl code.

Allows for resuse in other controllers and components.
This commit is contained in:
Alan Guo Xiang Tan 2021-03-04 12:08:14 +08:00
parent 51483e1aef
commit 4a41f72f09
3 changed files with 15 additions and 18 deletions

View File

@ -22,8 +22,7 @@ import { isEmpty } from "@ember/utils";
import { notEmpty } from "@ember/object/computed";
import { setting } from "discourse/lib/computed";
import { userPath } from "discourse/lib/url";
import { helperContext } from "discourse-common/lib/helpers";
import { emojiBasePath } from "discourse/lib/settings";
import { wavingHandURL } from "discourse/lib/waving-hand-url";
export default Controller.extend(
ModalFunctionality,
@ -80,13 +79,7 @@ export default Controller.extend(
},
@discourseComputed()
wavingHandURL() {
const emojiSet = helperContext().siteSettings.emoji_set;
// random number between 2 -6 to render multiple skin tone waving hands
const random = Math.floor(Math.random() * (7 - 2) + 2);
return getURL(`${emojiBasePath()}/${emojiSet}/wave/${random}.png`);
},
wavingHandURL: () => wavingHandURL(),
@discourseComputed(
"userFields",

View File

@ -18,8 +18,7 @@ import { getWebauthnCredential } from "discourse/lib/webauthn";
import { isEmpty } from "@ember/utils";
import { setting } from "discourse/lib/computed";
import showModal from "discourse/lib/show-modal";
import { helperContext } from "discourse-common/lib/helpers";
import { emojiBasePath } from "discourse/lib/settings";
import { wavingHandURL } from "discourse/lib/waving-hand-url";
// This is happening outside of the app via popup
const AuthErrors = [
@ -67,13 +66,7 @@ export default Controller.extend(ModalFunctionality, {
},
@discourseComputed()
wavingHandURL() {
const emojiSet = helperContext().siteSettings.emoji_set;
// random number between 2 -6 to render multiple skin tone waving hands
const random = Math.floor(Math.random() * (7 - 2) + 2);
return getURL(`${emojiBasePath()}/${emojiSet}/wave/${random}.png`);
},
wavingHandURL: () => wavingHandURL(),
@discourseComputed("showSecondFactor", "showSecurityKey")
secondFactorClass(showSecondFactor, showSecurityKey) {

View File

@ -0,0 +1,11 @@
import { helperContext } from "discourse-common/lib/helpers";
import { emojiBasePath } from "discourse/lib/settings";
import getURL from "discourse-common/lib/get-url";
export function wavingHandURL() {
const emojiSet = helperContext().siteSettings.emoji_set;
// random number between 2 -6 to render multiple skin tone waving hands
const random = Math.floor(Math.random() * (7 - 2) + 2);
return getURL(`${emojiBasePath()}/${emojiSet}/wave/${random}.png`);
}