REFACTOR: Remove `Discourse.SiteSettings` from upload.js

REFACTOR: Remove Discourse.SiteSettings from upload.js

diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js
index 46dbadd..a8d7849 100644
--- a/app/assets/javascripts/discourse/app/components/composer-editor.js
+++ b/app/assets/javascripts/discourse/app/components/composer-editor.js
@@ -766,7 +766,7 @@ export default Component.extend({
       this._xhr = null;
 
       if (!userCancelled) {
-        displayErrorForUpload(data);
+        displayErrorForUpload(data, this.siteSettings);
       }
     });
 
diff --git a/app/assets/javascripts/discourse/app/lib/uploads.js b/app/assets/javascripts/discourse/app/lib/uploads.js
index 22776a4..83bc9ec 100644
--- a/app/assets/javascripts/discourse/app/lib/uploads.js
+++ b/app/assets/javascripts/discourse/app/lib/uploads.js
@@ -266,7 +266,7 @@ export function getUploadMarkdown(upload) {
   }
 }
 
-export function displayErrorForUpload(data) {
+export function displayErrorForUpload(data, siteSettings) {
   if (data.jqXHR) {
     switch (data.jqXHR.status) {
       // cancelled by the user
@@ -276,7 +276,7 @@ export function displayErrorForUpload(data) {
       // entity too large, usually returned from the web server
       case 413:
         const type = uploadTypeFromFileName(data.files[0].name);
-        const max_size_kb = Discourse.SiteSettings[`max_${type}_size_kb`];
+        const max_size_kb = siteSettings[`max_${type}_size_kb`];
         bootbox.alert(I18n.t("post.errors.file_too_large", { max_size_kb }));
         return;
 
diff --git a/app/assets/javascripts/discourse/app/mixins/upload.js b/app/assets/javascripts/discourse/app/mixins/upload.js
index 1c6b026..968313a 100644
--- a/app/assets/javascripts/discourse/app/mixins/upload.js
+++ b/app/assets/javascripts/discourse/app/mixins/upload.js
@@ -107,7 +107,7 @@ export default Mixin.create({
 
     $upload.on("fileuploadfail", (e, data) => {
       if (!data || data.errorThrown !== "abort") {
-        displayErrorForUpload(data);
+        displayErrorForUpload(data, this.siteSettings);
       }
       reset();
     });

GitHub sha: 5077cf52

1 Like