From 9dd6367d816ebf01a201c85767037aab6744ac67 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 21 Jul 2020 12:10:24 -0400 Subject: [PATCH] REFACTOR: Remove `Discourse.SiteSettings` from `PostCooked` widget --- .../javascripts/discourse/app/widgets/decorator-helper.js | 2 +- .../javascripts/discourse/app/widgets/post-cooked.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/widgets/decorator-helper.js b/app/assets/javascripts/discourse/app/widgets/decorator-helper.js index dfecfd87547..7c67d99ed9e 100644 --- a/app/assets/javascripts/discourse/app/widgets/decorator-helper.js +++ b/app/assets/javascripts/discourse/app/widgets/decorator-helper.js @@ -83,7 +83,7 @@ class DecoratorHelper { * ``` **/ cooked(cooked) { - return new PostCooked({ cooked }); + return new PostCooked({ cooked }, this); } /** diff --git a/app/assets/javascripts/discourse/app/widgets/post-cooked.js b/app/assets/javascripts/discourse/app/widgets/post-cooked.js index 5f5c6e87ec4..0196b0f24ae 100644 --- a/app/assets/javascripts/discourse/app/widgets/post-cooked.js +++ b/app/assets/javascripts/discourse/app/widgets/post-cooked.js @@ -93,8 +93,12 @@ export default class PostCooked { } _fixImageSizes($html) { - const maxImageWidth = Discourse.SiteSettings.max_image_width; - const maxImageHeight = Discourse.SiteSettings.max_image_height; + if (!this.decoratorHelper || !this.decoratorHelper.widget) { + return; + } + let siteSettings = this.decoratorHelper.widget.siteSettings; + const maxImageWidth = siteSettings.max_image_width; + const maxImageHeight = siteSettings.max_image_height; let maxWindowWidth; $html.find("img:not(.avatar)").each((idx, img) => {