1
- "use strict" ;
2
-
3
- var _electron = require ( "electron" ) ;
4
-
5
- var _path = _interopRequireDefault ( require ( "path" ) ) ;
6
-
7
- function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
1
+ import { ipcRenderer } from 'electron' ;
2
+ import path from 'path' ;
8
3
9
4
const getTeamIcon = function getTeamIcon ( count = 0 ) {
10
5
let countTeamIconCheck = count ;
11
6
let bgUrl = null ;
12
- const teamMenu = document . querySelector ( '#team-menu-trigger' ) ;
13
7
8
+ const teamMenu = document . querySelector ( '#team-menu-trigger' ) ;
14
9
if ( teamMenu ) {
15
10
teamMenu . click ( ) ;
16
- const icon = document . querySelector ( '.c-team_icon' ) ;
17
11
12
+ const icon = document . querySelector ( '.c-team_icon' ) ;
18
13
if ( icon ) {
19
14
bgUrl = window . getComputedStyle ( icon , null ) . getPropertyValue ( 'background-image' ) ;
20
15
bgUrl = / ^ u r l \( ( [ ' " ] ? ) ( .* ) \1\) $ / . exec ( bgUrl ) ;
@@ -29,26 +24,30 @@ const getTeamIcon = function getTeamIcon(count = 0) {
29
24
countTeamIconCheck += 1 ;
30
25
31
26
if ( bgUrl ) {
32
- _electron . ipcRenderer . sendToHost ( 'avatar' , bgUrl ) ;
27
+ ipcRenderer . sendToHost ( 'avatar' , bgUrl ) ;
33
28
} else if ( countTeamIconCheck <= 5 ) {
34
29
setTimeout ( ( ) => {
35
30
getTeamIcon ( countTeamIconCheck + 1 ) ;
36
31
} , 2000 ) ;
37
32
}
38
33
} ;
39
-
34
+ // c-link p-channel_sidebar__channel p-channel_sidebar__channel--unread
40
35
const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)' ;
41
36
42
- module . exports = Franz => {
37
+ module . exports = ( Franz ) => {
43
38
const getMessages = ( ) => {
44
- const directMessages = document . querySelectorAll ( `${ SELECTOR_CHANNELS_UNREAD } .p-channel_sidebar__badge, .p-channel_sidebar__link--unread` ) . length ;
39
+ const directMessages = document . querySelectorAll ( `${ SELECTOR_CHANNELS_UNREAD } .p-channel_sidebar__badge, .p-channel_sidebar__link--unread:not([data-sidebar-link-id="Punreads"] ` ) . length ;
45
40
const allMessages = document . querySelectorAll ( SELECTOR_CHANNELS_UNREAD ) . length - directMessages ;
41
+
42
+ // set Franz badge
46
43
Franz . setBadge ( directMessages , allMessages ) ;
47
44
} ;
48
-
49
45
Franz . loop ( getMessages ) ;
46
+
50
47
setTimeout ( ( ) => {
51
48
getTeamIcon ( ) ;
52
49
} , 4000 ) ;
53
- Franz . injectCSS ( _path . default . join ( __dirname , 'service.css' ) ) ;
54
- } ;
50
+
51
+ // inject franz.css stylesheet
52
+ Franz . injectCSS ( path . join ( __dirname , 'service.css' ) ) ;
53
+ } ;
0 commit comments