Skip to content

Commit

Permalink
refactor(react): remove locale from initial session and make use of m…
Browse files Browse the repository at this point in the history
…erge func
  • Loading branch information
vanbasten17 committed Oct 29, 2021
1 parent 94032e7 commit dde5fa6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/botonic-core/src/hubtype-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class HubtypeService {
}

handleConnectionChange(online: boolean): void {
this.onPusherEvent({ action: 'connectionChange', online })
this.onPusherEvent({ action: 'connection_change', online })
}

onPusherEvent(event: any): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/botonic-react/src/experimental/webchat-app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class WebchatApp {

onServiceEvent(event) {
const { action, ...eventData } = event
if (action === 'connectionChange')
if (action === 'connection_change')
this.webchatRef.current.setOnline(event.online)
else if (action === 'update_message_info') {
this.updateMessageInfo(eventData.id, eventData)
Expand Down
1 change: 0 additions & 1 deletion packages/botonic-react/src/experimental/webchat/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const initialBotState = {
lastRoutePath: null,
isFirstInteraction: true,
retries: 0,
locale: undefined,
isHandoff: false,
isShadowing: false,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ const initialBotState = {
botId: '0000000',
isFirstInteraction: true,
retries: 0,
locale: undefined,
lastRoutePath: null,
isHandoff: false,
isShadowing: false,
Expand Down
6 changes: 3 additions & 3 deletions packages/botonic-react/src/experimental/webchat/webchat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export const Webchat = forwardRef((props, ref) => {
session,
botState,
} = botonicState || {}
updateUser({ ...initialUser, ...initUser(user) })
updateUser(merge(initialUser, initUser(user)))

if (shouldKeepSessionOnReload({ initialDevSettings, devSettings })) {
if (messages) {
Expand All @@ -339,11 +339,11 @@ export const Webchat = forwardRef((props, ref) => {
updateSession(merge(initialSession, session))
}
if (initialBotState) {
updateBotState({ ...initialBotState, ...botState })
updateBotState(merge(initialBotState, botState))
}
} else {
updateSession(merge(initialSession, session))
updateBotState({ ...initialBotState, ...botState })
updateBotState(merge(initialBotState, botState))
}
if (devSettings) updateDevSettings(devSettings)
else if (initialDevSettings) updateDevSettings(initialDevSettings)
Expand Down
2 changes: 1 addition & 1 deletion packages/botonic-react/src/webchat-app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class WebchatApp {
}

onServiceEvent(event) {
if (event.action === 'connectionChange') {
if (event.action === 'connection_change') {
this.onConnectionChange && this.onConnectionChange(this, event.online)
this.webchatRef.current.setOnline(event.online)
} else if (event.action === 'update_message_info')
Expand Down

0 comments on commit dde5fa6

Please sign in to comment.