Browse Source

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 3 years ago
parent
commit
749d2f48d7
1 changed files with 9 additions and 4 deletions
  1. 9
    4
      js/browser-notifications.js

+ 9
- 4
js/browser-notifications.js View File

@@ -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 } );
}
} );
};

Loading…
Cancel
Save