diff --git a/assets/locales/en-us.json b/assets/locales/en-us.json index ac6b12c5..5b1269d4 100644 --- a/assets/locales/en-us.json +++ b/assets/locales/en-us.json @@ -218,6 +218,7 @@ "version": "Version", "added": "Date Added", "modified": "Date Modified", + "isEnabled": "Enabled", "search": "Search {{type}}", "editAddon": "Edit", "deleteAddon": "Delete", @@ -324,4 +325,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?" } -} \ No newline at end of file +} diff --git a/renderer/src/ui/settings/addonlist.jsx b/renderer/src/ui/settings/addonlist.jsx index 097458d9..6659aae3 100644 --- a/renderer/src/ui/settings/addonlist.jsx +++ b/renderer/src/ui/settings/addonlist.jsx @@ -96,7 +96,8 @@ export default class AddonList extends React.Component { {label: Strings.Addons.author, value: "author"}, {label: Strings.Addons.version, value: "version"}, {label: Strings.Addons.added, value: "added"}, - {label: Strings.Addons.modified, value: "modified"} + {label: Strings.Addons.modified, value: "modified"}, + {label: Strings.Addons.isEnabled, value: "isEnabled"} ]; } @@ -127,9 +128,12 @@ export default class AddonList extends React.Component { const showReloadIcon = !Settings.get("settings", "addons", "autoReload"); const button = folder ? {title: Strings.Addons.openFolder.format({type: title}), onClick: this.openFolder} : null; let sortedAddons = addonList.sort((a, b) => { - const first = a[this.state.sort]; - const second = b[this.state.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;