Add 'system' activities, use avatar as icon

* "System activities" are things like "follows" and "group joins"
* Use user avatar as browser notification icon.
master
Chimo 8 years ago
parent 78928f984b
commit 749d2f48d7

@ -20,13 +20,18 @@
Notification.requestPermission( function( permission ) {
if ( permission === "granted" ) {
var $node = $( node ),
noticeText = $.trim( $node.find( ".e-content" ).text() ),
content = $.trim( $node.find( ".e-content" ).text() ),
isRepeat = $node.find( ".repeat" ).length > 0,
isSystem = $node.find( ".system-activity" ).length > 0,
author,
repeater,
title;
title,
icon = $node.find( ".avatar" ).attr( "src" ) || "";
if ( isRepeat ) {
if ( isSystem ) {
title = "";
content = $.trim( $node.find( ".system-activity" ).text() );
} else if ( isRepeat ) {
author = $.trim( $node.find( ".notice-headers .h-card" ).first().text() );
repeater = $.trim( $node.find( ".repeat .p-author" ).text() );
title = repeater + " repeated a notice by " + author;
@ -35,7 +40,7 @@
title = "New notice from " + author;
}
new Notification( title, { body: noticeText } );
new Notification( title, { body: content, icon: icon } );
}
} );
};