From 71a4e9db854300b9219a52c7c725cd3faf8aba53 Mon Sep 17 00:00:00 2001 From: Isaac Janzen <50783505+janzenisaac@users.noreply.github.com> Date: Wed, 4 May 2022 09:37:42 -0500 Subject: [PATCH] DEV: Use Ember getter and explicitly check for undefined (#16618) Context -> https://deprecations.emberjs.com/v3.x/#toc_ember-metal-get-with-default --- .../discourse/app/components/d-editor.js | 4 +++- .../javascripts/discourse/app/mixins/uppy-upload.js | 13 ++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js index afae9e0428e..37d570b2684 100644 --- a/app/assets/javascripts/discourse/app/components/d-editor.js +++ b/app/assets/javascripts/discourse/app/components/d-editor.js @@ -546,10 +546,12 @@ export default Component.extend(TextareaTextManipulation, { // note this will only work for emojis starting with : // eg: :-) + const emojiTranslation = + this.get("site.custom_emoji_translation") || {}; const allTranslations = Object.assign( {}, translations, - this.getWithDefault("site.custom_emoji_translation", {}) + emojiTranslation ); if (allTranslations[full]) { return resolve([allTranslations[full]]); diff --git a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js index 0807f98f40e..59f04690451 100644 --- a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js +++ b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js @@ -120,10 +120,8 @@ export default Mixin.create(UppyS3Multipart, ExtendableUploader, { onBeforeUpload: (files) => { let tooMany = false; const fileCount = Object.keys(files).length; - const maxFiles = this.getWithDefault( - "maxFiles", - this.siteSettings.simultaneous_uploads - ); + const maxFiles = + this.maxFiles || this.siteSettings.simultaneous_uploads; if (this.allowMultipleFiles) { tooMany = maxFiles > 0 && fileCount > maxFiles; @@ -396,11 +394,8 @@ export default Mixin.create(UppyS3Multipart, ExtendableUploader, { }, _xhrUploadUrl() { - return ( - getUrl(this.getWithDefault("uploadUrl", this.uploadRootPath)) + - ".json?client_id=" + - this.messageBus?.clientId - ); + const uploadUrl = this.uploadUrl || this.uploadRootPath; + return getUrl(uploadUrl) + ".json?client_id=" + this.messageBus?.clientId; }, _bindFileInputChange() {