@papercups-io/chat-widget
Advanced tools
Comparing version 1.0.16-beta.1 to 1.0.16-beta.2
@@ -298,2 +298,29 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var PREFIX = '__PAPERCUPS__'; | ||
var get = function get(key) { | ||
var result = localStorage.getItem("" + PREFIX + key); | ||
if (!result) { | ||
return null; | ||
} | ||
try { | ||
return JSON.parse(result); | ||
} catch (e) { | ||
return result; | ||
} | ||
}; | ||
var set = function set(key, value) { | ||
localStorage.setItem("" + PREFIX + key, JSON.stringify(value)); | ||
}; | ||
var getCustomerId = function getCustomerId() { | ||
return get('__CUSTOMER_ID__'); | ||
}; | ||
var setCustomerId = function setCustomerId(id) { | ||
return set('__CUSTOMER_ID__', id); | ||
}; | ||
var IFRAME_URL = 'https://chat-window.vercel.app'; | ||
@@ -339,2 +366,3 @@ | ||
var iframeRef = React.useRef(null); | ||
var cachedCustomerId = getCustomerId(); | ||
var query = React.useRef(qs.stringify({ | ||
@@ -346,3 +374,4 @@ accountId: accountId, | ||
baseUrl: baseUrl, | ||
greeting: greeting | ||
greeting: greeting, | ||
customerId: cachedCustomerId | ||
})).current; | ||
@@ -381,2 +410,7 @@ var theme = getThemeConfig({ | ||
var handleCacheCustomerId = function handleCacheCustomerId(payload) { | ||
var customerId = payload.customerId; | ||
return setCustomerId(customerId); | ||
}; | ||
var handlers = function handlers(msg) { | ||
@@ -393,2 +427,5 @@ console.log('Handling in parent:', msg.data); | ||
case 'customer:created': | ||
return handleCacheCustomerId(payload); | ||
case 'conversation:join': | ||
@@ -395,0 +432,0 @@ return sendCustomerUpdate(payload); |
@@ -296,2 +296,29 @@ import React from 'react'; | ||
var PREFIX = '__PAPERCUPS__'; | ||
var get = function get(key) { | ||
var result = localStorage.getItem("" + PREFIX + key); | ||
if (!result) { | ||
return null; | ||
} | ||
try { | ||
return JSON.parse(result); | ||
} catch (e) { | ||
return result; | ||
} | ||
}; | ||
var set = function set(key, value) { | ||
localStorage.setItem("" + PREFIX + key, JSON.stringify(value)); | ||
}; | ||
var getCustomerId = function getCustomerId() { | ||
return get('__CUSTOMER_ID__'); | ||
}; | ||
var setCustomerId = function setCustomerId(id) { | ||
return set('__CUSTOMER_ID__', id); | ||
}; | ||
var IFRAME_URL = 'https://chat-window.vercel.app'; | ||
@@ -337,2 +364,3 @@ | ||
var iframeRef = React.useRef(null); | ||
var cachedCustomerId = getCustomerId(); | ||
var query = React.useRef(qs.stringify({ | ||
@@ -344,3 +372,4 @@ accountId: accountId, | ||
baseUrl: baseUrl, | ||
greeting: greeting | ||
greeting: greeting, | ||
customerId: cachedCustomerId | ||
})).current; | ||
@@ -379,2 +408,7 @@ var theme = getThemeConfig({ | ||
var handleCacheCustomerId = function handleCacheCustomerId(payload) { | ||
var customerId = payload.customerId; | ||
return setCustomerId(customerId); | ||
}; | ||
var handlers = function handlers(msg) { | ||
@@ -391,2 +425,5 @@ console.log('Handling in parent:', msg.data); | ||
case 'customer:created': | ||
return handleCacheCustomerId(payload); | ||
case 'conversation:join': | ||
@@ -393,0 +430,0 @@ return sendCustomerUpdate(payload); |
{ | ||
"name": "@papercups-io/chat-widget", | ||
"version": "1.0.16-beta.1", | ||
"version": "1.0.16-beta.2", | ||
"description": "Papercups chat widget", | ||
@@ -5,0 +5,0 @@ "author": "reichert621", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
111760
2008