Skip to content

Commit

Permalink
🐛 (share) Fix publicId null when publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 1, 2023
1 parent cc07389 commit eebcbb1
Showing 1 changed file with 37 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,37 +172,40 @@ export const TypebotProvider = ({
typebot,
])

const saveTypebot = useCallback(async () => {
if (!localTypebot || !typebot) return
const typebotToSave = { ...localTypebot }
if (dequal(omit(typebot, 'updatedAt'), omit(typebotToSave, 'updatedAt')))
return
setIsSavingLoading(true)
const { data, error } = await updateTypebotQuery(
typebotToSave.id,
typebotToSave
)
if (data?.typebot) setLocalTypebot({ ...data.typebot })
setIsSavingLoading(false)
if (error) {
showToast({ title: error.name, description: error.message })
return
}
mutate({
typebot: typebotToSave,
const saveTypebot = useCallback(
async (updates?: Partial<Typebot>) => {
if (!localTypebot || !typebot) return
const typebotToSave = { ...localTypebot, ...updates }
if (dequal(omit(typebot, 'updatedAt'), omit(typebotToSave, 'updatedAt')))
return
setIsSavingLoading(true)
const { data, error } = await updateTypebotQuery(
typebotToSave.id,
typebotToSave
)
if (data?.typebot) setLocalTypebot({ ...data.typebot })
setIsSavingLoading(false)
if (error) {
showToast({ title: error.name, description: error.message })
return
}
mutate({
typebot: typebotToSave,
publishedTypebot,
webhooks: webhooks ?? [],
})
window.removeEventListener('beforeunload', preventUserFromRefreshing)
},
[
localTypebot,
mutate,
publishedTypebot,
webhooks: webhooks ?? [],
})
window.removeEventListener('beforeunload', preventUserFromRefreshing)
}, [
localTypebot,
mutate,
publishedTypebot,
setLocalTypebot,
showToast,
typebot,
webhooks,
])
setLocalTypebot,
showToast,
typebot,
webhooks,
]
)

const savePublishedTypebot = async (newPublishedTypebot: PublicTypebot) => {
if (!localTypebot) return
Expand Down Expand Up @@ -232,9 +235,9 @@ export const TypebotProvider = ({
)

useEffect(() => {
Router.events.on('routeChangeStart', saveTypebot)
Router.events.on('routeChangeStart', () => saveTypebot())
return () => {
Router.events.off('routeChangeStart', saveTypebot)
Router.events.off('routeChangeStart', () => saveTypebot())
}
}, [saveTypebot])

Expand Down Expand Up @@ -266,13 +269,12 @@ export const TypebotProvider = ({
const publishTypebot = async () => {
if (!localTypebot) return
const newLocalTypebot = { ...localTypebot }
if (!publishedTypebot) {
if (!publishedTypebot || !localTypebot.publicId) {
const newPublicId =
localTypebot.publicId ??
parseDefaultPublicId(localTypebot.name, localTypebot.id)
updateLocalTypebot({ publicId: newPublicId })
newLocalTypebot.publicId = newPublicId
await saveTypebot()
await saveTypebot({ publicId: newPublicId })
}
if (publishedTypebot) {
await savePublishedTypebot({
Expand Down

4 comments on commit eebcbb1

@vercel
Copy link

@vercel vercel bot commented on eebcbb1 Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

vitamyway.com
am.nigerias.io
an.nigerias.io
app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.rslabs.pro
bots.bridge.ai
chat.hayuri.id
chicken.cr8.ai
gollum.riku.ai
gsbulletin.com
panther.cr7.ai
panther.cr8.ai
penguin.cr8.ai
talk.gocare.io
test.bot.gives
ticketfute.com
unicorn.cr8.ai
apo.nigerias.io
apr.nigerias.io
aso.nigerias.io
bot.ageenda.com
bot.artiweb.app
bot.devitus.com
bot.jesopizz.it
bot.reeplai.com
bot.scayver.com
bot.tc-mail.com
chat.lalmon.com
chat.sureb4.com
eventhub.com.au
fitness.riku.ai
games.klujo.com
sakuranembro.it
typebot.aloe.do
bot.contakit.com
bot.piccinato.co
bot.sv-energy.it
botc.ceox.com.br
clo.closeer.work
cockroach.cr8.ai
faqs.nigerias.io
feedback.ofx.one
form.syncwin.com
haymanevents.com
kw.wpwakanda.com
myrentalhost.com
stan.vselise.com
start.taxtree.io
typebot.aloe.bot
voicehelp.cr8.ai
zap.fundviser.in
app.chatforms.net
bot.hostnation.de
bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
bot.rihabilita.it
cares.urlabout.me
chat.gaswadern.de
fmm.wpwakanda.com
gentleman-shop.fr
k1.kandabrand.com
kp.pedroknoll.com
lb.ticketfute.com
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
support.triplo.ai
viewer.typebot.io
welcome.triplo.ai
1988.bouclidom.com
andreimayer.com.br
bot.danyservice.it
bot.iconicbrows.it
bot.megafox.com.br
bot.neferlopez.com
bots.robomotion.io
cadu.uninta.edu.br
dicanatural.online
digitalhelp.com.au
goalsettingbot.com
pant.maxbot.com.br
positivobra.com.br
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
bot.boston-voip.com
bot.cabinpromos.com
bot.digitalbled.com
bot.dsignagency.com
bot.eventhub.com.au
bot.jepierre.com.br
bot.ltmidias.com.br
bot.viralsangat.com
bot.winglabs.com.br
carsalesenquiry.com
chat.marius.digital
chatbot.matthesv.de

@vercel
Copy link

@vercel vercel bot commented on eebcbb1 Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on eebcbb1 Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
builder-v2-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on eebcbb1 Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io

Please sign in to comment.