Improve debug log for notifications

This commit is contained in:
Daniel Gasienica 2018-02-23 17:18:06 -05:00
parent b5e7882267
commit dbc242c37f

View file

@ -26,17 +26,22 @@
}, },
update: function() { update: function() {
const isFocused = window.isFocused(); const isFocused = window.isFocused();
const shouldPlayNotificationSound =
storage.get('audio-notification') || false;
const numNotifications = this.length;
console.log( console.log(
'updating notifications - count:', this.length, 'updating notifications:',
'focused:', isFocused, 'numNotifications:', numNotifications,
'isEnabled:', isEnabled 'isFocused:', isFocused,
'isEnabled:', isEnabled,
'shouldPlayNotificationSound:', shouldPlayNotificationSound
); );
if (!isEnabled) { if (!isEnabled) {
return; return;
} }
const hasNotifications = this.length > 0 const hasNotifications = numNotifications > 0;
if (!hasNotifications) { if (!hasNotifications) {
return; return;
} }
@ -63,8 +68,8 @@
// e.g. Russian: // e.g. Russian:
// http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html // http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html
var newMessageCount = [ var newMessageCount = [
this.length, numNotifications,
this.length === 1 ? i18n('newMessage') : i18n('newMessages') numNotifications === 1 ? i18n('newMessage') : i18n('newMessages')
].join(' '); ].join(' ');
var last = this.last(); var last = this.last();
@ -79,7 +84,7 @@
iconUrl = last.get('iconUrl'); iconUrl = last.get('iconUrl');
break; break;
case SETTINGS.MESSAGE: case SETTINGS.MESSAGE:
if (this.length === 1) { if (numNotifications === 1) {
title = last.get('title'); title = last.get('title');
} else { } else {
title = newMessageCount; title = newMessageCount;
@ -89,7 +94,6 @@
break; break;
} }
var shouldPlayNotificationSound = storage.get('audio-notification') || false;
if (window.config.polyfillNotifications) { if (window.config.polyfillNotifications) {
window.nodeNotifier.notify({ window.nodeNotifier.notify({
title: title, title: title,