fix: Prevent duplicate chat creation in the web widget during latency (#10745)

This commit is contained in:
Sivin Varghese
2025-01-23 12:53:28 +05:30
committed by GitHub
parent be8205657e
commit d3d39a81d6
10 changed files with 90 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ import {
SET_WIDGET_APP_CONFIG,
SET_WIDGET_COLOR,
TOGGLE_WIDGET_OPEN,
SET_ROUTE_UPDATE_STATE,
} from '../types';
const state = {
@@ -19,6 +20,7 @@ const state = {
widgetColor: '',
widgetStyle: 'standard',
darkMode: 'light',
isUpdatingRoute: false,
};
export const getters = {
@@ -31,6 +33,7 @@ export const getters = {
isWidgetStyleFlat: $state => $state.widgetStyle === 'flat',
darkMode: $state => $state.darkMode,
getShowUnreadMessagesDialog: $state => $state.showUnreadMessagesDialog,
getIsUpdatingRoute: _state => _state.isUpdatingRoute,
};
export const actions = {
@@ -69,6 +72,13 @@ export const actions = {
setBubbleVisibility({ commit }, hideMessageBubble) {
commit(SET_BUBBLE_VISIBILITY, hideMessageBubble);
},
setRouteTransitionState: async ({ commit }, status) => {
// Handles the routing state during navigation to different screen
// Called before the navigation starts and after navigation completes
// Handling this state in app/javascript/widget/router.js
// See issue: https://github.com/chatwoot/chatwoot/issues/10736
commit(SET_ROUTE_UPDATE_STATE, status);
},
};
export const mutations = {
@@ -96,6 +106,9 @@ export const mutations = {
[SET_COLOR_SCHEME]($state, darkMode) {
$state.darkMode = darkMode;
},
[SET_ROUTE_UPDATE_STATE]($state, status) {
$state.isUpdatingRoute = status;
},
};
export default {