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 @@
20 20
         Notification.requestPermission( function( permission ) {
21 21
             if ( permission === "granted" ) {
22 22
                 var $node = $( node ),
23
-                    noticeText = $.trim( $node.find( ".e-content" ).text() ),
23
+                    content = $.trim( $node.find( ".e-content" ).text() ),
24 24
                     isRepeat = $node.find( ".repeat" ).length > 0,
25
+                    isSystem = $node.find( ".system-activity" ).length > 0,
25 26
                     author,
26 27
                     repeater,
27
-                    title;
28
+                    title,
29
+                    icon = $node.find( ".avatar" ).attr( "src" ) || "";
28 30
 
29
-                if ( isRepeat ) {
31
+                if ( isSystem ) {
32
+                    title = "";
33
+                    content = $.trim( $node.find( ".system-activity" ).text() );
34
+                } else if ( isRepeat ) {
30 35
                     author = $.trim( $node.find( ".notice-headers .h-card" ).first().text() );
31 36
                     repeater = $.trim( $node.find( ".repeat .p-author" ).text() );
32 37
                     title = repeater + " repeated a notice by " + author;
@@ -35,7 +40,7 @@
35 40
                     title = "New notice from " + author;
36 41
                 }
37 42
 
38
-                new Notification( title, { body: noticeText } );
43
+                new Notification( title, { body: content, icon: icon } );
39 44
             }
40 45
         } );
41 46
     };

Loading…
Cancel
Save