Fix bugs (#457)
* ensure word not empty when lookup * fix null issue * fix undefined issue when video failed to add
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user