stuff
This commit is contained in:
parent
4c4beb9f72
commit
6ca856068e
|
@ -1796,9 +1796,13 @@
|
|||
}
|
||||
return parent.props.children;
|
||||
}
|
||||
BDFDB.ReactUtils.createElement = function (component, props = {}) {
|
||||
BDFDB.ReactUtils.createElement = function (component, props = {}, errorWrap = false) {
|
||||
if (component && component.defaultProps) for (let key in component.defaultProps) if (props[key] == null) props[key] = component.defaultProps[key];
|
||||
try {return LibraryModules.React.createElement(component || "div", props) || null;}
|
||||
try {
|
||||
let child = LibraryModules.React.createElement(component || "div", props) || null;
|
||||
if (errorWrap) return LibraryModules.React.createElement(InternalComponents.ErrorBoundary, {}, child) || null;
|
||||
else return child;
|
||||
}
|
||||
catch (err) {BDFDB.LogUtils.error("Could not create react element! " + err);}
|
||||
return null;
|
||||
};
|
||||
|
@ -6837,6 +6841,36 @@
|
|||
}, 100);
|
||||
|
||||
var InternalComponents = {NativeSubComponents: {}, LibraryComponents: {}}, reactInitialized = LibraryModules.React && LibraryModules.React.Component;
|
||||
|
||||
InternalComponents.ErrorBoundary = reactInitialized && class BDFDB_ErrorBoundary extends LibraryModules.React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {hasError: false};
|
||||
}
|
||||
static getDerivedStateFromError(error) {
|
||||
return {hasError: true};
|
||||
}
|
||||
componentDidCatch(error, info) {
|
||||
BDFDB.LogUtils.error("Could not create react element! " + error);
|
||||
}
|
||||
render() {
|
||||
if (this.state.hasError) return LibraryModules.React.createElement("span", {
|
||||
style: {
|
||||
background: BDFDB.DiscordConstants && BDFDB.DiscordConstants.Colors && BDFDB.DiscordConstants.Colors.PRIMARY_DARK,
|
||||
borderRadius: 5,
|
||||
color: BDFDB.DiscordConstants && BDFDB.DiscordConstants.Colors && BDFDB.DiscordConstants.Colors.STATUS_RED,
|
||||
fontSize: 12,
|
||||
fontWeight: 600,
|
||||
padding: 6,
|
||||
textAlign: "center",
|
||||
verticalAlign: "center"
|
||||
},
|
||||
children: "React Component Error"
|
||||
});
|
||||
return this.props.children;
|
||||
}
|
||||
};
|
||||
|
||||
InternalComponents.NativeSubComponents.Button = BDFDB.ModuleUtils.findByProperties("Colors", "Hovers", "Looks");
|
||||
InternalComponents.NativeSubComponents.Checkbox = BDFDB.ModuleUtils.findByName("Checkbox");
|
||||
InternalComponents.NativeSubComponents.Clickable = BDFDB.ModuleUtils.findByName("Clickable");
|
||||
|
@ -9050,8 +9084,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
InternalComponents.NativeSubComponents.TabBar = BDFDB.ModuleUtils.findByName("TabBar");
|
||||
|
||||
InternalComponents.LibraryComponents.Table = InternalBDFDB.loadPatchedComp("Table") || reactInitialized && class BDFDB_Table extends LibraryModules.React.Component {
|
||||
render() {
|
||||
return BDFDB.ReactUtils.createElement(InternalComponents.NativeSubComponents.Table, Object.assign({}, this.props, {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -602,7 +602,7 @@ var PluginRepo = (_ => {
|
|||
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
|
||||
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
|
||||
|
||||
return BDFDB.ReactUtils.createElement(RepoListComponent, options);
|
||||
return BDFDB.ReactUtils.createElement(RepoListComponent, options, true);
|
||||
}
|
||||
});
|
||||
if (oldSettings) e.instance.props.sections.splice(index + 1, 0, {section: "DIVIDER"});
|
||||
|
@ -621,7 +621,7 @@ var PluginRepo = (_ => {
|
|||
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
|
||||
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
|
||||
children[index] = [
|
||||
BDFDB.ReactUtils.createElement(RepoListHeaderComponent, options),
|
||||
BDFDB.ReactUtils.createElement(RepoListHeaderComponent, options, true),
|
||||
children[index]
|
||||
];
|
||||
}
|
||||
|
|
|
@ -636,7 +636,7 @@ var ServerFolders = (_ => {
|
|||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: ["FluxContainer(Guilds)", "FluxContainer(NavigableGuilds)"]});
|
||||
if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(folderGuildContentComponent, {
|
||||
themeOverride: children[index].props.themeOverride
|
||||
}));
|
||||
}, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -817,7 +817,7 @@ var ServerFolders = (_ => {
|
|||
className: BDFDB.disCN.marginbottom20,
|
||||
children: BDFDB.ReactUtils.createElement(folderIconPickerComponent, {
|
||||
selectedIcon: data.iconID
|
||||
})
|
||||
}, true)
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||
type: "Switch",
|
||||
|
@ -888,7 +888,7 @@ var ServerFolders = (_ => {
|
|||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
|
||||
tab: this.labels.modal_tabheader4_text,
|
||||
children: BDFDB.ReactUtils.createElement(folderIconCustomPreviewComponent, {})
|
||||
children: BDFDB.ReactUtils.createElement(folderIconCustomPreviewComponent, {}, true)
|
||||
})
|
||||
];
|
||||
[children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: ["ModalFooter", "Footer"]});
|
||||
|
|
|
@ -892,7 +892,7 @@ var ThemeRepo = (_ => {
|
|||
options.useThemeFixer = false;
|
||||
options.useCustomCSS = false;
|
||||
|
||||
return BDFDB.ReactUtils.createElement(RepoListComponent, options);
|
||||
return BDFDB.ReactUtils.createElement(RepoListComponent, options, true);
|
||||
}
|
||||
});
|
||||
if (oldSettings && !isPRinjected) e.instance.props.sections.splice(index + 1, 0, {section: "DIVIDER"});
|
||||
|
@ -911,7 +911,7 @@ var ThemeRepo = (_ => {
|
|||
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
|
||||
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
|
||||
children[index] = [
|
||||
BDFDB.ReactUtils.createElement(RepoListHeaderComponent, options),
|
||||
BDFDB.ReactUtils.createElement(RepoListHeaderComponent, options, true),
|
||||
children[index]
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue