Skip to content

Commit 01e12d4

Browse files
authored
Merge pull request #28 from hovancik/feature/version-checker
Adds version checker to check for latest version
2 parents c2eccda + 3f1fd2f commit 01e12d4

File tree

7 files changed

+51
-16
lines changed

7 files changed

+51
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
### Added
99
- possibility to pause reminders for different times
1010
- autostart for Windows and macOS
11+
- check for latest version on About page
1112

1213
## [0.2.1] - 2016-10-10
1314
### Fixed

app/about.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="UTF-8">
54
<title>About stretchly v0.2.1</title>
65
<link rel="stylesheet" type="text/css" href="css/app.css">
76
</head>
@@ -13,9 +12,13 @@
1312
<div>
1413
break time reminder app
1514
</div>
15+
<div class="about-stretchly">
16+
<p>
17+
To learn more about all of stretchly features and about ways how you can help it, visit it's <a href="https://hovancik.net/stretchly" id="homepage">homepage</a>.
18+
</p>
19+
</div>
1620
<div id="about-footer">
17-
<a href="https://hovancik.net/stretchly" id="homepage">homepage</a>
18-
<a href="https://github.com/hovancik/stretchly/releases" id="update">update</a>
21+
latest version: <a href="https://github.com/hovancik/stretchly/releases" id="update">checking...</a>
1922
</div>
2023
</div>
2124
<script>

app/about.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const shell = require('electron').shell
1+
let {shell} = require('electron')
2+
let VersionChecker = require('./utils/versionChecker')
23

34
document.getElementById('homepage').addEventListener('click', function (e) {
45
e.preventDefault()
@@ -9,3 +10,7 @@ document.getElementById('update').addEventListener('click', function (e) {
910
e.preventDefault()
1011
shell.openExternal('https://github.com/hovancik/stretchly/releases')
1112
})
13+
14+
new VersionChecker().latest(function (version) {
15+
document.getElementById('update').innerHTML = version
16+
})

app/css/app.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,10 @@ body {
6262
text-decoration: none;
6363
font-family: 'Lato Thin';
6464
}
65+
66+
.about-stretchly {
67+
font-size: 18px;
68+
text-decoration: none;
69+
font-family: 'Lato Thin';
70+
padding-top: 60px;
71+
}

app/main.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,6 @@ function getTrayMenu (MicrobreaksPaused) {
176176
}
177177

178178
trayMenu.push({
179-
label: 'About',
180-
click: function () {
181-
showAboutWindow()
182-
}
183-
}, {
184-
label: 'Settings',
185-
click: function () {
186-
showSettingsWindow()
187-
}
188-
}
189-
, {
190179
type: 'separator'
191180
})
192181

@@ -228,6 +217,16 @@ function getTrayMenu (MicrobreaksPaused) {
228217

229218
trayMenu.push({
230219
type: 'separator'
220+
}, {
221+
label: 'About',
222+
click: function () {
223+
showAboutWindow()
224+
}
225+
}, {
226+
label: 'Settings',
227+
click: function () {
228+
showSettingsWindow()
229+
}
231230
}, {
232231
label: 'Quit',
233232
click: function () {

app/utils/VersionChecker.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class VersionChecker {
2+
latest (callback) {
3+
fetch('https://api.github.com/repos/hovancik/stretchly/releases/latest', {
4+
method: 'GET',
5+
headers: {'User-Agent': 'hovancik/stretchly'},
6+
mode: 'cors',
7+
cache: 'default'
8+
}).then(function (response) {
9+
return response.text()
10+
}).then(function (body) {
11+
let json = JSON.parse(body)
12+
callback(json.tag_name)
13+
}).catch(function (ex) {
14+
callback('Error getting latest version')
15+
})
16+
}
17+
}
18+
19+
module.exports = VersionChecker

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"describe",
8888
"beforeEach",
8989
"afterEach",
90-
"Audio"
90+
"Audio",
91+
"fetch"
9192
]
9293
}
9394
}

0 commit comments

Comments
 (0)