mirror of
https://github.com/mue/mue.git
synced 2026-07-10 22:14:39 +02:00
fix: some bug fixes
This commit is contained in:
@@ -5,7 +5,8 @@ import Navbar from '../widgets/navbar/Navbar';
|
||||
|
||||
import Modal from 'react-modal';
|
||||
|
||||
// Modals are lazy loaded as the user won't use them every time they open a tab
|
||||
// These modals are lazy loaded as the user won't use them every time they open a tab
|
||||
// We used to lazy load the main modal, but doing so broke the main modal open animation on first click
|
||||
const Welcome = React.lazy(() => import('./welcome/Welcome'));
|
||||
const Feedback = React.lazy(() => import('./feedback/Feedback'));
|
||||
const renderLoader = () => <></>;
|
||||
|
||||
@@ -4,6 +4,7 @@ import Tabs from './tabs/backend/Tabs';
|
||||
|
||||
import './scss/index.scss';
|
||||
|
||||
// Lazy load all the tabs instead of the modal itself
|
||||
const Settings = React.lazy(() => import('./tabs/Settings'));
|
||||
const Addons = React.lazy(() => import('./tabs/Addons'));
|
||||
const Marketplace = React.lazy(() => import('./tabs/Marketplace'));
|
||||
|
||||
@@ -39,7 +39,7 @@ export default function Item(props) {
|
||||
<img alt='product' draggable='false' src={iconsrc}/>
|
||||
<div className='informationContainer'>
|
||||
<h1>{language.overview}</h1>
|
||||
<p className='description' dangerouslySetInnerHTML={{__html: props.data.description}}></p>
|
||||
<p className='description' dangerouslySetInnerHTML={{ __html: props.data.description }}></p>
|
||||
<div className='productInformation'>
|
||||
<ul>
|
||||
{/* <li className='header'>{language.last_updated}</li>
|
||||
|
||||
@@ -66,7 +66,7 @@ export default class Added extends React.PureComponent {
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
MarketplaceFunctions.uninstall(this.state.item.display_name, this.state.item.type);
|
||||
MarketplaceFunctions.uninstall(this.state.item.type, this.state.item.display_name);
|
||||
|
||||
toast(window.language.toasts.uninstalled);
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ export default class Marketplace extends React.PureComponent {
|
||||
if (type === 'install') {
|
||||
MarketplaceFunctions.install(this.state.item.type, this.state.item.data);
|
||||
} else {
|
||||
MarketplaceFunctions.uninstall(this.state.item.display_name, this.state.item.type);
|
||||
MarketplaceFunctions.uninstall(this.state.item.type, this.state.item.display_name);
|
||||
}
|
||||
|
||||
toast(window.language.toasts[type + 'ed']);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@import '../../../../scss/variables';
|
||||
@import '../../../../scss/mixins';
|
||||
|
||||
@import 'settings/main';
|
||||
@import 'settings/buttons';
|
||||
|
||||
@@ -19,7 +19,9 @@ export default class FileUpload extends React.PureComponent {
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
reader.addEventListener('load', (e) => this.props.loadFunction(e));
|
||||
reader.addEventListener('load', (e) => {
|
||||
this.props.loadFunction(e);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export default class Slider extends React.PureComponent {
|
||||
value: this.props.default
|
||||
});
|
||||
|
||||
toast(this.language.toasts.reset);
|
||||
toast(window.language.toasts.reset);
|
||||
EventBus.dispatch('refresh', this.props.category);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export default class Text extends React.PureComponent {
|
||||
value: this.props.default || ''
|
||||
});
|
||||
|
||||
toast(this.language.toasts.reset);
|
||||
toast(window.language.toasts.reset);
|
||||
EventBus.dispatch('refresh', this.props.category);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ export default class About extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (localStorage.getItem('offlineMode') === 'true') {
|
||||
if (navigator.onLine === false || localStorage.getItem('offlineMode') === 'true') {
|
||||
this.setState({
|
||||
update: this.language.version.offline_mode
|
||||
});
|
||||
|
||||
@@ -22,9 +22,9 @@ export default class AdvancedSettings extends React.PureComponent {
|
||||
settingsImport(e) {
|
||||
const content = JSON.parse(e.target.result);
|
||||
|
||||
for (const key of Object.keys(content)) {
|
||||
Object.keys(content).forEach((key) => {
|
||||
localStorage.setItem(key, content[key]);
|
||||
}
|
||||
});
|
||||
|
||||
toast(window.language.toasts.imported);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export default class Changelog extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (localStorage.getItem('offlineMode') === 'true') {
|
||||
if (navigator.onLine || localStorage.getItem('offlineMode') === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ export default class OrderSettings extends React.PureComponent {
|
||||
items: JSON.parse(localStorage.getItem('order'))
|
||||
});
|
||||
|
||||
toast(this.language.toasts.reset);
|
||||
toast(window.language.toasts.reset);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
|
||||
@@ -30,18 +30,12 @@ export default class BackgroundSettings extends React.PureComponent {
|
||||
this.setState({
|
||||
customBackground: ''
|
||||
});
|
||||
toast(this.language.toasts.reset);
|
||||
toast(window.language.toasts.reset);
|
||||
EventBus.dispatch('refresh', 'background');
|
||||
}
|
||||
|
||||
customBackground(e, text) {
|
||||
let result;
|
||||
if (text === true) {
|
||||
result = e.target.value;
|
||||
} else {
|
||||
result = e.target.result;
|
||||
}
|
||||
|
||||
const result = (text === true) ? e.target.value : e.target.result;
|
||||
localStorage.setItem('customBackground', result);
|
||||
this.setState({
|
||||
customBackground: result
|
||||
@@ -83,6 +77,10 @@ export default class BackgroundSettings extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (navigator.onLine === false || localStorage.getItem('offlineMode') === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.getBackgroundCategories();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// warning: the code here is fairly messy and probably needs a rewrite
|
||||
import React from 'react';
|
||||
|
||||
import EventBus from '../../../modules/helpers/eventbus';
|
||||
|
||||
@@ -32,7 +32,8 @@ export default class Favourite extends React.PureComponent {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (localStorage.getItem('backgroundType') === 'colour') {
|
||||
const backgroundType = localStorage.getItem('backgroundType');
|
||||
if (backgroundType === 'colour' || backgroundType === 'custom') {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,10 @@ export default class View extends React.PureComponent {
|
||||
}
|
||||
|
||||
setAttribute(blur, brightness) {
|
||||
document.querySelector('#backgroundImage').setAttribute(
|
||||
const element = document.getElementById('backgroundImage');
|
||||
element.setAttribute(
|
||||
'style',
|
||||
`background-image: url(${document.getElementById('backgroundImage').style.backgroundImage.replace('url("', '').replace('")', '')}); -webkit-filter: blur(${blur}px) brightness(${brightness}%);`
|
||||
`background-image: url(${element.style.backgroundImage.replace('url("', '').replace('")', '')}); -webkit-filter: blur(${blur}px) brightness(${brightness}%);`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@
|
||||
border: none;
|
||||
}
|
||||
|
||||
&:hover, span {
|
||||
&:hover,
|
||||
span {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
export default class EventBus {
|
||||
static on(event, callback) {
|
||||
document.addEventListener(event, (e) => callback(e.detail));
|
||||
document.addEventListener(event, (e) => {
|
||||
callback(e.detail);
|
||||
});
|
||||
}
|
||||
|
||||
static dispatch(event, data) {
|
||||
|
||||
@@ -4,17 +4,19 @@ import EventBus from './eventbus';
|
||||
|
||||
export default class MarketplaceFunctions {
|
||||
// based on https://stackoverflow.com/questions/37684/how-to-replace-plain-urls-with-links
|
||||
static urlParser (input) {
|
||||
static urlParser(input) {
|
||||
const urlPattern = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_+.~#?&//=]*)/;
|
||||
return input.replace(urlPattern, '<a href="$&" target="_blank">$&</a>');
|
||||
}
|
||||
|
||||
static uninstall(name, type) {
|
||||
static uninstall(type, name) {
|
||||
switch (type) {
|
||||
case 'settings':
|
||||
const oldSettings = JSON.parse(localStorage.getItem('backup_settings'));
|
||||
localStorage.clear();
|
||||
oldSettings.forEach((item) => localStorage.setItem(item.name, item.value));
|
||||
oldSettings.forEach((item) => {
|
||||
localStorage.setItem(item.name, item.value);
|
||||
});
|
||||
break;
|
||||
case 'quote_packs':
|
||||
localStorage.removeItem('quote_packs');
|
||||
@@ -52,15 +54,17 @@ export default class MarketplaceFunctions {
|
||||
localStorage.removeItem('backup_settings');
|
||||
|
||||
let oldSettings = [];
|
||||
for (const key of Object.keys(localStorage)) {
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
oldSettings.push({
|
||||
name: key,
|
||||
value: localStorage.getItem(key)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
localStorage.setItem('backup_settings', JSON.stringify(oldSettings));
|
||||
input.settings.forEach((element) => localStorage.setItem(element.name, element.value));
|
||||
input.settings.forEach((element) => {
|
||||
localStorage.setItem(element.name, element.value);
|
||||
});
|
||||
break;
|
||||
|
||||
case 'photos':
|
||||
|
||||
@@ -23,10 +23,9 @@ const saveFile = (data, filename = 'file') => {
|
||||
export default class SettingsFunctions {
|
||||
static exportSettings() {
|
||||
let settings = {};
|
||||
for (const key of Object.keys(localStorage)) {
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
settings[key] = localStorage.getItem(key);
|
||||
}
|
||||
|
||||
});
|
||||
saveFile(settings, 'mue-settings.json');
|
||||
}
|
||||
|
||||
@@ -160,15 +159,17 @@ export default class SettingsFunctions {
|
||||
`);
|
||||
}
|
||||
|
||||
// in a nutshell, this function saves all of the current settings, resets them, sets the defaults and then overrides
|
||||
// the new settings with the old saved messages where they exist
|
||||
static moveSettings() {
|
||||
if (Object.keys(localStorage).length === 0) {
|
||||
return this.setDefaultSettings();
|
||||
}
|
||||
|
||||
let settings = {};
|
||||
for (const key of Object.keys(localStorage)) {
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
settings[key] = localStorage.getItem(key);
|
||||
}
|
||||
});
|
||||
|
||||
localStorage.clear();
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@import 'variables';
|
||||
@import 'mixins';
|
||||
@import 'themes';
|
||||
|
||||
@import 'modules/toast';
|
||||
|
||||
Reference in New Issue
Block a user