Add enable sort to new addon page, code cleanup
This commit is contained in:
parent
4c153158d2
commit
4a5c027208
|
@ -234,6 +234,7 @@
|
|||
"added": "Date Added",
|
||||
"uploaded": "Date Uploaded",
|
||||
"modified": "Date Modified",
|
||||
"isEnabled": "Enabled",
|
||||
"search": "Search {{type}}",
|
||||
"noResults": "We searched far and wide. Unfortunately, no results were found.",
|
||||
"editAddon": "Edit",
|
||||
|
@ -352,4 +353,4 @@
|
|||
"enabledInfo": "This option requires a transparent theme in order to work properly. On Windows this may break your aero snapping and maximizing.\n\nIn order to take effect, Discord needs to be restarted. Do you want to restart now?",
|
||||
"disabledInfo": "In order to take effect, Discord needs to be restarted. Do you want to restart now?"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
"target": "es2020",
|
||||
"allowSyntheticDefaultImports": false,
|
||||
"baseUrl": "./",
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react-jsx",
|
||||
"resolveJsonModule": true,
|
||||
"paths": {
|
||||
"modules": ["./src/modules/modules.js"],
|
||||
"builtins": ["./src/builtins/builtins.js"],
|
||||
|
|
|
@ -15,7 +15,7 @@ import path from "path";
|
|||
import fs from "fs";
|
||||
|
||||
const API_CACHE = {plugins: [], themes: [], addon: []};
|
||||
const README_CACHE = {plugins: {}, themes: {}};
|
||||
// const README_CACHE = {plugins: {}, themes: {}};
|
||||
|
||||
export default new class BdWebApi {
|
||||
get apiVersion() {return Web.API_VERSION;}
|
||||
|
|
|
@ -21,7 +21,8 @@ const CONTROLS = {
|
|||
{get label() {return Strings.Addons.author;}, value: "author"},
|
||||
{get label() {return Strings.Addons.version;}, value: "version"},
|
||||
{get label() {return Strings.Addons.added;}, value: "added"},
|
||||
{get label() {return Strings.Addons.modified;}, value: "modified"}
|
||||
{get label() {return Strings.Addons.modified;}, value: "modified"},
|
||||
{get label() {return Strings.Addons.isEnabled;}, value: "isEnabled"}
|
||||
],
|
||||
directions: [
|
||||
{get label() {return Strings.Sorting.ascending;}, value: true},
|
||||
|
|
|
@ -34,9 +34,12 @@ export default class InstalledPage extends React.Component {
|
|||
|
||||
const showReloadIcon = !Settings.get("settings", "addons", "autoReload");
|
||||
let sortedAddons = addonList.sort((a, b) => {
|
||||
const first = a[this.props.sort];
|
||||
const second = b[this.props.sort];
|
||||
if (typeof(first) == "string") return first.toLocaleLowerCase().localeCompare(second.toLocaleLowerCase());
|
||||
const sortByEnabled = this.state.sort === "isEnabled";
|
||||
const first = sortByEnabled ? addonState[a.id] : a[this.state.sort];
|
||||
const second = sortByEnabled ? addonState[b.id] : b[this.state.sort];
|
||||
const stringSort = (str1, str2) => str1.toLocaleLowerCase().localeCompare(str2.toLocaleLowerCase());
|
||||
if (typeof(first) == "string") return stringSort(first, second);
|
||||
if (typeof(first) == "boolean") return (first === second) ? stringSort(a.name, b.name) : first ? -1 : 1;
|
||||
if (first > second) return 1;
|
||||
if (second > first) return -1;
|
||||
return 0;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {React, Strings, Utilities, WebpackModules, DiscordClasses} from "modules";
|
||||
import {Web} from "data";
|
||||
|
||||
import Next from "../../icons/next";
|
||||
import Previous from "../../icons/previous";
|
||||
|
@ -93,11 +94,11 @@ export default class StorePage extends React.Component {
|
|||
{addons[this.state.selectedPage].map(addon => {
|
||||
return <StoreCard
|
||||
{...addon}
|
||||
thumbnail={BdWebApi.endpoints.thumbnail(addon.thumbnail_url)}
|
||||
reload={this.props.reload}
|
||||
confirmAddonDelete={this.props.confirmAddonDelete}
|
||||
deleteAddon={this.props.deleteAddon}
|
||||
installAddon={BdWebApi.installAddon.bind(this)}
|
||||
thumbnail={Web.ENDPOINTS.thumbnail(addon.thumbnail_url)}
|
||||
reload={this.props.reload}
|
||||
confirmAddonDelete={this.props.confirmAddonDelete}
|
||||
isInstalled={this.isInstalled.bind(this)}
|
||||
selectedTag={this.props.state.selectedTag}
|
||||
folder={this.props.folder}
|
||||
|
|
|
@ -30,7 +30,7 @@ export default class StoreCard extends React.Component {
|
|||
if (n >= 1e6 && n < 1e9) return +(n / 1e6).toFixed(1) + "M";
|
||||
}
|
||||
|
||||
preview = event => {
|
||||
preview = (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
|
@ -42,12 +42,10 @@ export default class StoreCard extends React.Component {
|
|||
|
||||
onClick = event => {
|
||||
const {onDetailsView} = this.props;
|
||||
if (typeof onDetailsView !== "function") return;
|
||||
|
||||
onDetailsView();
|
||||
if (typeof(onDetailsView) === "function") onDetailsView();
|
||||
}
|
||||
|
||||
onButtonClick = async event => {
|
||||
onButtonClick = async (event) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
|
|
|
@ -15,10 +15,12 @@ export class StoreDetail extends React.Component {
|
|||
|
||||
this.scrollerRef = React.createRef();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// dirty hack for customizing layers created by pushLayer
|
||||
this.scrollerRef.current.parentElement.classList.add("bd-store-details");
|
||||
}
|
||||
|
||||
render() {
|
||||
return <>
|
||||
<header class="bd-store-details-title">
|
||||
|
|
Loading…
Reference in New Issue