Skip to content

A platform for community discussion. Free, open, simple.

DEV: DRY up wavingHandUrl code.

Alan Guo Xiang Tan4a41f72f09c8
diff --git a/app/assets/javascripts/discourse/app/controllers/create-account.js b/app/assets/javascripts/discourse/app/controllers/create-account.js
index 1799033a684..5b9de9130e9 100644
--- a/app/assets/javascripts/discourse/app/controllers/create-account.js
+++ b/app/assets/javascripts/discourse/app/controllers/create-account.js
@@ -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",
diff --git a/app/assets/javascripts/discourse/app/controllers/login.js b/app/assets/javascripts/discourse/app/controllers/login.js
index a1ff3240b92..ada901c7d01 100644
--- a/app/assets/javascripts/discourse/app/controllers/login.js
+++ b/app/assets/javascripts/discourse/app/controllers/login.js
@@ -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) {
diff --git a/app/assets/javascripts/discourse/app/lib/waving-hand-url.js b/app/assets/javascripts/discourse/app/lib/waving-hand-url.js
new file mode 100644
index 00000000000..8078cb0c295
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/lib/waving-hand-url.js
@@ -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`);
+}