-
- {!onCollection && !isCurator ? (
+ {showCreateYourOwn ? (
{variables.getMessage('modals.main.marketplace.cant_find')}
diff --git a/src/features/marketplace/views/Added.jsx b/src/features/marketplace/views/Added.jsx
index b49c5b4f..66a01e7c 100644
--- a/src/features/marketplace/views/Added.jsx
+++ b/src/features/marketplace/views/Added.jsx
@@ -5,7 +5,7 @@ import { toast } from 'react-toastify';
import Modal from 'react-modal';
import { SideloadFailedModal } from '../components/Elements/SideloadFailedModal/SideloadFailedModal';
-import Item from '../components/Items/Item';
+import ItemPage from './ItemPage';
import Items from '../components/Items/Items';
import { Dropdown, FileUpload } from 'components/Form/Settings';
import { Header, CustomActions } from 'components/Layout/Settings';
@@ -68,9 +68,12 @@ export default class Added extends PureComponent {
});
}
- install(input.type, input);
+ install(input.type, input, true, false);
toast(variables.getMessage('toasts.installed'));
variables.stats.postEvent('marketplace', 'Sideload');
+ this.setState({
+ installed: JSON.parse(localStorage.getItem('installed')),
+ });
}
getSideloadButton() {
@@ -105,7 +108,7 @@ export default class Added extends PureComponent {
},
button: this.buttons.uninstall,
});
- variables.stats.postEvent('marketplace', 'Item viewed');
+ variables.stats.postEvent('marketplace', 'ItemPage viewed');
} else {
this.setState({
item: {},
@@ -121,6 +124,7 @@ export default class Added extends PureComponent {
this.setState({
button: '',
installed: JSON.parse(localStorage.getItem('installed')),
+ item: {},
});
variables.stats.postEvent('marketplace', 'Uninstall');
@@ -135,7 +139,15 @@ export default class Added extends PureComponent {
case 'oldest':
break;
case 'a-z':
- installed.sort();
+ installed.sort((a, b) => {
+ if (a.display_name < b.display_name) {
+ return -1;
+ }
+ if (a.display_name > b.display_name) {
+ return 1;
+ }
+ return 0;
+ });
break;
case 'z-a':
installed.sort();
@@ -158,7 +170,7 @@ export default class Added extends PureComponent {
let updates = 0;
this.state.installed.forEach(async (item) => {
const data = await (
- await fetch(variables.constants.API_URL + 'marketplace//item/' + item.name)
+ await fetch(variables.constants.API_URL + 'marketplace/item/' + item.name)
).json();
if (data.version !== item.version) {
updates++;
@@ -176,6 +188,25 @@ export default class Added extends PureComponent {
}
}
+ removeAll() {
+ try {
+ this.state.installed.forEach((item) => {
+ uninstall(item.type, item.name);
+ });
+ } catch (e) {
+ }
+
+ localStorage.setItem('installed', JSON.stringify([]));
+
+ toast(variables.getMessage('toasts.uninstalled_all'));
+
+ this.setState({
+ installed: [],
+ });
+
+ this.forceUpdate();
+ }
+
componentDidMount() {
this.sortAddons(localStorage.getItem('sortAddons'), false);
}
@@ -229,9 +260,10 @@ export default class Added extends PureComponent {
if (this.state.item.display_name) {
return (
- - this.toggle()}
/>
);
@@ -249,6 +281,7 @@ export default class Added extends PureComponent {
icon={}
label={variables.getMessage('modals.main.addons.check_updates')}
/>
+
>
@@ -460,6 +461,7 @@ class Marketplace extends PureComponent {
toggleFunction={(input) => this.toggle('item', input)}
collectionFunction={(input) => this.toggle('collection', input)}
filter={this.state.filter}
+ showCreateYourOwn={true}
/>
)}
>
diff --git a/src/features/marketplace/components/Items/Item.jsx b/src/features/marketplace/views/ItemPage.jsx
similarity index 73%
rename from src/features/marketplace/components/Items/Item.jsx
rename to src/features/marketplace/views/ItemPage.jsx
index 53a96131..e4c5f78b 100644
--- a/src/features/marketplace/components/Items/Item.jsx
+++ b/src/features/marketplace/views/ItemPage.jsx
@@ -18,12 +18,12 @@ import { Header } from 'components/Layout/Settings';
import { Button } from 'components/Elements';
import { install, uninstall } from 'utils/marketplace';
-import { Carousel } from '../Elements/Carousel';
+import { Carousel } from '../components/Elements/Carousel';
import { ShareModal } from 'components/Elements';
import placeholderIcon from 'assets/icons/marketplace-placeholder.png';
-import { Items } from './Items';
+import { Items } from '../components/Items/Items';
-class Item extends PureComponent {
+class ItemPage extends PureComponent {
constructor(props) {
super(props);
this.state = {
@@ -119,34 +119,33 @@ class Item extends PureComponent {
);
}
- let itemWarning;
- if (
- this.props.data.data.language !== undefined &&
- this.props.data.data.language !== null &&
- shortLocale !== this.props.data.data.language
- ) {
- itemWarning = (
+ const itemWarning = () => {
+ const template = (message) => (
Warning
- {variables.getMessage('modals.main.marketplace.product.not_in_language')}
+ {message}
);
- }
- if (this.props.data.data.image_api === true) {
- itemWarning = (
-
-
-
- Warning
- {variables.getMessage('modals.main.marketplace.product.third_party_api')}
-
-
- );
- }
+ if (this.props.data.data.sideload === true) {
+ return template(variables.getMessage('modals.main.marketplace.product.sideload_warning'));
+ }
+
+ if (this.props.data.data.image_api === true) {
+ return template(variables.getMessage('modals.main.marketplace.product.third_party_api'));
+ }
+
+ if (this.props.data.data.language !== undefined && this.props.data.data.language !== null) {
+ if (shortLocale !== this.props.data.data.language) {
+ return template(variables.getMessage('modals.main.marketplace.product.not_in_language'));
+ }
+ }
+
+ return null;
+ };
const moreInfoItem = (icon, header, text) => (
@@ -158,31 +157,7 @@ class Item extends PureComponent {
);
- const DataTable = ({ data, title, value, incrementCount, count }) => (
- <>
-
-
-
- | {variables.getMessage(title)} |
- {variables.getMessage(value)} |
-
- {data.slice(0, count).map((item, index) => (
-
- | {item.quote || item.key} |
- {item.author || item.value} |
-
- ))}
-
-
-
-
- {count !== data.length
- ? variables.getMessage('modals.main.marketplace.product.show_all')
- : variables.getMessage('modals.main.marketplace.product.show_less')}
-
-
- >
- );
+ console.log(this.props.data.data)
return (
<>
@@ -203,11 +178,13 @@ class Item extends PureComponent {
0
- ? this.props.data.data.in_collections[0].display_name
- : variables.getMessage('modals.main.navbar.marketplace')
+ this.props.addons
+ ? variables.getMessage('modals.main.addons.added')
+ : this.props.data.data.in_collections?.length > 0
+ ? this.props.data.data.in_collections[0].display_name
+ : variables.getMessage('modals.main.navbar.marketplace')
}
- secondaryTitle={this.props.data.data.display_name}
+ secondaryTitle={this.props.data.data.sideload ? this.props.data.data.name : this.props.data.data.display_name}
report={false}
goBack={this.props.toggleFunction}
/>
@@ -219,7 +196,7 @@ class Item extends PureComponent {
variables.getMessage('modals.main.marketplace.product.created_by'),
this.props.data.author,
)}
- {itemWarning}
+ {itemWarning()}