Skip to content

Commit 63cbfc3

Browse files
committed
feat: fix conflict bug
1 parent 78f33a9 commit 63cbfc3

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

src/common/components/content-panel.tsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,26 @@ const ContentPanel = (props: IContentPanelProps) => {
9292
setPromptType(p || promptType || query)
9393
setResult("")
9494
setSending(true)
95-
await sendNotionPostToBackground({
96-
prompt: query,
97-
context: selectionText,
98-
promptType: p || promptType,
99-
onProgress: (e: IPostNotionProgress) => {
100-
resultTemp += e.value.completion
101-
if (!e.done) {
102-
setResult(resultTemp)
103-
} else {
104-
setSending(false)
95+
96+
try {
97+
await sendNotionPostToBackground({
98+
prompt: query,
99+
context: selectionText,
100+
promptType: p || promptType,
101+
onProgress: (e: IPostNotionProgress) => {
102+
resultTemp += e.value.completion
103+
if (!e.done) {
104+
setResult(resultTemp)
105+
} else {
106+
setSending(false)
107+
}
105108
}
106-
}
107-
})
109+
})
110+
} catch (error) {
111+
console.log(error, "error")
112+
showToast(t("MessageProcessing"))
113+
}
114+
108115
setSending(false)
109116
}
110117

@@ -186,7 +193,7 @@ const ContentPanel = (props: IContentPanelProps) => {
186193
className="pl-12 pr-12 input input-bordered w-full rounded-none box-border h-12"
187194
style={{
188195
outline: "none",
189-
minWidth: "700px"
196+
minWidth: "900px"
190197
}}
191198
placeholder={t("AskInputPlaceholder") as string}
192199
onChange={(event) => {

src/lib/notion.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export const sendNotionPostToBackground = ({
3131
prompt?: string
3232
onProgress: (data: IPostNotionProgress) => void
3333
}) => {
34+
if (onProgressHandler) {
35+
return Promise.reject("posting")
36+
}
37+
3438
onProgressHandler = onProgress
3539
postNotionAddEventListener()
3640
return new Promise(async (resolve) => {

0 commit comments

Comments
 (0)