fix: marketplace now works, more hot reload support and fixes

Co-authored-by: Alex Sparkes <turbomarshmello@gmail.com>
This commit is contained in:
David Ralph
2021-04-12 20:35:17 +01:00
parent b370de9ea3
commit 90a4696114
14 changed files with 52 additions and 35 deletions

View File

@@ -55,7 +55,7 @@ export default class Marketplace extends React.PureComponent {
const installed = JSON.parse(localStorage.getItem('installed'));
if (installed.some(item => item.name === data)) {
if (installed.some(item => item.name === info.data.name)) {
button = this.buttons.uninstall;
}

View File

@@ -16,7 +16,6 @@
opacity: 1;
z-index: -2;
padding: 25px;
transition: 0.6s;
transition-timing-function: ease-in;
border-radius: map-get($modal, 'border-radius');
-moz-user-select: none;

View File

@@ -1,5 +1,7 @@
import React from 'react';
import EventBus from '../../../../modules/helpers/eventbus';
export default class Dropdown extends React.PureComponent {
constructor(props) {
super(props);
@@ -26,6 +28,8 @@ export default class Dropdown extends React.PureComponent {
if (this.props.onChange) {
this.props.onChange(value);
}
EventBus.dispatch('refresh', this.props.category);
}
// todo: find a better way to do this

View File

@@ -31,6 +31,7 @@ export default class Slider extends React.PureComponent {
});
toast(this.language.toasts.reset);
EventBus.dispatch('refresh', this.props.category);
}
render() {

View File

@@ -36,6 +36,7 @@ export default class Text extends React.PureComponent {
});
toast(this.language.toasts.reset);
EventBus.dispatch('refresh', this.props.category);
}
render() {

View File

@@ -46,7 +46,7 @@ export default class AdvancedSettings extends React.PureComponent {
<h3>{advanced.customisation}</h3>
<Text title={advanced.custom_js} name='customjs' textarea={true}/>
<Text title={advanced.custom_css} name='customcss' textarea={true}/>
<Text title={advanced.tab_name} name='tabName' default={window.language.tabname}/>
<Text title={advanced.tab_name} name='tabName' default={window.language.tabname} category='other'/>
<h3>{this.language.sections.experimental.title}</h3>
<p>{advanced.experimental_warning}</p>

View File

@@ -29,7 +29,7 @@ export default function AppearanceSettings() {
return (
<>
<h2>{appearance.title}</h2>
<Radio name='theme' title={appearance.theme.title} options={themeOptions} />
<Radio name='theme' title={appearance.theme.title} options={themeOptions} category='other' />
<h3>{appearance.navbar.title}</h3>
<Checkbox name='notesEnabled' text={appearance.navbar.notes} />

View File

@@ -30,7 +30,7 @@ export default class BackgroundSettings extends React.PureComponent {
toast(this.language.toasts.reset);
}
fileUpload(e) {
customBackground(e) {
localStorage.setItem('customBackground', e.target.result);
this.setState({
customBackground: e.target.result
@@ -58,10 +58,6 @@ export default class BackgroundSettings extends React.PureComponent {
}
}
componentDidUpdate() {
localStorage.setItem('customBackground', this.state.customBackground);
}
async getBackgroundCategories() {
const data = await (await fetch(window.constants.API_URL + '/images/categories')).json();
this.setState({
@@ -94,7 +90,7 @@ export default class BackgroundSettings extends React.PureComponent {
<br/>
<Radio title={background.source.api} options={apiOptions} name='backgroundAPI'/>
<br/>
<Dropdown label='Category' name='apiCategory'>
<Dropdown label={background.category} name='apiCategory'>
{this.state.backgroundCategories.map((category) => (
<option value={category} key={category}>{category.charAt(0).toUpperCase() + category.slice(1)}</option>
))}
@@ -106,9 +102,9 @@ export default class BackgroundSettings extends React.PureComponent {
<>
<ul>
<p>{background.source.custom_background} <span className='modalLink' onClick={this.resetCustom}>{this.language.buttons.reset}</span></p>
<input type='text' value={this.state.customBackground} onChange={(e) => this.setState({ customBackground: e.target.value })}></input>
<input type='text' value={this.state.customBackground} onChange={(e) => this.customBackground(e)}></input>
<span className='modalLink' onClick={() => document.getElementById('bg-input').click()}>{background.source.upload}</span>
<FileUpload id='bg-input' accept='image/jpeg, image/png, image/webp, image/webm, image/gif, video/mp4, video/webm, video/ogg' loadFunction={(e) => this.fileUpload(e)} />
<FileUpload id='bg-input' accept='image/jpeg, image/png, image/webp, image/webm, image/gif, video/mp4, video/webm, video/ogg' loadFunction={(e) => this.customBackground(e)} />
</ul>
{this.videoCustomSettings()}
</>