Skip to content

Commit

Permalink
feat: fix conflict bug
Browse files Browse the repository at this point in the history
  • Loading branch information
smackgg committed Mar 29, 2023
1 parent 78f33a9 commit 63cbfc3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/common/components/content-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,26 @@ const ContentPanel = (props: IContentPanelProps) => {
setPromptType(p || promptType || query)
setResult("")
setSending(true)
await sendNotionPostToBackground({
prompt: query,
context: selectionText,
promptType: p || promptType,
onProgress: (e: IPostNotionProgress) => {
resultTemp += e.value.completion
if (!e.done) {
setResult(resultTemp)
} else {
setSending(false)

try {
await sendNotionPostToBackground({
prompt: query,
context: selectionText,
promptType: p || promptType,
onProgress: (e: IPostNotionProgress) => {
resultTemp += e.value.completion
if (!e.done) {
setResult(resultTemp)
} else {
setSending(false)
}
}
}
})
})
} catch (error) {
console.log(error, "error")
showToast(t("MessageProcessing"))
}

setSending(false)
}

Expand Down Expand Up @@ -186,7 +193,7 @@ const ContentPanel = (props: IContentPanelProps) => {
className="pl-12 pr-12 input input-bordered w-full rounded-none box-border h-12"
style={{
outline: "none",
minWidth: "700px"
minWidth: "900px"
}}
placeholder={t("AskInputPlaceholder") as string}
onChange={(event) => {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export const sendNotionPostToBackground = ({
prompt?: string
onProgress: (data: IPostNotionProgress) => void
}) => {
if (onProgressHandler) {
return Promise.reject("posting")
}

onProgressHandler = onProgress
postNotionAddEventListener()
return new Promise(async (resolve) => {
Expand Down

0 comments on commit 63cbfc3

Please sign in to comment.