@datlv-trustshop/shopify-inapp-components 0.1.11 → 0.1.12

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.
@@ -47,11 +47,20 @@ export class GlobalDashboardManager {
47
47
  if (config && !this.configEquals(this.lastConfig, config)) {
48
48
  this.updateGlobalConfig(config);
49
49
  }
50
- // Check if we have a pending locale refresh
51
- if (this.pendingLocaleRefresh && this.engine?.isInitialized()) {
50
+ // Check if we need to initialize due to pending locale refresh
51
+ // This handles the case where all providers have autoInit=false but want locale refresh
52
+ if (this.pendingLocaleRefresh && autoRefreshOnLocaleChange) {
52
53
  const locale = this.pendingLocaleRefresh;
53
54
  this.pendingLocaleRefresh = null;
54
- this.engine.setLocale(locale).catch(console.error);
55
+ // Force initialization with the new locale if not initialized
56
+ if (!this.engine || !this.engine.isInitialized()) {
57
+ if (this.lastConfig) {
58
+ this.init({ ...this.lastConfig, locale }).catch(console.error);
59
+ }
60
+ }
61
+ else {
62
+ this.engine.setLocale(locale).catch(console.error);
63
+ }
55
64
  }
56
65
  }
57
66
  /**
@@ -109,13 +118,17 @@ export class GlobalDashboardManager {
109
118
  }
110
119
  }
111
120
  else {
112
- // Engine not initialized yet, update locale and mark for refresh
121
+ // Engine not initialized yet
113
122
  this.engine.updateLocale(config.locale);
114
- this.pendingLocaleRefresh = config.locale;
115
- // If any provider wants refresh and we have providers, force initialization
116
- if (shouldRefresh && this.providers.size > 0) {
123
+ // If any provider wants refresh, force initialization NOW
124
+ // This is critical for autoInit=false providers
125
+ if (shouldRefresh) {
117
126
  this.init(config).catch(console.error);
118
127
  }
128
+ else {
129
+ // Mark for later refresh when a provider initializes
130
+ this.pendingLocaleRefresh = config.locale;
131
+ }
119
132
  }
120
133
  }
121
134
  }
@@ -220,13 +233,17 @@ export class GlobalDashboardManager {
220
233
  if (this.lastConfig) {
221
234
  this.lastConfig = { ...this.lastConfig, locale };
222
235
  }
236
+ // Check if any provider wants auto-refresh
237
+ const shouldRefresh = Array.from(this.providers.values()).some(p => p.autoRefreshOnLocaleChange);
223
238
  if (!this.engine) {
224
- // No engine yet, mark locale for refresh when engine is created
225
- this.pendingLocaleRefresh = locale;
226
- // If we have providers, initialize with the new locale
227
- if (this.providers.size > 0 && this.lastConfig) {
239
+ // No engine yet, but if any provider wants refresh, initialize NOW
240
+ if (shouldRefresh && this.lastConfig) {
228
241
  await this.init({ ...this.lastConfig, locale });
229
242
  }
243
+ else {
244
+ // Mark locale for refresh when engine is created
245
+ this.pendingLocaleRefresh = locale;
246
+ }
230
247
  return;
231
248
  }
232
249
  // Engine exists, update locale
@@ -234,9 +251,12 @@ export class GlobalDashboardManager {
234
251
  await this.engine.setLocale(locale);
235
252
  }
236
253
  else {
237
- // Engine not initialized, update locale and initialize
254
+ // Engine exists but not initialized
238
255
  this.engine.updateLocale(locale);
239
- await this.init();
256
+ // If any provider wants refresh, initialize now
257
+ if (shouldRefresh) {
258
+ await this.init();
259
+ }
240
260
  }
241
261
  }
242
262
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datlv-trustshop/shopify-inapp-components",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "private": false,
5
5
  "description": "React TypeScript components for Shopify in-app dashboard content",
6
6
  "main": "dist/index.js",