2017-02-27 18:53:04 +03:00
|
|
|
/**
|
|
|
|
* Settings Lib
|
|
|
|
* A collection of utilities for handling settings including a cache
|
|
|
|
*/
|
2019-06-25 19:33:56 +03:00
|
|
|
const models = require('../../models');
|
|
|
|
const SettingsCache = require('./cache');
|
2017-02-27 18:53:04 +03:00
|
|
|
|
|
|
|
module.exports = {
|
2020-07-06 18:09:43 +03:00
|
|
|
async init() {
|
|
|
|
const settingsCollection = await models.Settings.populateDefaults();
|
|
|
|
SettingsCache.init(settingsCollection);
|
2020-07-01 19:16:57 +03:00
|
|
|
},
|
|
|
|
|
2020-07-06 18:09:43 +03:00
|
|
|
async reinit() {
|
2020-07-01 19:16:57 +03:00
|
|
|
SettingsCache.shutdown();
|
2020-07-06 18:09:43 +03:00
|
|
|
const settingsCollection = await models.Settings.populateDefaults();
|
|
|
|
SettingsCache.init(settingsCollection);
|
|
|
|
for (const model of settingsCollection.models) {
|
|
|
|
model.emitChange(model.attributes.key + '.' + 'edited', {});
|
|
|
|
}
|
2017-02-27 18:53:04 +03:00
|
|
|
}
|
|
|
|
};
|