fix(mediaPlaybackSpeed): add error boundary

This commit is contained in:
D3SOX 2024-06-06 09:02:40 +02:00
parent d2efeff84f
commit b24c50d213
No known key found for this signature in database
GPG key ID: 39EC1673FC37B048

View file

@ -7,6 +7,7 @@
import "./styles.css"; import "./styles.css";
import { classNameFactory } from "@api/Styles"; import { classNameFactory } from "@api/Styles";
import ErrorBoundary from "@components/ErrorBoundary";
import { makeRange } from "@components/PluginSettings/components"; import { makeRange } from "@components/PluginSettings/components";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
@ -24,7 +25,7 @@ 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(mediaRef: RefObject<HTMLMediaElement>) { playbackSpeedComponent: ErrorBoundary.wrap((mediaRef: RefObject<HTMLMediaElement>) => {
const changeSpeed = (speed: number) => { const changeSpeed = (speed: number) => {
const media = mediaRef.current; const media = mediaRef.current;
if (media) { if (media) {
@ -36,7 +37,7 @@ export default definePlugin({
<Tooltip text="Playback speed"> <Tooltip text="Playback speed">
{tooltipProps => ( {tooltipProps => (
<button <button
{...tooltipProps} {...tooltipProps}
className={cl("icon")} className={cl("icon")}
onClick={e => { onClick={e => {
ContextMenuApi.openContextMenu(e, () => ContextMenuApi.openContextMenu(e, () =>
@ -65,7 +66,7 @@ export default definePlugin({
)} )}
</Tooltip> </Tooltip>
); );
}, }),
patches: [ patches: [
// voice message embeds // voice message embeds