Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #33221 from jrburke/bug1225122-email-notification-…
Browse files Browse the repository at this point in the history
…no-subject

Bug 1225122 - Notification for emails with no subject shows undefined r=asuth
  • Loading branch information
jrburke committed Nov 17, 2015
2 parents 6c761e2 + 4aec9c8 commit 6d68dfb
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions apps/email/js/sync.js
Expand Up @@ -77,12 +77,10 @@ define(function(require) {
});
}

titleL10n = titleL10n || 'notification-no-subject';

notificationHelper.send(titleL10n, notificationOptions)
.then(function(notification){
// If the app is open, but in the background, when the notification
// comes in, then we do not get notifived via our
// comes in, then we do not get notifived via our
// mozSetMessageHandler that is set elsewhere. Instead need to
// listen to click event and synthesize an "event" ourselves.
notification.onclick = function() {
Expand Down Expand Up @@ -152,8 +150,16 @@ define(function(require) {
model.latestOnce('account', function(currentAccount) {
fetchNotificationsData('sync').then(
function(existingNotificationsData) {
mozL10n.formatValue('senders-separation-sign').then(separator => {
fn(app, currentAccount, existingNotificationsData, separator);
mozL10n.formatValue('senders-separation-sign')
.then(function(separator) {
var localized = {
separator
};
mozL10n.formatValue('notification-no-subject')
.then(function(noSubject) {
localized.noSubject = noSubject;
fn(app, currentAccount, existingNotificationsData, localized);
});
});
});
});
Expand Down Expand Up @@ -250,7 +256,7 @@ define(function(require) {
// There are sync updates, get environment and figure out how to notify
// the user of the updates.
getSyncEnv(function(
app, currentAccount, existingNotificationsData, separator) {
app, currentAccount, existingNotificationsData, localized) {
var iconUrl = notificationHelper.getIconURI(app);

accountsResults.updates.forEach(function(result) {
Expand Down Expand Up @@ -327,8 +333,8 @@ define(function(require) {
}
};
}
bodyL10n = { raw: newFromNames.join(separator) };

bodyL10n = { raw: newFromNames.join(localized.separator) };

} else {
// Only one message to notify about.
Expand All @@ -343,8 +349,10 @@ define(function(require) {
fromNames: [info.from]
};

var rawSubject = info.subject || localized.noSubject;

if (model.getAccountCount() === 1) {
subjectL10n = { raw: info.subject };
subjectL10n = { raw: rawSubject };
bodyL10n = { raw: info.from };
} else {
subjectL10n = {
Expand All @@ -355,10 +363,10 @@ define(function(require) {
}
};
bodyL10n = {
id: 'new-emails-notify-multiple-accounts-body',
id: 'new-emails-notify-multiple-accounts-body',
args: {
from: info.from,
subject: info.subject
subject: rawSubject
}
};
}
Expand Down

0 comments on commit 6d68dfb

Please sign in to comment.