diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx index 2ccf5c440..0c5b56304 100644 --- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx +++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx @@ -111,7 +111,7 @@ const MetadataEditor = createClass({ handleTheme : function(theme){ this.props.metadata.renderer = theme.renderer; this.props.metadata.theme = theme.path; - this.props.onChange(this.props.metadata, "theme"); + this.props.onChange(this.props.metadata, 'theme'); }, handleLanguage : function(languageCode){ @@ -212,7 +212,7 @@ const MetadataEditor = createClass({ }; const currentThemePath = this.props.metadata?.theme && Themes[_.upperFirst(this.props.metadata.renderer)]?.hasOwnProperty(this.props.metadata?.theme) ? this.props.metadata.renderer : 'Brew'; - const currentTheme = mergedThemes[`${_.upperFirst(currentThemePath)}`]?.hasOwnProperty(this.props.metadata.theme) ? mergedThemes[`${_.upperFirst(currentThemePath)}`][this.props.metadata.theme] : { name: `!!! THEME MISSING !!! ID=${this.props.metadata.theme.slice(1)}`}; + const currentTheme = mergedThemes[`${_.upperFirst(currentThemePath)}`]?.hasOwnProperty(this.props.metadata.theme) ? mergedThemes[`${_.upperFirst(currentThemePath)}`][this.props.metadata.theme] : { name: `!!! THEME MISSING !!! ID=${this.props.metadata.theme.slice(1)}` }; let dropdown; if(this.props.metadata.renderer == 'legacy') { diff --git a/client/homebrew/editor/snippetbar/snippetbar.jsx b/client/homebrew/editor/snippetbar/snippetbar.jsx index 34687f020..af493c961 100644 --- a/client/homebrew/editor/snippetbar/snippetbar.jsx +++ b/client/homebrew/editor/snippetbar/snippetbar.jsx @@ -51,7 +51,7 @@ const Snippetbar = createClass({ }, componentDidMount : async function() { - let snippets = this.compileSnippets(); + const snippets = this.compileSnippets(); this.setState({ snippets : snippets }); @@ -59,7 +59,7 @@ const Snippetbar = createClass({ componentDidUpdate : async function(prevProps) { if(prevProps.renderer != this.props.renderer || prevProps.theme != this.props.theme || prevProps.snippetBundle != this.props.snippetBundle) { - let snippets = this.compileSnippets(); + const snippets = this.compileSnippets(); this.setState({ snippets : snippets }); @@ -78,12 +78,12 @@ const Snippetbar = createClass({ let compiledSnippets = []; let oldSnippets = _.keyBy(compiledSnippets, 'groupName'); - + for (let snippets of this.props.snippetBundle) { - if (typeof(snippets) == "string") // load staticThemes as needed; they were sent as just a file name + if(typeof(snippets) == 'string') // load staticThemes as needed; they were sent as just a file name snippets = ThemeSnippets[snippets]; - let newSnippets = _.keyBy(_.cloneDeep(snippets), 'groupName'); + const newSnippets = _.keyBy(_.cloneDeep(snippets), 'groupName'); compiledSnippets = _.values(_.mergeWith(oldSnippets, newSnippets, this.mergeCustomizer)); oldSnippets = _.keyBy(compiledSnippets, 'groupName'); diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index a36d272db..f8040d5c3 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -134,9 +134,9 @@ const EditPage = createClass({ }, handleMetaChange : function(metadata, field=undefined){ - if(field == "theme") // Fetch theme bundle only if theme was changed + if(field == 'theme') // Fetch theme bundle only if theme was changed this.fetchThemeBundle(metadata.renderer, metadata.theme); - + this.setState((prevState)=>({ brew : { ...prevState.brew, @@ -153,13 +153,13 @@ const EditPage = createClass({ // Loads the theme bundle and parses it out. Called when the iFrame is first mounted, and when a new theme is selected fetchThemeBundle : function(renderer, theme) { fetch(`${window.location.protocol}//${window.location.host}/theme/${renderer}/${theme}`).then((response)=>response.json()).then((themeBundle)=>{ - themeBundle.joinedStyles = themeBundle.styles.map(style => ``).join('\n\n'); //DOMPurify.sanitize(joinedStyles, purifyConfig); + themeBundle.joinedStyles = themeBundle.styles.map((style)=>``).join('\n\n'); //DOMPurify.sanitize(joinedStyles, purifyConfig); this.setState((prevState)=>({ // MOVE TO MOUNT STEP OF SHARE / NEW / EDIT ...prevState, themeBundle : themeBundle })); }); - + }, trySave : function(immediate=false){ diff --git a/server/homebrew.api.js b/server/homebrew.api.js index b8807a439..aa3eded0a 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -61,7 +61,7 @@ const api = { const userThemes = {}; - const brews = await HomebrewModel.getByUser(username, true, fields, { tags: { $in: ['meta:theme', 'meta:Theme'] }}); + const brews = await HomebrewModel.getByUser(username, true, fields, { tags: { $in: ['meta:theme', 'meta:Theme'] } }); if(brews) { for (const brew of brews) { @@ -269,7 +269,6 @@ const api = { const completeSnippets = []; while (req.params.id) { - console.log(`loading theme ID ${req.params.id}`) //=== User Themes ===// if(!isStaticTheme(req.params.renderer, req.params.id)) { await api.getBrew('share')(req, res, ()=>{}); @@ -282,7 +281,7 @@ const api = { req.params.id = currentTheme.theme; req.params.renderer = currentTheme.renderer; - } + } //=== Static Themes ===// else { const localSnippets = `${req.params.renderer}_${req.params.id}`; // Just log the name for loading on client diff --git a/server/homebrew.api.spec.js b/server/homebrew.api.spec.js index 5eb8a407c..67f4abe5f 100644 --- a/server/homebrew.api.spec.js +++ b/server/homebrew.api.spec.js @@ -288,14 +288,14 @@ describe('Tests for api', ()=>{ textBin : undefined, version : undefined, userThemes : { - Brew: {} + Brew : {} }, - createdAt : undefined, - gDrive : false, - style : undefined, - trashed : false, - updatedAt : undefined, - views : 0 + createdAt : undefined, + gDrive : false, + style : undefined, + trashed : false, + updatedAt : undefined, + views : 0 }); expect(next).toHaveBeenCalled(); expect(api.getId).toHaveBeenCalledWith(req);