Skip to content

Commit 5490145

Browse files
committed
More accurate notification count and improved the "Open Ghetto Skype
when recieving message" setting
1 parent 6737482 commit 5490145

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

app/GhettoSkype.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class GhettoSkype {
9090
openSettings() {
9191
if (this.settingsWindow) {
9292
this.settingsWindow.show();
93+
this.settingsWindow.focus();
9394
return;
9495
}
9596

@@ -102,6 +103,7 @@ class GhettoSkype {
102103
zoomFactor: this.settings.ZoomFactor
103104
}
104105
});
106+
this.settingsWindow.focus();
105107

106108
if (this.settings.Theme) {
107109
let folder = path.join(__dirname, '..', 'themes', this.settings.Theme);

app/tray.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ exports.setNotificationCount = function(count) {
2525
}
2626

2727
let image = basePath;
28-
2928
if (count > 0) {
3029
image += 'skype24-1.png';
3130
mainWindow.flashFrame(true);
3231
if (GhettoSkype.settings.OpenWhenMessaged) {
33-
GhettoSkype.sendToRenderers('read-latest-thread');
32+
// Do not click threads once a user reads one
33+
if (count > lastCount) {
34+
GhettoSkype.sendToRenderers('read-latest-thread');
35+
}
36+
3437
mainWindow.show();
3538
mainWindow.focus();
3639
}

views/preload.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
});
2020

2121
ipc.on('read-latest-thread', function(event) {
22-
document.querySelector(".recent.message").click();
22+
$('.unseenNotifications:first').closest('.message').get(0).click();
2323
});
2424

2525
ipc.on('settings-updated', function(event, settings) {
@@ -32,17 +32,6 @@
3232
setActivityHandle(settings.RefreshInterval);
3333
});
3434

35-
setInterval(function() {
36-
let hasNotifications = document.querySelector('.unseenNotifications');
37-
let count = 0;
38-
39-
if (hasNotifications) {
40-
count = 1;
41-
}
42-
43-
ipc.sendToHost('notification-count', count);
44-
}, 1000);
45-
4635
window.addEventListener("DOMContentLoaded", function(event) {
4736
$ = require('../assets/jquery-2.2.3.min');
4837

@@ -63,6 +52,30 @@
6352
hasActivity = true;
6453
});
6554
}
55+
56+
// Get an accurate notification count... we can't parse it out of the title
57+
// because Web Skype has a bug
58+
let lastCount = 0;
59+
setInterval(function() {
60+
// Gets a numeric representation of each thread's unread messages
61+
let unreadCounters = $('.unseenNotifications').map(function() {
62+
return Number($(this).find('p').text());
63+
});
64+
65+
// Sums them all up
66+
let count = 0;
67+
for (let i = 0; i < unreadCounters.length; i++) {
68+
count += unreadCounters[i];
69+
}
70+
71+
// We currently do not have a way to determine who last messaged the user
72+
// TODO: figure this out by intercepting HTML5 notifications
73+
if (count > 0 && lastCount !== 0)
74+
return;
75+
76+
lastCount = count;
77+
ipc.sendToHost('notification-count', count);
78+
}, 500);
6679
});
6780

6881
function setActivityHandle(minutes) {

0 commit comments

Comments
 (0)