Skip to content

Commit 54d8bad

Browse files
committed
Update slack: Fix incorrect notification count
meetfranz/recipe-slack#13
1 parent f47c638 commit 54d8bad

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

slack.tar.gz

63 KB
Binary file not shown.

uncompressed/slack/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
"use strict";
2-
3-
module.exports = Franz => Franz;
1+
module.exports = Franz => Franz;

uncompressed/slack/webview.js

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
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';
83

94
const getTeamIcon = function getTeamIcon(count = 0) {
105
let countTeamIconCheck = count;
116
let bgUrl = null;
12-
const teamMenu = document.querySelector('#team-menu-trigger');
137

8+
const teamMenu = document.querySelector('#team-menu-trigger');
149
if (teamMenu) {
1510
teamMenu.click();
16-
const icon = document.querySelector('.c-team_icon');
1711

12+
const icon = document.querySelector('.c-team_icon');
1813
if (icon) {
1914
bgUrl = window.getComputedStyle(icon, null).getPropertyValue('background-image');
2015
bgUrl = /^url\((['"]?)(.*)\1\)$/.exec(bgUrl);
@@ -29,26 +24,30 @@ const getTeamIcon = function getTeamIcon(count = 0) {
2924
countTeamIconCheck += 1;
3025

3126
if (bgUrl) {
32-
_electron.ipcRenderer.sendToHost('avatar', bgUrl);
27+
ipcRenderer.sendToHost('avatar', bgUrl);
3328
} else if (countTeamIconCheck <= 5) {
3429
setTimeout(() => {
3530
getTeamIcon(countTeamIconCheck + 1);
3631
}, 2000);
3732
}
3833
};
39-
34+
// c-link p-channel_sidebar__channel p-channel_sidebar__channel--unread
4035
const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)';
4136

42-
module.exports = Franz => {
37+
module.exports = (Franz) => {
4338
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;
4540
const allMessages = document.querySelectorAll(SELECTOR_CHANNELS_UNREAD).length - directMessages;
41+
42+
// set Franz badge
4643
Franz.setBadge(directMessages, allMessages);
4744
};
48-
4945
Franz.loop(getMessages);
46+
5047
setTimeout(() => {
5148
getTeamIcon();
5249
}, 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

Comments
 (0)