This commit is contained in:
David Ralph
2021-02-08 17:29:07 +00:00
parent 7785706737
commit 182da7cd5d
9 changed files with 35 additions and 56 deletions

View File

@@ -56,13 +56,22 @@ export default class Marketplace extends React.PureComponent {
break;
case 'item':
let info;
let info; // get item info
try {
info = await (await fetch(`${Constants.MARKETPLACE_URL}/item/${type2}/${data}`)).json();
} catch (e) {
return toast(this.props.toastLanguage.error);
}
// check if already installed
let button = this.buttons.install;
const installed = JSON.parse(localStorage.getItem('installed'));
if (installed.some(item => item.name === data)) {
button = this.buttons.uninstall;
}
this.setState({
current_data: { type: type2, name: data, content: info },
item_data: {
@@ -72,19 +81,8 @@ export default class Marketplace extends React.PureComponent {
updated: info.updated,
version: info.data.version,
icon: info.data.screenshot_url
}
});
let button = this.buttons.install;
const installed = JSON.parse(localStorage.getItem('installed'));
if (installed.some(item => item.name === data)) {
button = this.buttons.uninstall;
}
this.setState({
button: button
},
button: button
});
document.getElementById('marketplace').style.display = 'none';
@@ -101,7 +99,7 @@ export default class Marketplace extends React.PureComponent {
}
async getItems() {
const { data }= await (await fetch(Constants.MARKETPLACE_URL + '/all')).json();
const { data } = await (await fetch(Constants.MARKETPLACE_URL + '/all')).json();
const featured = await (await fetch(Constants.MARKETPLACE_URL + '/featured')).json();
this.setState({