mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 04:22:15 +08:00
b6f0b634fb
Improved Knockout observableArray
36 lines
994 B
JavaScript
36 lines
994 B
JavaScript
import ko from 'ko';
|
|
|
|
class LanguageStore {
|
|
constructor() {
|
|
this.languages = ko.observableArray();
|
|
this.languagesAdmin = ko.observableArray();
|
|
|
|
this.language = ko
|
|
.observable('')
|
|
.extend({ limitedList: this.languages, reversible: true });
|
|
|
|
this.languageAdmin = ko
|
|
.observable('')
|
|
.extend({ limitedList: this.languagesAdmin, reversible: true });
|
|
|
|
this.userLanguage = ko.observable('');
|
|
this.userLanguageAdmin = ko.observable('');
|
|
}
|
|
|
|
populate() {
|
|
const Settings = rl.settings,
|
|
aLanguages = Settings.app('languages'),
|
|
aLanguagesAdmin = Settings.app('languagesAdmin');
|
|
|
|
this.languages(Array.isArray(aLanguages) ? aLanguages : []);
|
|
this.languagesAdmin(Array.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
|
|
|
|
this.language(Settings.get('Language'));
|
|
this.languageAdmin(Settings.get('LanguageAdmin'));
|
|
|
|
this.userLanguage(Settings.get('UserLanguage'));
|
|
this.userLanguageAdmin(Settings.get('UserLanguageAdmin'));
|
|
}
|
|
}
|
|
|
|
export default new LanguageStore();
|