Fix unhandled errors (#617)
* fix undefined * prevent story preview unless url provided * refactor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useContext, useState } from "react";
|
||||
import { useEffect, useContext } from "react";
|
||||
import { MediaPlayerProviderContext } from "@renderer/context";
|
||||
import {
|
||||
MediaLoadingModal,
|
||||
|
||||
@@ -417,7 +417,7 @@ export const MediaCurrentRecording = () => {
|
||||
|
||||
useHotkeys(
|
||||
currentHotkeys.PlayOrPauseRecording,
|
||||
(keyboardEvent, hotkeyEvent) => {
|
||||
(keyboardEvent, _hotkeyEvent) => {
|
||||
if (!player) return;
|
||||
keyboardEvent.preventDefault();
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ export const WavesurferPlayer = (props: {
|
||||
const [duration, setDuration] = useState<number>(0);
|
||||
|
||||
const onPlayClick = useCallback(() => {
|
||||
if (!wavesurfer) return;
|
||||
|
||||
wavesurfer.isPlaying() ? wavesurfer.pause() : wavesurfer.play();
|
||||
}, [wavesurfer]);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ export const StoryForm = () => {
|
||||
placeholder={t("inputUrlToStartReading")}
|
||||
/>
|
||||
<Button
|
||||
disabled={!url}
|
||||
onClick={() =>
|
||||
navigate(`/stories/preview/${encodeURIComponent(url)}`)
|
||||
}
|
||||
|
||||
@@ -443,8 +443,8 @@ export const MediaPlayerProvider = ({
|
||||
setDecoded(true);
|
||||
}),
|
||||
wavesurfer.on("error", (err: Error) => {
|
||||
toast.error(err.message);
|
||||
setDecodeError(err.message);
|
||||
toast.error(err?.message || "Error occurred while decoding audio");
|
||||
setDecodeError(err?.message || "Error occurred while decoding audio");
|
||||
}),
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user