Skip to content

Commit

Permalink
fix: Livechat Reactivity issues with createOrUpdateGuest (6.4.8 versi…
Browse files Browse the repository at this point in the history
…on) (#30993)
  • Loading branch information
MartinSchoeler committed Nov 20, 2023
1 parent 550900b commit a1c7f5c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/livechat/src/lib/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const createOrUpdateGuest = async (guest) => {
token && (await store.setState({ token }));
const { visitor: user } = await Livechat.grantVisitor({ visitor: { ...guest } });
store.setState({ user });
await loadConfig();
};

const updateIframeGuestData = (data) => {
Expand Down Expand Up @@ -141,8 +142,7 @@ const api = {
if (token === localToken) {
return;
}
createOrUpdateGuest({ token });
await loadConfig();
await createOrUpdateGuest({ token });
},

setGuestName(name) {
Expand All @@ -153,8 +153,8 @@ const api = {
updateIframeGuestData({ email });
},

registerGuest(data = {}) {
if (typeof data !== 'object') {
async registerGuest(data) {
if (!data || typeof data !== 'object') {
return;
}

Expand All @@ -166,7 +166,9 @@ const api = {
api.setDepartment(data.department);
}

createOrUpdateGuest(data);
Livechat.unsubscribeAll();

await createOrUpdateGuest(data);
},

async setLanguage(language) {
Expand Down

0 comments on commit a1c7f5c

Please sign in to comment.