Translate: Only add button in chat box
This commit is contained in:
parent
4d0a064425
commit
6e3cafce42
|
@ -37,9 +37,12 @@ export function TranslateIcon({ height = 24, width = 24, className }: { height?:
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TranslateChatBarIcon() {
|
export function TranslateChatBarIcon({ slateProps }: { slateProps: { type: { analyticsName: string; }; }; }) {
|
||||||
const { autoTranslate } = settings.use(["autoTranslate"]);
|
const { autoTranslate } = settings.use(["autoTranslate"]);
|
||||||
|
|
||||||
|
if (slateProps.type.analyticsName !== "normal")
|
||||||
|
return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip text="Open Translate Modal">
|
<Tooltip text="Open Translate Modal">
|
||||||
{({ onMouseEnter, onMouseLeave }) => (
|
{({ onMouseEnter, onMouseLeave }) => (
|
||||||
|
|
|
@ -45,7 +45,7 @@ export default definePlugin({
|
||||||
find: ".activeCommandOption",
|
find: ".activeCommandOption",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(.)\.push.{1,30}disabled:(\i),.{1,20}\},"gift"\)\)/,
|
match: /(.)\.push.{1,30}disabled:(\i),.{1,20}\},"gift"\)\)/,
|
||||||
replace: "$&;try{$2||$1.push($self.chatBarIcon())}catch{}",
|
replace: "$&;try{$2||$1.push($self.chatBarIcon(arguments[0]))}catch{}",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -82,5 +82,9 @@ export default definePlugin({
|
||||||
removeAccessory("vc-translation");
|
removeAccessory("vc-translation");
|
||||||
},
|
},
|
||||||
|
|
||||||
chatBarIcon: ErrorBoundary.wrap(TranslateChatBarIcon, { noop: true }),
|
chatBarIcon: (slateProps: any) => (
|
||||||
|
<ErrorBoundary noop>
|
||||||
|
<TranslateChatBarIcon slateProps={slateProps} />
|
||||||
|
</ErrorBoundary>
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue