From a9c06fd935f200749e870d93012ecc5404b69477 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Sun, 17 Jan 2021 16:25:21 +0000 Subject: [PATCH] bug fixes --- package.json | 1 + src/App.jsx | 5 +-- src/components/modals/Feedback.jsx | 44 +++++++++---------- src/components/modals/Main.jsx | 3 +- src/components/modals/Welcome.jsx | 26 +++++------ src/components/modals/settings/FileUpload.jsx | 2 + src/components/modals/settings/Section.jsx | 2 +- src/components/modals/settings/Slider.jsx | 1 + .../settings/sections/BackgroundSettings.jsx | 5 ++- .../settings/sections/GreetingSettings.jsx | 4 +- .../settings/sections/LanguageSettings.jsx | 40 ++++++++--------- src/components/modals/tabs/Addons.jsx | 3 +- src/components/modals/tabs/Marketplace.jsx | 32 +++++++++----- src/components/widgets/Widgets.jsx | 1 - .../widgets/background/Background.jsx | 2 +- .../widgets/background/Favourite.jsx | 4 +- .../widgets/background/Maximise.jsx | 3 ++ .../widgets/background/PhotoInformation.jsx | 44 +++++++++---------- src/components/widgets/greeting/Greeting.jsx | 10 ++--- src/components/widgets/navbar/Navbar.jsx | 8 ++-- src/components/widgets/navbar/Notes.jsx | 11 ++++- src/components/widgets/navbar/Pin.jsx | 17 +++---- src/components/widgets/quote/Quote.jsx | 18 +++++--- src/components/widgets/search/Search.jsx | 5 ++- src/components/widgets/time/Clock.jsx | 9 +++- src/components/widgets/time/Date.jsx | 3 +- src/modules/helpers/settings.js | 4 +- 27 files changed, 180 insertions(+), 127 deletions(-) diff --git a/package.json b/package.json index 7f9c2d59..f0af509f 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "react-toastify": "6.2.0" }, "devDependencies": { + "eslint": "^7.18.0", "node-sass": "^4.14.1", "react-scripts": "^4.0.1" }, diff --git a/src/App.jsx b/src/App.jsx index bd0e0776..6d8b10f1 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -44,7 +44,7 @@ export default class App extends React.PureComponent { document.head.insertAdjacentHTML('beforeend', ''); } - if (localStorage.getItem('darkTheme') === 'true'){ + if (localStorage.getItem('darkTheme') === 'true') { document.getElementsByClassName('Toastify')[0].classList.add('dark'); } } @@ -56,7 +56,6 @@ export default class App extends React.PureComponent { }); } - // Render all the components render() { // dark theme support for modals and info card let modalClassList = 'Modal'; @@ -78,7 +77,7 @@ export default class App extends React.PureComponent {
- this.setState({ mainModal: true })} updateModalOpen={() => this.setState({ updateModal: true })} feedbackModalOpen={() => this.setState({ feedbackModal: true })} language={language} /> + this.setState({ [modal]: true })} language={language} /> diff --git a/src/components/modals/Feedback.jsx b/src/components/modals/Feedback.jsx index 4f5b847a..5cc99fdd 100644 --- a/src/components/modals/Feedback.jsx +++ b/src/components/modals/Feedback.jsx @@ -1,25 +1,25 @@ import React from 'react'; -export default class Feedback extends React.PureComponent { - render() { - return ( -
-

Give us feedback

- × - -

- -

- -

- -

- -

- -


- -
- ); - } +const FeedbackModal = () => { + return ( +
+

Give us feedback

+ × + +

+ +

+ +

+ +

+ +

+ +


+ +
+ ); } + +export default FeedbackModal; \ No newline at end of file diff --git a/src/components/modals/Main.jsx b/src/components/modals/Main.jsx index 9f65db61..d341723b 100644 --- a/src/components/modals/Main.jsx +++ b/src/components/modals/Main.jsx @@ -41,7 +41,8 @@ export default class MainModal extends React.PureComponent { document.getElementById(input + 'TabLink').classList.toggle('active'); this.setState({ - tab: this.tabs[input], currentTab: input + tab: this.tabs[input], + currentTab: input }); } diff --git a/src/components/modals/Welcome.jsx b/src/components/modals/Welcome.jsx index bcc150ea..ba6faabd 100644 --- a/src/components/modals/Welcome.jsx +++ b/src/components/modals/Welcome.jsx @@ -3,25 +3,25 @@ import EmailIcon from '@material-ui/icons/Email'; import TwitterIcon from '@material-ui/icons/Twitter'; import ForumIcon from '@material-ui/icons/Forum'; -export default class Welcome extends React.PureComponent { - render() { - return ( -
- × +const WelcomeModal = (props) => { + return ( +
+ ×
-

{this.props.language.title}

+

{props.language.title}

Mue Tab

celebration -

{this.props.language.information}

-

{this.props.language.thankyoumessage1},
{this.props.language.thankyoumessage2}

-

{this.props.language.support}

+

{props.language.information}

+

{props.language.thankyoumessage1},
{props.language.thankyoumessage2}

+

{props.language.support}


- +
- ); - } -} \ No newline at end of file + ); +} + +export default WelcomeModal; \ No newline at end of file diff --git a/src/components/modals/settings/FileUpload.jsx b/src/components/modals/settings/FileUpload.jsx index 59ffdcc6..46c9bb43 100644 --- a/src/components/modals/settings/FileUpload.jsx +++ b/src/components/modals/settings/FileUpload.jsx @@ -13,8 +13,10 @@ export default class FileUpload extends React.PureComponent { if (file.size > 2000000) { return toast('File is over 2MB'); } + reader.readAsDataURL(file); } + reader.addEventListener('load', (e) => this.props.loadFunction(e)); }; } diff --git a/src/components/modals/settings/Section.jsx b/src/components/modals/settings/Section.jsx index 1efb93b6..b05f7693 100644 --- a/src/components/modals/settings/Section.jsx +++ b/src/components/modals/settings/Section.jsx @@ -46,7 +46,7 @@ export default class Section extends React.PureComponent { slider = ; } - if (this.props.dropdown === false){ + if (this.props.dropdown === false) { noDropdown = 'nodropdown'; } diff --git a/src/components/modals/settings/Slider.jsx b/src/components/modals/settings/Slider.jsx index bbe11107..887499b5 100644 --- a/src/components/modals/settings/Slider.jsx +++ b/src/components/modals/settings/Slider.jsx @@ -11,6 +11,7 @@ export default class Slider extends React.PureComponent { handleChange(name) { SettingsFunctions.setItem(name); + this.setState({ checked: (this.state.checked === true) ? false : true }); diff --git a/src/components/modals/settings/sections/BackgroundSettings.jsx b/src/components/modals/settings/sections/BackgroundSettings.jsx index 1f00d22e..0076bb22 100644 --- a/src/components/modals/settings/sections/BackgroundSettings.jsx +++ b/src/components/modals/settings/sections/BackgroundSettings.jsx @@ -190,7 +190,10 @@ export default class BackgroundSettings extends React.PureComponent { let gradientInputs; if (gradientHasMoreThanOneColour) { - if (this.GradientPickerInitalState === undefined) this.InitializeColorPickerState(this.state.gradientSettings); + if (this.GradientPickerInitalState === undefined) { + this.InitializeColorPickerState(this.state.gradientSettings); + } + gradientInputs = ( this.onColorPickerChange(color, 'start')} diff --git a/src/components/modals/settings/sections/GreetingSettings.jsx b/src/components/modals/settings/sections/GreetingSettings.jsx index e89d2df7..3f2e9f73 100644 --- a/src/components/modals/settings/sections/GreetingSettings.jsx +++ b/src/components/modals/settings/sections/GreetingSettings.jsx @@ -15,7 +15,9 @@ export default class GreetingSettings extends React.PureComponent { } resetItem() { - this.setState({ greetingName: '' }); + this.setState({ + greetingName: '' + }); toast(this.props.toastLanguage.reset); } diff --git a/src/components/modals/settings/sections/LanguageSettings.jsx b/src/components/modals/settings/sections/LanguageSettings.jsx index 4f916c19..5e4ab9e2 100644 --- a/src/components/modals/settings/sections/LanguageSettings.jsx +++ b/src/components/modals/settings/sections/LanguageSettings.jsx @@ -1,23 +1,23 @@ import React from 'react'; import Dropdown from '../Dropdown'; -export default class LanguageSettings extends React.PureComponent { - render() { - return ( -
-

{this.props.language.language}

- localStorage.setItem('language', document.getElementById('language').value)} > - - - - - - - -
- ); - } -} \ No newline at end of file +const LanguageSettings = (props) => { + return ( +
+

{props.language.language}

+ localStorage.setItem('language', document.getElementById('language').value)} > + + + + + + + +
+ ); +} + +export default LanguageSettings; \ No newline at end of file diff --git a/src/components/modals/tabs/Addons.jsx b/src/components/modals/tabs/Addons.jsx index c40fac60..3709a757 100644 --- a/src/components/modals/tabs/Addons.jsx +++ b/src/components/modals/tabs/Addons.jsx @@ -58,6 +58,7 @@ export default class Addons extends React.PureComponent { document.getElementById('marketplace').style.display = 'block'; document.getElementById('item').style.display = 'none'; } + this.setState({ button: this.buttons.uninstall }); @@ -78,7 +79,7 @@ export default class Addons extends React.PureComponent { toast(this.props.toastLanguage[type + 'ed']); let button = ''; - if (type === 'install'){ + if (type === 'install') { button = this.buttons.uninstall; } diff --git a/src/components/modals/tabs/Marketplace.jsx b/src/components/modals/tabs/Marketplace.jsx index 5c24ce83..3bd42cc0 100644 --- a/src/components/modals/tabs/Marketplace.jsx +++ b/src/components/modals/tabs/Marketplace.jsx @@ -81,7 +81,7 @@ export default class Marketplace extends React.PureComponent { this.setState({ button: button - }); + }); document.getElementById('marketplace').style.display = 'none'; document.getElementById('seemore').style.display = 'none'; @@ -97,14 +97,14 @@ export default class Marketplace extends React.PureComponent { } async getItems() { - const data = await (await fetch(Constants.MARKETPLACE_URL + '/all')).json(); + const { data }= await (await fetch(Constants.MARKETPLACE_URL + '/all')).json(); const featured = await (await fetch(Constants.MARKETPLACE_URL + '/featured')).json(); this.setState({ - settings: data.data.settings, - photo_packs: data.data.photo_packs, - quote_packs: data.data.quote_packs, - see_more: data.data.photo_packs, + settings: data.settings, + photo_packs: data.photo_packs, + quote_packs: data.quote_packs, + see_more: data.photo_packs, featured: featured.data, done: true }); @@ -133,7 +133,7 @@ export default class Marketplace extends React.PureComponent { document.getElementById('marketplace').classList.add('marketplaceanimation'); } - if (navigator.onLine === false) { + if (navigator.onLine === false || localStorage.getItem('offlineMode') === 'true') { return; } @@ -141,7 +141,7 @@ export default class Marketplace extends React.PureComponent { } render() { - const returnMessage = (msg) => { + const errorMessage = (msg) => { return (
@@ -152,7 +152,7 @@ export default class Marketplace extends React.PureComponent { } if (navigator.onLine === false) { - return returnMessage( + return errorMessage(

{this.props.language.offline.title}

@@ -161,7 +161,19 @@ export default class Marketplace extends React.PureComponent { ); } - if (this.state.done === false) return returnMessage(

{this.props.updateLanguage.loading}

); + if (localStorage.getItem('offlineMode') === 'true') { + return errorMessage( + + +

Offline mode is enabled

+

Please turn off offline mode to access the marketplace

+
+ ); + } + + if (this.state.done === false) { + return errorMessage(

{this.props.updateLanguage.loading}

); + } return ( diff --git a/src/components/widgets/Widgets.jsx b/src/components/widgets/Widgets.jsx index ba75a109..89453848 100644 --- a/src/components/widgets/Widgets.jsx +++ b/src/components/widgets/Widgets.jsx @@ -26,7 +26,6 @@ export default class Widgets extends React.PureComponent { return enabled; } - // Render all the components render() { const { language, languagecode } = this.props; const enabled = this.enabled; diff --git a/src/components/widgets/background/Background.jsx b/src/components/widgets/background/Background.jsx index c7f8fc8d..5bb0eeb4 100644 --- a/src/components/widgets/background/Background.jsx +++ b/src/components/widgets/background/Background.jsx @@ -72,7 +72,7 @@ export default class Background extends React.PureComponent { this.setBackground(url); this.setCredit(photographer); - document.querySelector('#backgroundCredits').style.display = 'none'; // Hide the location icon + //document.querySelector('#backgroundCredits').style.display = 'none'; // Hide the location icon } async determineMode() { diff --git a/src/components/widgets/background/Favourite.jsx b/src/components/widgets/background/Favourite.jsx index aeeea846..f3df9bf4 100644 --- a/src/components/widgets/background/Favourite.jsx +++ b/src/components/widgets/background/Favourite.jsx @@ -13,7 +13,9 @@ export default class Favourite extends React.PureComponent { favourite() { if (localStorage.getItem('favourite')) { localStorage.removeItem('favourite'); - this.setState({ favourited: this.favourite()} /> }); + this.setState({ + favourited: this.favourite()} /> + }); } else { const url = document.getElementById('backgroundImage').style.backgroundImage.replace('url("', '').replace('")', ''); const credit = document.getElementById('credit').textContent; diff --git a/src/components/widgets/background/Maximise.jsx b/src/components/widgets/background/Maximise.jsx index 1ab697d9..4538aed4 100644 --- a/src/components/widgets/background/Maximise.jsx +++ b/src/components/widgets/background/Maximise.jsx @@ -18,6 +18,7 @@ export default class View extends React.PureComponent { viewStuff() { const elements = ['#searchBar', '.navbar-container', '.clock', '.greeting', '.quotediv', 'time']; // elements to hide + elements.forEach((element) => { try { (this.state.hidden === false) ? document.querySelector(element).style.display = 'none' : document.querySelector(element).style.display = 'block'; @@ -30,11 +31,13 @@ export default class View extends React.PureComponent { this.setState({ hidden: true }); + this.setAttribute(0, 100); } else { this.setState({ hidden: false }); + this.setAttribute(localStorage.getItem('blur'), localStorage.getItem('brightness')); } } diff --git a/src/components/widgets/background/PhotoInformation.jsx b/src/components/widgets/background/PhotoInformation.jsx index 81c9a6b8..65eb8681 100644 --- a/src/components/widgets/background/PhotoInformation.jsx +++ b/src/components/widgets/background/PhotoInformation.jsx @@ -5,27 +5,27 @@ import Camera from '@material-ui/icons/PhotoCamera'; import Resolution from '@material-ui/icons/Crop'; import Photographer from '@material-ui/icons/Person'; -export default class PhotoInformation extends React.PureComponent { - render() { - return ( -
-

{this.props.language.credit}

- -
- -

{this.props.language.information}

-
- - - - - - - - -
- +const PhotoInformation = (props) => { + return ( +
+

{props.language.credit}

+ +
+ +

{props.language.information}

+
+ + + + + + + +
- ); - } + +
+ ); } + +export default PhotoInformation; \ No newline at end of file diff --git a/src/components/widgets/greeting/Greeting.jsx b/src/components/widgets/greeting/Greeting.jsx index 681fab08..4c2768e9 100644 --- a/src/components/widgets/greeting/Greeting.jsx +++ b/src/components/widgets/greeting/Greeting.jsx @@ -16,14 +16,14 @@ export default class Greeting extends React.PureComponent { } // Get current month & day - const m = time.getMonth(); - const d = time.getDate(); + const month = time.getMonth(); + const date = time.getDate(); - if (m === 11 && d === 25) { + if (month === 11 && date === 25) { message = this.props.language.christmas; // If it's December 25th, set the greeting string to "Merry Christmas" - } else if (m === 0 && d === 1) { + } else if (month === 0 && date === 1) { message = this.props.language.newyear; // If the date is January 1st, set the greeting string to "Happy new year" - } else if (m === 9 && d === 31) { + } else if (month === 9 && date === 31) { message = this.props.language.halloween; // If it's October 31st, set the greeting string to "Happy Halloween" } diff --git a/src/components/widgets/navbar/Navbar.jsx b/src/components/widgets/navbar/Navbar.jsx index 29d03c79..e25544f3 100644 --- a/src/components/widgets/navbar/Navbar.jsx +++ b/src/components/widgets/navbar/Navbar.jsx @@ -30,11 +30,11 @@ export default class Navbar extends React.PureComponent { // toggle feedback button let feedbackHTML = ( - + this.props.openModal('feedbackModal')} /> ); - if (Constants.BETA_VERSION === false){ + if (Constants.BETA_VERSION === false) { feedbackHTML = null; } @@ -48,11 +48,11 @@ export default class Navbar extends React.PureComponent {
{feedbackHTML} - + this.props.openModal('updateModal')} /> {refreshHTML} - + this.props.openModal('mainModal')} />
); diff --git a/src/components/widgets/navbar/Notes.jsx b/src/components/widgets/navbar/Notes.jsx index 925e572d..083dc921 100644 --- a/src/components/widgets/navbar/Notes.jsx +++ b/src/components/widgets/navbar/Notes.jsx @@ -14,12 +14,19 @@ export default class Notes extends React.PureComponent { setNotes = (e) => { localStorage.setItem('notes', e.target.value); - this.setState({ notes: e.target.value }); + this.setState({ + notes: e.target.value + }); }; pin() { document.getElementById('noteContainer').classList.toggle('visibilityshow'); - (localStorage.getItem('notesPinned') === 'true') ? localStorage.setItem('notesPinned', false) : localStorage.setItem('notesPinned', true); + + if (localStorage.getItem('notesPinned') === 'true') { + localStorage.setItem('notesPinned', false); + } else { + localStorage.setItem('notesPinned', true); + } } componentDidMount() { diff --git a/src/components/widgets/navbar/Pin.jsx b/src/components/widgets/navbar/Pin.jsx index 70cd7d8d..ac168787 100644 --- a/src/components/widgets/navbar/Pin.jsx +++ b/src/components/widgets/navbar/Pin.jsx @@ -14,14 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ - import React from 'react'; -export default class Pin extends React.PureComponent { - render() { - return - - - ; - } +const Pin = () => { + return ( + + + + + ); } + +export default Pin; \ No newline at end of file diff --git a/src/components/widgets/quote/Quote.jsx b/src/components/widgets/quote/Quote.jsx index 22dc91a5..6a9da3fe 100644 --- a/src/components/widgets/quote/Quote.jsx +++ b/src/components/widgets/quote/Quote.jsx @@ -118,19 +118,27 @@ export default class Quote extends React.PureComponent { componentDidMount() { if (localStorage.getItem('favouriteQuote')) { - this.setState({ favourited: this.favourite()} /> }); + this.setState({ + favourited: this.favourite()} /> + }); } if (localStorage.getItem('favouriteQuoteEnabled') === 'false') { - this.setState({ favourited: null }); + this.setState({ + favourited: null + }); } if (localStorage.getItem('copyButton') === 'false') { - this.setState({ copy: null }); + this.setState({ + copy: null + }); } - if (localStorage.getItem('tweetEnabled') === 'false') { - this.setState({ tweet: null }); + if (localStorage.getItem('tweetButton') === 'false') { + this.setState({ + tweet: null + }); } this.getQuote(); diff --git a/src/components/widgets/search/Search.jsx b/src/components/widgets/search/Search.jsx index 3a769f10..c1b9a357 100644 --- a/src/components/widgets/search/Search.jsx +++ b/src/components/widgets/search/Search.jsx @@ -33,12 +33,15 @@ export default class Search extends React.PureComponent { const setting = localStorage.getItem('searchEngine'); const info = searchEngines.find(i => i.settingsName === setting); + if (info !== undefined) { url = info.url; if (info.query) query = info.query; } - if (setting === 'custom') url = localStorage.getItem('customSearchEngine'); + if (setting === 'custom') { + url = localStorage.getItem('customSearchEngine'); + } const searchButton = () => { const value = document.getElementById('searchtext').value || 'mue fast'; diff --git a/src/components/widgets/time/Clock.jsx b/src/components/widgets/time/Clock.jsx index 0d880f18..3a903847 100644 --- a/src/components/widgets/time/Clock.jsx +++ b/src/components/widgets/time/Clock.jsx @@ -20,12 +20,15 @@ export default class Clock extends React.PureComponent { // Percentage if (localStorage.getItem('percentageComplete') === 'true') { - return this.setState({ time: (now.getHours() / 24).toFixed(2).replace('0.', '') + '%'}); + return this.setState({ + time: (now.getHours() / 24).toFixed(2).replace('0.', '') + '%' + }); } // Analog clock if (localStorage.getItem('analog') === 'true') { require('react-clock/dist/Clock.css'); // load analog clock css + this.setState({ time: now }); @@ -49,7 +52,9 @@ export default class Clock extends React.PureComponent { time = `${('00' + now.getHours()).slice(-2)}:${('00' + now.getMinutes()).slice(-2)}${sec}`; } - this.setState({ time: time }); + this.setState({ + time: time + }); } else { // 12 hour support let hours = now.getHours(); diff --git a/src/components/widgets/time/Date.jsx b/src/components/widgets/time/Date.jsx index 7740058f..c302d779 100644 --- a/src/components/widgets/time/Date.jsx +++ b/src/components/widgets/time/Date.jsx @@ -31,7 +31,8 @@ export default class DateWidget extends React.PureComponent { day = dateYear; year = dateDay; break; - default: break; // DMY + default: + break; // DMY } let format; diff --git a/src/modules/helpers/settings.js b/src/modules/helpers/settings.js index cda78da8..c3aab985 100644 --- a/src/modules/helpers/settings.js +++ b/src/modules/helpers/settings.js @@ -1,7 +1,9 @@ const defaultSettings = require('../default_settings.json'); const saveFile = (data, filename = 'file') => { - if (typeof data === 'object') data = JSON.stringify(data, undefined, 4); + if (typeof data === 'object') { + data = JSON.stringify(data, undefined, 4); + } const blob = new Blob([data], { type: 'text/json' }); let e = document.createEvent('MouseEvents');