Listen to mail config change event correctly

This commit is contained in:
Girish Ramakrishnan
2016-08-31 07:46:00 -07:00
parent 0eab262084
commit 42b65baa39
2 changed files with 6 additions and 4 deletions

View File

@@ -34,11 +34,15 @@ var apps = require('./apps.js'),
var gAddonVars = null,
gPlatformReadyTimer = null;
var NOOP_CALLBACK = function (error) { if (error) debug(error); };
function initialize(callback) {
if (process.env.BOX_ENV === 'test' && !process.env.CREATE_INFRA) return callback();
debug('initializing addon infrastructure');
settings.events.on(settings.MAIL_CONFIG_KEY, function () { startMail(NOOP_CALLBACK); });
var existingInfra = { version: 'none' };
if (fs.existsSync(paths.INFRA_VERSION_FILE)) {
existingInfra = safe.JSON.parse(fs.readFileSync(paths.INFRA_VERSION_FILE, 'utf8'));
@@ -74,8 +78,6 @@ function initialize(callback) {
exports.events.emit(exports.EVENT_READY);
}, 30000);
settings.events.on(exports.MAIL_CONFIG_KEY, startMail);
callback();
});
}
@@ -83,7 +85,7 @@ function initialize(callback) {
function uninitialize(callback) {
clearTimeout(gPlatformReadyTimer);
gPlatformReadyTimer = null;
settings.events.removeListener(exports.MAIL_CONFIG_KEY, startMail);
settings.events.removeListener(settings.MAIL_CONFIG_KEY, startMail);
callback();
}