Unfurl notifications
Since we no longer have support for list-style notifications, stop coalescing notifications into batches and just show contents of the last message received. Also open the window when clicking on a notification if it has previously been closed. // FREEBIE
This commit is contained in:
parent
b5649a6874
commit
79872be9f5
2 changed files with 22 additions and 54 deletions
|
@ -98,6 +98,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
Whisper.Notifications.on('click', function(conversation) {
|
Whisper.Notifications.on('click', function(conversation) {
|
||||||
|
showWindow();
|
||||||
if (conversation) {
|
if (conversation) {
|
||||||
appView.openConversation(conversation);
|
appView.openConversation(conversation);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
Whisper.Notifications = new (Backbone.Collection.extend({
|
Whisper.Notifications = new (Backbone.Collection.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.on('add', _.debounce(this.update.bind(this), 1000));
|
this.on('add', this.update);
|
||||||
this.on('remove', this.onRemove);
|
this.on('remove', this.onRemove);
|
||||||
},
|
},
|
||||||
onclick: function() {
|
onclick: function() {
|
||||||
|
@ -59,61 +59,28 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.length > 1) {
|
var m = this.last();
|
||||||
var conversationIds = _.uniq(this.map(function(m) {
|
var type = 'basic';
|
||||||
return m.get('conversationId');
|
var message = i18n('newMessage');
|
||||||
}));
|
var imageUrl;
|
||||||
if (conversationIds.length === 1 && this.showSender()) {
|
if (this.showMessage()) {
|
||||||
iconUrl = this.at(0).get('iconUrl');
|
message = m.get('message');
|
||||||
|
if (m.get('imageUrl')) {
|
||||||
|
type = 'image';
|
||||||
|
imageUrl = m.get('imageUrl');
|
||||||
}
|
}
|
||||||
extension.notification.update({
|
|
||||||
type : 'list',
|
|
||||||
iconUrl : iconUrl,
|
|
||||||
title : title,
|
|
||||||
message : 'Most recent from ' + this.last().get('title'),
|
|
||||||
items : this.map(function(m) {
|
|
||||||
var message, title;
|
|
||||||
if (this.showMessage()) {
|
|
||||||
return {
|
|
||||||
title : m.get('title'),
|
|
||||||
message : m.get('message')
|
|
||||||
};
|
|
||||||
} else if (this.showSender()) {
|
|
||||||
return {
|
|
||||||
title : m.get('title'),
|
|
||||||
message : i18n('newMessage')
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}.bind(this)),
|
|
||||||
buttons : [{
|
|
||||||
title : 'Mark all as read',
|
|
||||||
iconUrl : 'images/check.svg'
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var m = this.at(0);
|
|
||||||
var type = 'basic';
|
|
||||||
var message = i18n('newMessage');
|
|
||||||
var imageUrl;
|
|
||||||
if (this.showMessage()) {
|
|
||||||
message = m.get('message');
|
|
||||||
if (m.get('imageUrl')) {
|
|
||||||
type = 'image';
|
|
||||||
imageUrl = m.get('imageUrl');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.showSender()) {
|
|
||||||
title = m.get('title');
|
|
||||||
iconUrl = m.get('iconUrl');
|
|
||||||
}
|
|
||||||
extension.notification.update({
|
|
||||||
type : type,
|
|
||||||
title : title,
|
|
||||||
message : message,
|
|
||||||
iconUrl : iconUrl,
|
|
||||||
imageUrl : imageUrl
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
if (this.showSender()) {
|
||||||
|
title = m.get('title');
|
||||||
|
iconUrl = m.get('iconUrl');
|
||||||
|
}
|
||||||
|
extension.notification.update({
|
||||||
|
type : type,
|
||||||
|
title : title,
|
||||||
|
message : message,
|
||||||
|
iconUrl : iconUrl,
|
||||||
|
imageUrl : imageUrl
|
||||||
|
});
|
||||||
},
|
},
|
||||||
getSetting: function() {
|
getSetting: function() {
|
||||||
return storage.get('notification-setting') || 'message';
|
return storage.get('notification-setting') || 'message';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue