Skip to content

Commit ee2e5f8

Browse files
authored
Merge pull request RocketChat#323 from alexbrazier/bugfix/windows
Windows notification issues
2 parents f21644d + 3219472 commit ee2e5f8

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

src/Toaster.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export default class Toaster {
1212
const window = new BrowserWindow({
1313
width: msg.width,
1414
height: 75,
15-
useContentSize: true,
1615
transparent: true,
1716
frame: false,
1817
show : false,
1918
alwaysOnTop: true,
2019
skipTaskbar: true,
21-
resizeable: false
20+
resizable: false,
21+
focusable: false
2222
});
2323

2424
if (this.debug) {
@@ -38,8 +38,8 @@ export default class Toaster {
3838
`title=${encodeURIComponent(msg.title || '')}&` +
3939
`message=${encodeURIComponent(msg.message || '')}&` +
4040
`timeout=${msg.timeout}&` +
41-
`icon=${msg.icon}&` +
42-
`tag=${msg.tag}`;
41+
`icon=${encodeURIComponent(msg.icon)}&` +
42+
`tag=${encodeURIComponent(msg.tag)}`;
4343

4444
window.loadURL(htmlFile);
4545

@@ -49,18 +49,18 @@ export default class Toaster {
4949
}
5050

5151
_setPosition (window, index) {
52-
const width = window.getSize()[0];
53-
const height = window.getSize()[1];
54-
const pos = this.mainWindow.getPosition();
55-
const display = screen.getDisplayNearestPoint({x:pos[0], y:pos[1]});
56-
const notificationDistance = height + 5;
57-
const x = display.workAreaSize.width - width - 4;
58-
const y = display.workAreaSize.height - (notificationDistance * index);
52+
const [ notificationWidth, notificationHeight ] = window.getSize();
53+
const [ appX, appY ] = this.mainWindow.getPosition();
54+
const { x, y, width, height } = screen.getDisplayNearestPoint({x: appX, y: appY}).workArea;
55+
const margin = 5;
56+
const notificationX = x + width - notificationWidth - margin;
57+
const notificationDistance = notificationHeight + margin;
58+
const notificationY = y + height - (notificationDistance * index);
5959

60-
window.setPosition(x, y);
60+
window.setPosition(notificationX, notificationY);
6161

6262
if (index <= this.maxNotifications) {
63-
window.show();
63+
window.showInactive();
6464
}
6565
}
6666
}

src/public/notification.html

+10-6
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
<style type="text/css">
66
*{margin: 0;padding:0;}
77
body, html{
8-
font: 13px/1.4 Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";
8+
font: 14px/1.4 Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";
99
width: 100%;
1010
height: 100%;
1111
overflow: hidden;
12+
-webkit-user-select: none;
1213
}
1314

1415
#frame {
@@ -72,21 +73,24 @@
7273
line-height: 16px;
7374
float: left;
7475
color: white;
76+
width: 285px;
7577
}
7678

7779
.title {
7880
font-weight: bold;
7981
margin-top: 0.5em;
8082
margin-bottom: 0;
81-
padding-right: 2em;
8283
-webkit-line-clamp: 1;
84+
display: -webkit-box;
85+
-webkit-box-orient: vertical;
8386
overflow: hidden;
8487
text-overflow: ellipsis;
8588
}
8689
.message {
8790
margin-top: 0.33em;
88-
padding-right: 4em;
8991
-webkit-line-clamp: 2;
92+
display: -webkit-box;
93+
-webkit-box-orient: vertical;
9094
overflow: hidden;
9195
text-overflow: ellipsis;
9296
}
@@ -179,11 +183,11 @@
179183
frame.addEventListener('mouseout', startTimeout)
180184

181185
document.getElementById('close').addEventListener('click', closeClick);
186+
document.getElementById('title').innerHTML = getQueryVariable('title');
187+
document.getElementById('message').innerHTML = getQueryVariable('message');
188+
document.getElementById('icon').setAttribute('src', getQueryVariable('icon'));
182189
}
183190

184-
document.getElementById('title').innerHTML = getQueryVariable('title');
185-
document.getElementById('message').innerHTML = getQueryVariable('message');
186-
document.getElementById('icon').setAttribute('src', getQueryVariable('icon'));
187191
</script>
188192
</body>
189193
</html>

0 commit comments

Comments
 (0)