11$ ( ( ) => {
22 /**
3- * @param {QPixelNotification } notification
3+ * @param {QPixelNotification } notification
44 */
55 const makeNotification = ( notification ) => {
66 const template = `<div class="js-notification widget h-m-0 h-m-b-2 ${ notification . is_read ? 'read' : 'is-teal' } ">
77 <div class="widget--body h-p-2">
88 <div class="h-c-tertiary-600 h-fs-caption">
99 ${ notification . community_name } ·
1010 <span class="js-notif-state">${ notification . is_read ? 'read' : `<strong>unread</strong>` } </span> ·
11- <span data-livestamp ="${ notification . created_at } ">${ notification . created_at } </span>
11+ <span title ="${ notification . created_at } ">${ QPixel . DOM . formatTimestamp ( notification . created_at ) } </span>
1212 </div>
1313 <p><a href="${ notification . link } " data-id="${ notification . id } "
1414 class="h-fw-bold is-not-underlined ${ notification . is_read ? 'read' : '' } notification-link">${ notification . content } </a></p>
@@ -22,7 +22,7 @@ $(() => {
2222 } ;
2323
2424 /**
25- * @param {number } change
25+ * @param {number } change
2626 */
2727 const changeInboxCount = ( change ) => {
2828 const counter = $ ( '.inbox-count' ) ;
@@ -51,20 +51,20 @@ $(() => {
5151 $ ( '.inbox-toggle' ) . on ( 'click' , async ( ev ) => {
5252 ev . preventDefault ( ) ;
5353 const $inbox = $ ( '.inbox' ) ;
54- if ( $inbox . hasClass ( " is-active" ) ) {
54+ if ( $inbox . hasClass ( ' is-active' ) ) {
5555 const data = await QPixel . getNotifications ( ) ;
5656
57- const $inboxContainer = $inbox . find ( " .inbox--container" ) ;
57+ const $inboxContainer = $inbox . find ( ' .inbox--container' ) ;
5858 $inboxContainer . html ( '' ) ;
59-
59+
6060 const unread = data . filter ( ( n ) => ! n . is_read ) ;
6161 const read = data . filter ( ( n ) => n . is_read ) ;
62-
62+
6363 unread . forEach ( ( notification ) => {
6464 const item = $ ( makeNotification ( notification ) ) ;
6565 $inboxContainer . append ( item ) ;
6666 } ) ;
67-
67+
6868 $inboxContainer . append ( `<div role="separator" class="header-slide--separator"></div>` ) ;
6969 read . forEach ( ( notification ) => {
7070 const item = $ ( makeNotification ( notification ) ) ;
@@ -76,9 +76,13 @@ $(() => {
7676 $ ( '.js-read-all-notifs' ) . on ( 'click' , async ( ev ) => {
7777 ev . preventDefault ( ) ;
7878
79- await QPixel . fetchJSON ( '/notifications/read_all' , { } , {
80- headers : { 'Accept' : 'application/json' }
81- } ) ;
79+ await QPixel . fetchJSON (
80+ '/notifications/read_all' ,
81+ { } ,
82+ {
83+ headers : { Accept : 'application/json' } ,
84+ } ,
85+ ) ;
8286
8387 $ ( '.inbox-count' ) . remove ( ) ;
8488
@@ -91,9 +95,13 @@ $(() => {
9195 const $tgt = $ ( evt . target ) ;
9296 const id = $tgt . data ( 'id' ) ;
9397
94- const resp = await QPixel . fetchJSON ( `/notifications/${ id } /read` , { } , {
95- headers : { 'Accept' : 'application/json' }
96- } ) ;
98+ const resp = await QPixel . fetchJSON (
99+ `/notifications/${ id } /read` ,
100+ { } ,
101+ {
102+ headers : { Accept : 'application/json' } ,
103+ } ,
104+ ) ;
97105
98106 const data = await resp . json ( ) ;
99107 $tgt . parents ( '.js-notification' ) [ 0 ] . outerHTML = makeNotification ( data . notification ) ;
@@ -106,9 +114,13 @@ $(() => {
106114 const $tgt = $ ( ev . target ) . is ( 'a' ) ? $ ( ev . target ) : $ ( ev . target ) . parents ( 'a' ) ;
107115 const id = $tgt . attr ( 'data-notif-id' ) ;
108116
109- const resp = await QPixel . fetchJSON ( `/notifications/${ id } /read` , { } , {
110- headers : { 'Accept' : 'application/json' }
111- } ) ;
117+ const resp = await QPixel . fetchJSON (
118+ `/notifications/${ id } /read` ,
119+ { } ,
120+ {
121+ headers : { Accept : 'application/json' } ,
122+ } ,
123+ ) ;
112124
113125 const data = await resp . json ( ) ;
114126 if ( data . status !== 'success' ) {
0 commit comments