Skip to content

Commit

Permalink
fix(builtin): fix crash on converse api (#12205)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvitora committed Oct 26, 2022
1 parent c2f158c commit 0c9450e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/builtin/src/actions/switchLanguage.js
Expand Up @@ -14,9 +14,14 @@ async function getVisitorId(userId) {
*/
const switchLanguage = async language => {
event.state.user.language = language
await event.setFlag(bp.IO.WellKnownFlags.FORCE_PERSIST_STATE, true)

if (event.channel === 'api') {
return
}

const visitorId = await getVisitorId(event.target)
bp.realtime.sendPayload(bp.RealTimePayload.forVisitor(visitorId, 'webchat.data', { payload: { language } }))
await event.setFlag(bp.IO.WellKnownFlags.FORCE_PERSIST_STATE, true)
}

return switchLanguage(args.lang.toLowerCase())

0 comments on commit 0c9450e

Please sign in to comment.