This commit is contained in:
David Ralph
2020-12-02 12:23:55 +00:00
parent 89b4d154ad
commit fc570089c2
10 changed files with 67 additions and 70 deletions

View File

@@ -3,6 +3,7 @@ import LocalMallIcon from '@material-ui/icons/LocalMall';
import { toast } from 'react-toastify';
import Item from '../marketplace/Item';
import Items from '../marketplace/Items';
import FileUpload from '../settings/FileUpload';
import MarketplaceFunctions from '../../../modules/helpers/marketplace';
export default class Addons extends React.PureComponent {
@@ -69,12 +70,6 @@ export default class Addons extends React.PureComponent {
componentDidMount() {
if (localStorage.getItem('animations') === 'true') document.getElementById('marketplace').classList.add('marketplaceanimation');
document.getElementById('file-input').onchange = (e) => {
const reader = new FileReader();
reader.readAsText(e.target.files[0], 'UTF-8');
reader.onload = (readerEvent) => this.manage('install', JSON.parse(readerEvent.target.result));
};
}
render() {
@@ -96,7 +91,7 @@ export default class Addons extends React.PureComponent {
return (
<React.Fragment>
<div id='marketplace'>
<input id='file-input' type='file' name='name' className='hidden' accept='application/json' />
<FileUpload id='file-input' accept='application/json' loadFunction={(e) => this.manage('install', JSON.parse(e.target.result))} />
<button className='addToMue sideload' onClick={() => document.getElementById('file-input').click()}>{this.props.language.sideload}</button>
<h1>{this.props.language.added}</h1>
{content}

View File

@@ -100,9 +100,9 @@ export default class Marketplace extends React.PureComponent {
default: break;
}
toast(this.props.toastLanguage[type + 'ed']);
let button = this.buttons.install;
if (type === 'install') button = this.buttons.uninstall;
this.setState({ button: button });
this.setState({
button: (type === 'install') ? this.buttons.uninstall : this.buttons.install
});
}
componentDidMount() {
@@ -132,7 +132,7 @@ export default class Marketplace extends React.PureComponent {
);
}
if (this.state.done === false) return returnMessage(<h1>{this.props.updateLanguage.loading}</h1>)
if (this.state.done === false) return returnMessage(<h1>{this.props.updateLanguage.loading}</h1>);
return (
<React.Fragment>