* ensure word not empty when lookup

* fix null issue

* fix undefined issue when video failed to add
This commit is contained in:
an-lee
2024-03-28 16:10:23 +08:00
committed by GitHub
parent 3f6d26ee1a
commit 848de1abdf
3 changed files with 7 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ export const StoryViewer = (props: {
const handleSelectionChanged = debounce(() => {
const selection = document.getSelection();
if (!selection?.anchorNode?.parentElement) return;
if (!ref.current?.contains(selection.anchorNode.parentElement)) return;
const word = selection

View File

@@ -51,6 +51,8 @@ export const TedTalksSegment = () => {
coverUrl: selectedTalk?.primaryImageSet[0].url,
})
.then((record) => {
if (!record) return;
if (type === "video") {
navigate(`/videos/${record.id}`);
} else {

View File

@@ -20,7 +20,10 @@ export const useAiCommand = () => {
sourceId?: string;
sourceType?: string;
}) => {
const { word, context, sourceId, sourceType } = params;
const { context, sourceId, sourceType } = params;
let { word } = params;
word = word.trim();
if (!word) return;
const lookup = await webApi.lookup({
word,