Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function finishSync() {
evt.emit('cronSyncStop', accountsResults.accountIds);
// Mark this accountId set as no longer waiting.
var accountKey = makeAccountKey(accountsResults.accountIds);
waitingOnCron[accountKey] = false;
var stillWaiting = Object.keys(waitingOnCron).some(function(key) {
return !!waitingOnCron[key];
});
if (!hasBeenVisible && !stillWaiting) {
var msg = 'mail sync complete, closing mail app';
if (typeof plog === 'function') {
plog(msg);
} else {
console.log(msg);
}
this.msgVScroll.on('messagesComplete', function(newEmailCount) {
this.onNewMail(newEmailCount);
// Inform that content is ready. There could actually be a small delay
// with vScroll.updateDataBind from rendering the final display, but it
// is small enough that it is not worth trying to break apart the design
// to accommodate this metrics signal.
if (!this._emittedContentEvents) {
evt.emit('metrics:contentDone');
this._emittedContentEvents = true;
}
}.bind(this));
onFolderShown: function() {
var model = this.model,
account = model.account,
foldersSlice = model.foldersSlice;
// The extra checks here are to allow for lazy startup when we might have
// a card instance but not a full model available. Once the model is
// available though, this method will get called again, so the event
// emitting is still correctly done in the lazy startup case.
if (!document.hidden && account && foldersSlice && this.curFolder) {
var inboxFolder = foldersSlice.getFirstFolderWithType('inbox');
if (inboxFolder === this.curFolder) {
evt.emit('inboxShown', account.id);
}
// If user tapped in search box on message_list before the JS for the
// card is attached, then treat that as the signal to go to search. Only
// do this when first starting up though.
if (document.activeElement === this.searchTextTease) {
this.onSearchButton();
}
}
},
enableReply: function() {
var btn = this.querySelector('.msg-reply-btn');
btn.removeAttribute('aria-disabled');
// Inform that content is ready. Done here because reply is only enabled
// once the full body is available.
if (!this._emittedContentEvents) {
evt.emit('metrics:contentDone');
this._emittedContentEvents = true;
}
},
onShowMail: function() {
// Nuke this card
evt.emit('showLatestAccount');
},
this.composer.finishCompositionSendMessage(function(sendInfo) {
evt.emit('uiDataOperationStop', this._dataIdSendEmail);
// Card could have been destroyed in the meantime,
// via an app card reset (not a _selfClosed case),
// so do not bother with the rest of this work if
// that was the case.
if (!this.composer) {
return;
}
if (activity) {
// Just mention the action completed, but do not give
// specifics, to maintain some privacy.
activity.postResult('complete');
activity = null;
}
_emitStartupEvents: function(skipEmitContentEvents) {
if (!this._startupEventsEmitted) {
if (startupCacheEventsSent) {
// Cache already loaded, so at this point the content shown is wired
// to event handlers.
window.dispatchEvent(new CustomEvent('moz-content-interactive'));
} else {
// Cache was not used, so only now is the chrome dom loaded.
window.dispatchEvent(new CustomEvent('moz-chrome-dom-loaded'));
}
window.dispatchEvent(new CustomEvent('moz-chrome-interactive'));
// If a card that has a simple static content DOM, content is complete.
// Otherwise, like message_list, need backend data to call complete.
if (!skipEmitContentEvents) {
evt.emit('metrics:contentDone');
}
this._startupEventsEmitted = true;
}
},
onAddAnother: function() {
evt.emit('addAccount');
},
onShowMail: function() {
_closeCard: function() {
evt.emit('folderPickerClosing');
this.classList.remove('opened');
},
this.composer.saveDraft(function() {
evt.emit('uiDataOperationStop', this._dataIdSaveDraft);
if (callback) {
callback();
}
}.bind(this));
},