Fix settings issue

Fixes #795
Closes #792
This commit is contained in:
Zack Rauen 2021-05-22 01:51:16 -04:00
parent 25873eaa96
commit 356c7e89fa
9 changed files with 36 additions and 42 deletions

View File

@ -2,6 +2,22 @@
This changelog starts with the restructured 1.0.0 release that happened after context isolation changes. The changelogs here should more-or-less mirror the ones that get shown in the client but probably with less formatting and pizzazz. This changelog starts with the restructured 1.0.0 release that happened after context isolation changes. The changelogs here should more-or-less mirror the ones that get shown in the client but probably with less formatting and pizzazz.
## 1.1.1
### Added
### Removed
### Changed
- Plugin loader now removes the used `script` tags
- URLs reflect new website
### Fixed
- Fixed an issue with hiding GIF and Gift buttons
- Fixed certain plugin patches not returning values
- Fixed an issue with the settings patch failing
## 1.1.0 ## 1.1.0
### Added ### Added

View File

@ -1,6 +1,6 @@
{ {
"name": "betterdiscord", "name": "betterdiscord",
"version": "1.1.0", "version": "1.1.1",
"description": "Enhances Discord by adding functionality and themes.", "description": "Enhances Discord by adding functionality and themes.",
"main": "src/index.js", "main": "src/index.js",
"scripts": { "scripts": {

View File

@ -9,7 +9,7 @@ export default new class HideGIFButton extends Builtin {
enabled() { enabled() {
this.after(WebpackModules.find(m => m.type && m.type.render && m.type.render.displayName === "ChannelTextAreaContainer").type, "render", (_, __, returnValue) => { this.after(WebpackModules.find(m => m.type && m.type.render && m.type.render.displayName === "ChannelTextAreaContainer").type, "render", (_, __, returnValue) => {
const buttons = Utilities.getNestedProp(returnValue, "props.children.0.props.children.1.props.children.1.props.children.2.props.children"); const buttons = Utilities.getNestedProp(returnValue, "props.children.0.props.children.1.props.children.2.props.children.2.props.children");
if (Array.isArray(buttons)) { if (Array.isArray(buttons)) {
for (const button of buttons) { for (const button of buttons) {
if (!button) continue; if (!button) continue;

View File

@ -9,7 +9,7 @@ export default new class HideGiftButton extends Builtin {
enabled() { enabled() {
this.after(WebpackModules.find(m => m.type && m.type.render && m.type.render.displayName === "ChannelTextAreaContainer").type, "render", (_, __, returnValue) => { this.after(WebpackModules.find(m => m.type && m.type.render && m.type.render.displayName === "ChannelTextAreaContainer").type, "render", (_, __, returnValue) => {
const buttons = Utilities.getNestedProp(returnValue, "props.children.0.props.children.1.props.children.1.props.children.2.props.children"); const buttons = Utilities.getNestedProp(returnValue, "props.children.0.props.children.1.props.children.2.props.children.2.props.children");
if (Array.isArray(buttons)) { if (Array.isArray(buttons)) {
for (const button of buttons) { for (const button of buttons) {
if (!button) continue; if (!button) continue;

View File

@ -1,41 +1,21 @@
export default { export default {
description: "BetterDiscord is now accepting translations. If you'd like to contribute reach out to an admin about getting access to POEditor.", description: "This version is a hotfix mainly to fix the settings issue.",
changes: [ changes: [
{ {
title: "New Features", title: "Fixes",
type: "added", type: "fixed",
items: [ items: [
"**Media Keys** can now be optionally prevented from being hijacked by Discord in settings.", "Fixed an issue with the settings patch failing",
"The plugin **RemoveMinimumSize** was absorbed into BetterDiscord and can be enabled in settings.", "Fixed an issue with hiding GIF and Gift buttons",
"**Update checks** should now happen within BetterDiscord so you won't have to reinstall when BetterDiscord updates.", "Fixed certain plugin patches not returning values",
"Addon error modals got a __makeover__ thanks to Strencher (https://github.com/Strencher) and Tropical (https://github.com/Tropix126)", "Updated links to new website"
"**Translations** were added thanks to help from the community! Languages include: French, Slovak, Polish, Portuguese (BR), Chinese (Traditional), Chinese (Simplified)"
] ]
}, },
{ {
title: "Power Users & Developers", title: "Power Users & Developers",
type: "improved", type: "improved",
items: [ items: [
"There is a now a command-line option to launch Discord without BetterDiscord injecting itself. Just use `--vanilla`.", "Certain patches done using `monkeyPatch` instead of `Patcher` now properly return values."
"`ctrl`+`shift`+`c` can now be used globally to activate inspect element, even with devtools closed.",
"Added emote blocklist to `BdApi` via `BdApi.Emotes.blocklist`",
"All console logs can now be logged into the BetterDiscord folder (`BetterDiscord/data/<releaseChannel>/debug.log`) by flipping the switch in settings.",
"The repeated console warnings can be completely removed in Developer Settings."
]
},
{
title: "Fixes",
type: "fixed",
items: [
"**Colored Text**, **Hide GIF Button**, **Hide Gift Button**, and **PublicServers** should all work again",
"Older themes should work with BetterDiscord again.",
"Certain issues with plugins crashing should be fixed.",
"More folders are automatically created to help for those attempting manual or 3rd-party installs.",
"Fixed an issue with an incorrect path being used on Mac.",
"Solved a bug that caused multiple error modals to occur on startup instead of consolidating to one.",
"Emote system should be functional, and the styling has been updating to match Discord's.",
"Using system editor to edit plugins/themes should work instead of causing an error.",
"Fixed a startup issue for users that had all their servers in collapsed folders."
] ]
} }
] ]

View File

@ -214,8 +214,9 @@ BdApi.monkeyPatch = function(what, methodName, options) {
data.methodArguments = args; data.methodArguments = args;
data.returnValue = returnValue; data.returnValue = returnValue;
try { try {
Reflect.apply(options[patchType], null, [data]); const patchReturn = Reflect.apply(options[patchType], null, [data]);
if (once) data.cancelPatch(); if (once) data.cancelPatch();
return patchReturn;
} }
catch (err) { catch (err) {
Logger.err(`${callerId}:monkeyPatch`, `Error in the ${patchType} of ${methodName}`); Logger.err(`${callerId}:monkeyPatch`, `Error in the ${patchType} of ${methodName}`);

View File

@ -116,6 +116,7 @@ export default new class PluginManager extends AddonManager {
delete window.module; delete window.module;
delete window.__filename; delete window.__filename;
delete window.__dirname; delete window.__dirname;
container.remove();
return ""; return "";
} }

View File

@ -1,4 +1,4 @@
import {React, WebpackModules, Patcher, ReactComponents, Utilities, Settings, Events, DataStore} from "modules"; import {React, WebpackModules, Patcher, Utilities, Settings, Events, DataStore} from "modules";
import AddonList from "./settings/addonlist"; import AddonList from "./settings/addonlist";
import SettingsGroup from "./settings/group"; import SettingsGroup from "./settings/group";
@ -60,12 +60,9 @@ export default new class SettingsRenderer {
}, options)); }, options));
} }
async patchSections() { patchSections() {
const UserSettings = await ReactComponents.get("UserSettings", m => m.prototype && m.prototype.generateSections); const UserSettings = WebpackModules.getByDisplayName("SettingsView");
Patcher.after("SettingsManager", UserSettings.prototype, "render", (thisObject) => { Patcher.after("SettingsManager", UserSettings.prototype, "getPredicateSections", (thisObject, args, returnValue) => {
thisObject._reactInternalFiber.return.return.return.return.return.return.return.memoizedProps.id = "user-settings";
});
Patcher.after("SettingsManager", UserSettings.prototype, "generateSections", (thisObject, args, returnValue) => {
let location = returnValue.findIndex(s => s.section.toLowerCase() == "changelog") - 1; let location = returnValue.findIndex(s => s.section.toLowerCase() == "changelog") - 1;
const insert = (section) => { const insert = (section) => {
returnValue.splice(location, 0, section); returnValue.splice(location, 0, section);
@ -90,14 +87,13 @@ export default new class SettingsRenderer {
insert(panel); insert(panel);
} }
}); });
this.forceUpdate();
} }
forceUpdate() { forceUpdate() {
const viewClass = WebpackModules.getByProps("standardSidebarView").standardSidebarView.split(" ")[0]; const viewClass = WebpackModules.getByProps("standardSidebarView").standardSidebarView.split(" ")[0];
const node = document.querySelector(`.${viewClass}`); const node = document.querySelector(`.${viewClass}`);
if (!node) return; if (!node) return;
const stateNode = Utilities.findInReactTree(Utilities.getReactInstance(node), m => m && m.generateSections, {walkable: ["return", "stateNode"]}); const stateNode = Utilities.findInReactTree(Utilities.getReactInstance(node), m => m && m.getPredicateSections, {walkable: ["return", "stateNode"]});
if (stateNode) stateNode.forceUpdate(); if (stateNode) stateNode.forceUpdate();
} }
}; };

View File

@ -108,7 +108,7 @@ export default class AddonList extends React.Component {
} }
get emptyImage() { get emptyImage() {
const message = Strings.Addons.blankSlateMessage.format({link: `https://betterdiscordlibrary.com/${this.props.type}s`, type: this.props.type}).toString(); const message = Strings.Addons.blankSlateMessage.format({link: `https://betterdiscord.app/${this.props.type}s`, type: this.props.type}).toString();
return <EmptyImage title={Strings.Addons.blankSlateHeader.format({type: this.props.type})} message={message}> return <EmptyImage title={Strings.Addons.blankSlateHeader.format({type: this.props.type})} message={message}>
<button className="bd-button" onClick={this.openFolder}>{Strings.Addons.openFolder.format({type: this.props.type})}</button> <button className="bd-button" onClick={this.openFolder}>{Strings.Addons.openFolder.format({type: this.props.type})}</button>
</EmptyImage>; </EmptyImage>;