From e2e51ee3484d80a84806131c330a0aac5915c47c Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 17 Aug 2020 16:33:57 -0400 Subject: [PATCH] FIX: Refactor broke wizard --- .../discourse-common/addon/lib/icon-library.js | 13 +++++++------ .../app/pre-initializers/discourse-bootstrap.js | 3 ++- .../app/pre-initializers/svg-sprite-fontawesome.js | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse-common/addon/lib/icon-library.js b/app/assets/javascripts/discourse-common/addon/lib/icon-library.js index 0bf8d8678bb..acbd7b18cee 100644 --- a/app/assets/javascripts/discourse-common/addon/lib/icon-library.js +++ b/app/assets/javascripts/discourse-common/addon/lib/icon-library.js @@ -1,12 +1,12 @@ import I18n from "I18n"; import { h } from "virtual-dom"; import attributeHook from "discourse-common/lib/attribute-hook"; -import Session from "discourse/models/session"; const SVG_NAMESPACE = "http://www.w3.org/2000/svg"; let _renderers = []; let warnMissingIcons = true; +let _iconList; const REPLACEMENTS = { "d-tracking": "bell", @@ -110,12 +110,13 @@ function iconClasses(icon, params) { return classNames; } +export function setIconList(iconList) { + _iconList = iconList; +} + function warnIfMissing(id) { - if (warnMissingIcons) { - let iconList = Session.currentProp("svgIconList"); - if (iconList && iconList.indexOf(id) === -1) { - console.warn(`The icon "${id}" is missing from the SVG subset.`); // eslint-disable-line no-console - } + if (warnMissingIcons && _iconList && _iconList.indexOf(id) === -1) { + console.warn(`The icon "${id}" is missing from the SVG subset.`); // eslint-disable-line no-console } } diff --git a/app/assets/javascripts/discourse/app/pre-initializers/discourse-bootstrap.js b/app/assets/javascripts/discourse/app/pre-initializers/discourse-bootstrap.js index 6695428969e..86e935442a1 100644 --- a/app/assets/javascripts/discourse/app/pre-initializers/discourse-bootstrap.js +++ b/app/assets/javascripts/discourse/app/pre-initializers/discourse-bootstrap.js @@ -10,6 +10,7 @@ import { } from "discourse-common/config/environment"; import { setupURL, setupS3CDN } from "discourse-common/lib/get-url"; import deprecated from "discourse-common/lib/deprecated"; +import { setIconList } from "discourse-common/lib/icon-library"; export default { name: "discourse-bootstrap", @@ -100,7 +101,7 @@ export default { Session.currentProp("svgSpritePath", setupData.svgSpritePath); if (isDevelopment()) { - Session.currentProp("svgIconList", setupData.svgIconList); + setIconList(setupData.svgIconList); } if (setupData.s3BaseUrl) { diff --git a/app/assets/javascripts/discourse/app/pre-initializers/svg-sprite-fontawesome.js b/app/assets/javascripts/discourse/app/pre-initializers/svg-sprite-fontawesome.js index 72aff84c020..686a9e6b5cc 100644 --- a/app/assets/javascripts/discourse/app/pre-initializers/svg-sprite-fontawesome.js +++ b/app/assets/javascripts/discourse/app/pre-initializers/svg-sprite-fontawesome.js @@ -2,6 +2,7 @@ import { loadSprites } from "discourse/lib/svg-sprite-loader"; export default { name: "svg-sprite-fontawesome", + after: "discourse-bootstrap", initialize(container) { let session = container.lookup("session:main");