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.
## 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
### Added

View File

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

View File

@ -9,7 +9,7 @@ export default new class HideGIFButton extends Builtin {
enabled() {
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)) {
for (const button of buttons) {
if (!button) continue;

View File

@ -9,7 +9,7 @@ export default new class HideGiftButton extends Builtin {
enabled() {
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)) {
for (const button of buttons) {
if (!button) continue;

View File

@ -1,41 +1,21 @@
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: [
{
title: "New Features",
type: "added",
title: "Fixes",
type: "fixed",
items: [
"**Media Keys** can now be optionally prevented from being hijacked by Discord in settings.",
"The plugin **RemoveMinimumSize** was absorbed into BetterDiscord and can be enabled in settings.",
"**Update checks** should now happen within BetterDiscord so you won't have to reinstall when BetterDiscord updates.",
"Addon error modals got a __makeover__ thanks to Strencher (https://github.com/Strencher) and Tropical (https://github.com/Tropix126)",
"**Translations** were added thanks to help from the community! Languages include: French, Slovak, Polish, Portuguese (BR), Chinese (Traditional), Chinese (Simplified)"
"Fixed an issue with the settings patch failing",
"Fixed an issue with hiding GIF and Gift buttons",
"Fixed certain plugin patches not returning values",
"Updated links to new website"
]
},
{
title: "Power Users & Developers",
type: "improved",
items: [
"There is a now a command-line option to launch Discord without BetterDiscord injecting itself. Just use `--vanilla`.",
"`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."
"Certain patches done using `monkeyPatch` instead of `Patcher` now properly return values."
]
}
]

View File

@ -214,8 +214,9 @@ BdApi.monkeyPatch = function(what, methodName, options) {
data.methodArguments = args;
data.returnValue = returnValue;
try {
Reflect.apply(options[patchType], null, [data]);
const patchReturn = Reflect.apply(options[patchType], null, [data]);
if (once) data.cancelPatch();
return patchReturn;
}
catch (err) {
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.__filename;
delete window.__dirname;
container.remove();
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 SettingsGroup from "./settings/group";
@ -60,12 +60,9 @@ export default new class SettingsRenderer {
}, options));
}
async patchSections() {
const UserSettings = await ReactComponents.get("UserSettings", m => m.prototype && m.prototype.generateSections);
Patcher.after("SettingsManager", UserSettings.prototype, "render", (thisObject) => {
thisObject._reactInternalFiber.return.return.return.return.return.return.return.memoizedProps.id = "user-settings";
});
Patcher.after("SettingsManager", UserSettings.prototype, "generateSections", (thisObject, args, returnValue) => {
patchSections() {
const UserSettings = WebpackModules.getByDisplayName("SettingsView");
Patcher.after("SettingsManager", UserSettings.prototype, "getPredicateSections", (thisObject, args, returnValue) => {
let location = returnValue.findIndex(s => s.section.toLowerCase() == "changelog") - 1;
const insert = (section) => {
returnValue.splice(location, 0, section);
@ -90,14 +87,13 @@ export default new class SettingsRenderer {
insert(panel);
}
});
this.forceUpdate();
}
forceUpdate() {
const viewClass = WebpackModules.getByProps("standardSidebarView").standardSidebarView.split(" ")[0];
const node = document.querySelector(`.${viewClass}`);
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();
}
};

View File

@ -108,7 +108,7 @@ export default class AddonList extends React.Component {
}
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}>
<button className="bd-button" onClick={this.openFolder}>{Strings.Addons.openFolder.format({type: this.props.type})}</button>
</EmptyImage>;