fix: repeat rendering (#3)

This commit is contained in:
josc146
2023-03-16 09:31:15 +08:00
parent 135e148ef4
commit 6e8f8410d4
+9 -2
View File
@@ -1,4 +1,5 @@
import './styles.scss'
import { unmountComponentAtNode } from 'react-dom'
import { render } from 'preact'
import DecisionCard from '../components/DecisionCard'
import { config as siteConfig } from './site-adapters'
@@ -27,13 +28,19 @@ async function mountComponent(siteConfig, userConfig) {
)
return
document.querySelectorAll('.chat-gpt-container').forEach((e) => e.remove())
document.querySelectorAll('.chat-gpt-container').forEach((e) => {
unmountComponentAtNode(e)
e.remove()
})
let question
if (userConfig.inputQuery) question = await getInput([userConfig.inputQuery])
if (!question && siteConfig) question = await getInput(siteConfig.inputQuery)
document.querySelectorAll('.chat-gpt-container').forEach((e) => e.remove())
document.querySelectorAll('.chat-gpt-container').forEach((e) => {
unmountComponentAtNode(e)
e.remove()
})
const container = document.createElement('div')
container.className = 'chat-gpt-container'
render(