valtech-components 4.0.1038 → 4.0.1039

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.
@@ -70,7 +70,7 @@ import fixWebmDuration from 'fix-webm-duration';
70
70
  * Current version of valtech-components.
71
71
  * This is automatically updated during the publish process.
72
72
  */
73
- const VERSION = '4.0.1038';
73
+ const VERSION = '4.0.1039';
74
74
 
75
75
  function evaluateValtechAccess(rule, context, features = {}, visitedFeatures = new Set()) {
76
76
  if (rule == null)
@@ -1876,13 +1876,18 @@ class I18nService {
1876
1876
  console.warn(`[i18n] Language '${lang}' not in supported languages`);
1877
1877
  return;
1878
1878
  }
1879
- if (lang === this._lang()) {
1880
- return;
1881
- }
1882
- // Persistir en localStorage (browser-only)
1879
+ // Aunque el signal ya tenga este valor, re-persistimos. Esto corrige
1880
+ // estados viejos donde la UI quedó en el idioma correcto por snapshot, pero
1881
+ // localStorage conservó otro valor y el siguiente bootstrap volvió al viejo.
1883
1882
  if (this.isBrowser) {
1884
1883
  localStorage.setItem(LANG_STORAGE_KEY$1, lang);
1885
1884
  }
1885
+ if (lang === this._lang()) {
1886
+ if (forceReload && this.isBrowser) {
1887
+ window.location.reload();
1888
+ }
1889
+ return;
1890
+ }
1886
1891
  // Actualizar signal
1887
1892
  this._lang.set(lang);
1888
1893
  // Fallback: recargar si se solicita
@@ -10651,7 +10656,11 @@ class AuthService {
10651
10656
  handle: profile.handle ?? null,
10652
10657
  avatarUrl: profile.avatarUrl ?? null,
10653
10658
  phone: profile.phone ?? null,
10654
- })), catchError(error => this.handleAuthError(error)));
10659
+ })), tap(profile => {
10660
+ if (this.i18nService && profile.language) {
10661
+ this.i18nService.setLanguage(profile.language);
10662
+ }
10663
+ }), catchError(error => this.handleAuthError(error)));
10655
10664
  }
10656
10665
  /**
10657
10666
  * Actualiza el perfil del usuario. Sincroniza state con los nuevos values
@@ -59765,9 +59774,13 @@ class PreferencesService {
59765
59774
  .docChanges(`users/${userId}/preferences`, 'main')
59766
59775
  .subscribe(doc => {
59767
59776
  if (!doc) {
59768
- // Doc no existe aún (user nuevo, sin primer sync). Mantenemos
59769
- // defaults locales pero NO marcamos synced — los side-effects no
59770
- // pisan el theme/lang locales con valores arbitrarios.
59777
+ // Doc no existe aún para esta app. Antes dejábamos la app con
59778
+ // localStorage/navigator, aunque el usuario ya tuviera idioma
59779
+ // canónico en auth. Resultado: cuenta en español, app nueva en inglés
59780
+ // hasta cambiar manualmente a inglés y volver a español. Hidratar
59781
+ // desde perfil canónico corrige ese primer arranque y además crea el
59782
+ // mirror de esta app.
59783
+ this.hydrateMissingPreferencesFromProfile(userId);
59771
59784
  return;
59772
59785
  }
59773
59786
  // Ignorar emisiones del listener mientras hay un update() en vuelo: un
@@ -59792,8 +59805,25 @@ class PreferencesService {
59792
59805
  this.subscription?.unsubscribe();
59793
59806
  this.subscription = undefined;
59794
59807
  this.currentUserId = undefined;
59808
+ this.missingDocHydrationUserId = undefined;
59795
59809
  this._synced.set(false);
59796
59810
  }
59811
+ hydrateMissingPreferencesFromProfile(userId) {
59812
+ if (this.missingDocHydrationUserId === userId)
59813
+ return;
59814
+ this.missingDocHydrationUserId = userId;
59815
+ void firstValueFrom(this.auth.getProfile())
59816
+ .then(profile => {
59817
+ const language = profile.language;
59818
+ if (language === 'es' || language === 'en') {
59819
+ this._language.set(language);
59820
+ this.i18n?.setLanguage(language);
59821
+ this._synced.set(true);
59822
+ void this.update({ language }).catch(() => undefined);
59823
+ }
59824
+ })
59825
+ .catch(() => undefined);
59826
+ }
59797
59827
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: PreferencesService, deps: [{ token: VALTECH_AUTH_CONFIG }, { token: FirestoreService }, { token: AuthService }, { token: i1$3.HttpClient }, { token: FirebaseService, optional: true }, { token: ThemeService, optional: true }, { token: FontSizeService, optional: true }, { token: I18nService, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
59798
59828
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: PreferencesService, providedIn: 'root' }); }
59799
59829
  }