fix: new radio buttons, fix background bugs etc

Co-authored-by: Alex Sparkes <turbomarshmello@gmail.com>
This commit is contained in:
David Ralph
2021-03-20 15:52:27 +00:00
parent ab7681f3d0
commit e092c805e8
14 changed files with 120 additions and 73 deletions

View File

@@ -100,10 +100,10 @@ export default class Background extends React.PureComponent {
if (customBackgroundColour !== 'Disabled' && customBackgroundColour !== '') {
let gradientSettings = '';
try {
gradientSettings = JSON.parse(colour);
gradientSettings = JSON.parse(customBackgroundColour);
} catch (e) {
const hexColorRegex = /#[0-9a-fA-F]{6}/s;
if (hexColorRegex.exec(colour)) {
if (hexColorRegex.exec(customBackgroundColour)) {
// Colour use to be simply a hex colour or a NULL value before it was a JSON object. This automatically upgrades the hex colour value to the new standard. (NULL would not trigger an exception)
gradientSettings = { "type": "linear", "angle": "180", "gradient": [{ "colour": colour, "stop": 0 }] };
localStorage.setItem('customBackgroundColour', JSON.stringify(gradientSettings));

View File

@@ -57,6 +57,10 @@ export default class Quote extends React.PureComponent {
}
async getQuote() {
if (localStorage.getItem('offlineMode') === 'true') {
return this.doOffline();
}
const quotePackAPI = JSON.parse(localStorage.getItem('quoteAPI'));
if (quotePackAPI) {
try {
@@ -86,10 +90,6 @@ export default class Quote extends React.PureComponent {
});
}
if (localStorage.getItem('offlineMode') === 'true') {
return this.doOffline();
}
// First we try and get a quote from the API...
try {
const data = await (await fetch(window.constants.API_URL + '/getQuote?language=' + localStorage.getItem('quotelanguage'))).json();