bug fixes and cleanup

This commit is contained in:
David Ralph
2020-08-27 18:15:59 +01:00
parent f56854127c
commit 3a0468dcb9
9 changed files with 58 additions and 95 deletions

View File

@@ -80,17 +80,15 @@ export default class Settings extends React.PureComponent {
reader.onload = (readerEvent) => {
const content = JSON.parse(readerEvent.target.result);
for (const key of Object.keys(content)) localStorage.setItem(key, content[key]);
toast('Imported settings!');
toast(this.props.toastLanguage.imported_settings);
}
}
document.getElementById('bg-input').onchange = (e) => {
const allowed = [ 'image/svg+xml', 'image/jpeg', 'image/png', 'image/webp', 'image/webm', 'image/gif' ];
const reader = new FileReader();
const file = e.target.files[0];
if (file.size > 2000000) return toast('File is over 2MB', '#ff0000', '#ffffff');
if (!allowed.includes(file.type)) return console.error(`expected xml, svg, png or jpeg, got ${file.type}`);
reader.addEventListener('load', (e) => {
localStorage.setItem('customBackground', e.target.result);
@@ -191,7 +189,7 @@ export default class Settings extends React.PureComponent {
<ul>
<p>{this.props.language.background.custombackground} <span className='modalLink' onClick={() => this.resetItem('customBackground')}>{this.props.language.reset}</span></p>
<button className='uploadbg' onClick={() => document.getElementById('bg-input').click()}>{this.props.language.background.upload}</button>
<input id='bg-input' type='file' name='name' className='hidden' />
<input id='bg-input' type='file' name='name' className='hidden' accept='image/svg+xml, image/jpeg, image/png, image/webp, image/webm, image/gif' />
</ul>
{ /* <ul>
<p>{this.props.language.background.customcolour} <span className='modalLink' onClick={() => this.resetItem('customBackgroundColour')}>Reset</span></p>