mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-11 02:16:23 +00:00
fix(mediaPlaybackSpeed): mediaRef is possibly undefined when 1 patch breaks
This commit is contained in:
parent
a8eea4dc7a
commit
c9459e9cf7
1 changed files with 35 additions and 33 deletions
|
@ -25,15 +25,16 @@ export default definePlugin({
|
||||||
description: "Adds an icon to change the playback speed of media embeds",
|
description: "Adds an icon to change the playback speed of media embeds",
|
||||||
authors: [Devs.D3SOX],
|
authors: [Devs.D3SOX],
|
||||||
|
|
||||||
playbackSpeedComponent: ErrorBoundary.wrap((mediaRef: RefObject<HTMLMediaElement>) => {
|
playbackSpeedComponent: (mediaRef: RefObject<HTMLMediaElement> | undefined) => {
|
||||||
const changeSpeed = (speed: number) => {
|
const changeSpeed = (speed: number) => {
|
||||||
const media = mediaRef.current;
|
const media = mediaRef?.current;
|
||||||
if (media) {
|
if (media) {
|
||||||
media.playbackRate = speed;
|
media.playbackRate = speed;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<ErrorBoundary noop>
|
||||||
<Tooltip text="Playback speed">
|
<Tooltip text="Playback speed">
|
||||||
{tooltipProps => (
|
{tooltipProps => (
|
||||||
<button
|
<button
|
||||||
|
@ -65,8 +66,9 @@ export default definePlugin({
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
// voice message embeds
|
// voice message embeds
|
||||||
|
|
Loading…
Reference in a new issue