mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 06:03:03 -04:00
avoid showing ugly red error cards to users
This commit is contained in:
parent
e7076f5aee
commit
fae15dbdfe
11 changed files with 20 additions and 18 deletions
|
@ -48,7 +48,7 @@ export function _modifyAccessories(
|
||||||
) {
|
) {
|
||||||
for (const [key, accessory] of accessories.entries()) {
|
for (const [key, accessory] of accessories.entries()) {
|
||||||
const res = (
|
const res = (
|
||||||
<ErrorBoundary message={`Failed to render ${key} Message Accessory`} key={key}>
|
<ErrorBoundary noop message={`Failed to render ${key} Message Accessory`} key={key}>
|
||||||
<accessory.render {...props} />
|
<accessory.render {...props} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
|
|
|
@ -75,10 +75,15 @@ const ErrorBoundary = LazyComponent(() => {
|
||||||
logger.error(`${this.props.message || "A component threw an Error"}\n`, error, errorInfo.componentStack);
|
logger.error(`${this.props.message || "A component threw an Error"}\n`, error, errorInfo.componentStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isNoop() {
|
||||||
|
if (IS_DEV) return false;
|
||||||
|
return this.props.noop;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.state.error === NO_ERROR) return this.props.children;
|
if (this.state.error === NO_ERROR) return this.props.children;
|
||||||
|
|
||||||
if (this.props.noop) return null;
|
if (this.isNoop) return null;
|
||||||
|
|
||||||
if (this.props.fallback)
|
if (this.props.fallback)
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -270,7 +270,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
|
||||||
{!!plugin.settingsAboutComponent && (
|
{!!plugin.settingsAboutComponent && (
|
||||||
<div className={classes(Margins.bottom8, "vc-text-selectable")}>
|
<div className={classes(Margins.bottom8, "vc-text-selectable")}>
|
||||||
<Forms.FormSection>
|
<Forms.FormSection>
|
||||||
<ErrorBoundary message="An error occurred while rendering this plugin's custom InfoComponent">
|
<ErrorBoundary message="An error occurred while rendering this plugin's custom Info Component">
|
||||||
<plugin.settingsAboutComponent tempSettings={tempSettings} />
|
<plugin.settingsAboutComponent tempSettings={tempSettings} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
</Forms.FormSection>
|
</Forms.FormSection>
|
||||||
|
|
|
@ -150,5 +150,5 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
DecorSection: ErrorBoundary.wrap(DecorSection)
|
DecorSection: ErrorBoundary.wrap(DecorSection, { noop: true })
|
||||||
});
|
});
|
||||||
|
|
|
@ -118,7 +118,7 @@ export default definePlugin({
|
||||||
renderSearchBar(instance: Instance, SearchBarComponent: TSearchBarComponent) {
|
renderSearchBar(instance: Instance, SearchBarComponent: TSearchBarComponent) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary noop={true}>
|
<ErrorBoundary noop>
|
||||||
<SearchBar instance={instance} SearchBarComponent={SearchBarComponent} />
|
<SearchBar instance={instance} SearchBarComponent={SearchBarComponent} />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
|
|
|
@ -99,7 +99,7 @@ export default definePlugin({
|
||||||
src={`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${roleId}/${role.icon}.webp?size=24&quality=lossless`}
|
src={`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${roleId}/${role.icon}.webp?size=24&quality=lossless`}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}),
|
}, { noop: true }),
|
||||||
});
|
});
|
||||||
|
|
||||||
function getUsernameString(username: string) {
|
function getUsernameString(username: string) {
|
||||||
|
|
|
@ -20,7 +20,6 @@ import { addMessageAccessory, removeMessageAccessory } from "@api/MessageAccesso
|
||||||
import { updateMessage } from "@api/MessageUpdater";
|
import { updateMessage } from "@api/MessageUpdater";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { getUserSettingLazy } from "@api/UserSettings";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
|
||||||
import { Devs } from "@utils/constants.js";
|
import { Devs } from "@utils/constants.js";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { Queue } from "@utils/Queue";
|
import { Queue } from "@utils/Queue";
|
||||||
|
@ -373,7 +372,7 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
addMessageAccessory("messageLinkEmbed", props => {
|
addMessageAccessory("MessageLinkEmbeds", props => {
|
||||||
if (!messageLinkRegex.test(props.message.content))
|
if (!messageLinkRegex.test(props.message.content))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -381,16 +380,14 @@ export default definePlugin({
|
||||||
messageLinkRegex.lastIndex = 0;
|
messageLinkRegex.lastIndex = 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary>
|
<MessageEmbedAccessory
|
||||||
<MessageEmbedAccessory
|
message={props.message}
|
||||||
message={props.message}
|
/>
|
||||||
/>
|
|
||||||
</ErrorBoundary>
|
|
||||||
);
|
);
|
||||||
}, 4 /* just above rich embeds */);
|
}, 4 /* just above rich embeds */);
|
||||||
},
|
},
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
removeMessageAccessory("messageLinkEmbed");
|
removeMessageAccessory("MessageLinkEmbeds");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -204,5 +204,5 @@ export default definePlugin({
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
})
|
}, { noop: true })
|
||||||
});
|
});
|
||||||
|
|
|
@ -75,5 +75,5 @@ export default definePlugin({
|
||||||
}}> Pause Indefinitely.</a>}
|
}}> Pause Indefinitely.</a>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})
|
}, { noop: true })
|
||||||
});
|
});
|
||||||
|
|
|
@ -86,5 +86,5 @@ export default definePlugin({
|
||||||
</TooltipContainer>
|
</TooltipContainer>
|
||||||
)}
|
)}
|
||||||
</div>;
|
</div>;
|
||||||
})
|
}, { noop: true })
|
||||||
});
|
});
|
||||||
|
|
|
@ -125,7 +125,7 @@ function VencordPopoutButton() {
|
||||||
function ToolboxFragmentWrapper({ children }: { children: ReactNode[]; }) {
|
function ToolboxFragmentWrapper({ children }: { children: ReactNode[]; }) {
|
||||||
children.splice(
|
children.splice(
|
||||||
children.length - 1, 0,
|
children.length - 1, 0,
|
||||||
<ErrorBoundary noop={true}>
|
<ErrorBoundary noop>
|
||||||
<VencordPopoutButton />
|
<VencordPopoutButton />
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue