@developpement/tp-chatbot-widget 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/chatbot.js +8 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developpement/tp-chatbot-widget",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Chatbot widget for TravelPlanet / Makitizy",
5
5
  "main": "src/chatbot.js",
6
6
  "files": [
package/src/chatbot.js CHANGED
@@ -209,11 +209,13 @@
209
209
  if (!response.ok) return;
210
210
  const data = await response.json();
211
211
  const t = data.result?.result;
212
+ console.log('[fetchTheme] open_by_default:', t.open_by_default, typeof t.open_by_default);
212
213
  if (!t) return;
213
214
  if (CLIENT_THEMES[this.client_id]) {
214
215
  if (t.primary) CLIENT_THEMES[this.client_id].primary = t.primary;
215
216
  if (t.position) CLIENT_THEMES[this.client_id].position = t.position;
216
217
  if (t.name) CLIENT_THEMES[this.client_id].name = t.name;
218
+ if (t.open_by_default !== undefined) CLIENT_THEMES[this.client_id].open_by_default = t.open_by_default;
217
219
  } else {
218
220
  CLIENT_THEMES[this.client_id] = {
219
221
  primary: t.primary || DEFAULT_THEME.primary,
@@ -247,9 +249,12 @@
247
249
  this.attachEvents();
248
250
  this._initialized = true;
249
251
 
250
- setTimeout(() => {
251
- this.toggleChat();
252
- }, 300);
252
+ const theme = getClientTheme(this.client_id);
253
+ console.log('[widget] theme after fetch:', theme);
254
+
255
+ if (theme.open_by_default) {
256
+ setTimeout(() => this.toggleChat(), 300);
257
+ }
253
258
 
254
259
  if (this.access_token) {
255
260
  this.user_info = extractUserInfo(this.access_token);