not store locale if not present in app.config.json or changed by the language picker (#4431)

This commit is contained in:
Eugenio Romano
2019-03-13 16:50:34 +00:00
committed by GitHub
parent 5193a42983
commit 2b5b915d55
2 changed files with 30 additions and 1 deletions

View File

@@ -52,11 +52,19 @@ export class UserPreferencesService {
}
private initUserPreferenceStatus() {
this.set(UserPreferenceValues.Locale, (this.locale || this.getDefaultLocale()));
this.initUserLanguage();
this.set(UserPreferenceValues.PaginationSize, this.paginationSize);
this.set(UserPreferenceValues.SupportedPageSizes, JSON.stringify(this.supportedPageSizes));
}
private initUserLanguage() {
if (this.locale || this.appConfig.get<string>(UserPreferenceValues.Locale)) {
this.set(UserPreferenceValues.Locale, (this.locale || this.getDefaultLocale()));
} else {
this.setWithoutStore(UserPreferenceValues.Locale, (this.locale || this.getDefaultLocale()));
}
}
/**
* Sets up a callback to notify when a property has changed.
* @param property The property to watch
@@ -102,6 +110,19 @@ export class UserPreferencesService {
this.onChangeSubject.next(this.userPreferenceStatus);
}
/**
* Sets a preference property.
* @param property Name of the property
* @param value New value for the property
*/
setWithoutStore(property: string, value: any) {
if (!property) {
return;
}
this.userPreferenceStatus[property] = value;
this.onChangeSubject.next(this.userPreferenceStatus);
}
/**
* Check if an item is present in the storage
* @param property Name of the property