diff options
author | 2019-04-12 19:05:59 +0200 | |
---|---|---|
committer | 2019-04-12 19:05:59 +0200 | |
commit | 821a3192801eb86a06373054e90150f73473d30c (patch) | |
tree | f7f3417d05108787636fbe8371f3babb40fe47f3 /src/features/announcements/api.js | |
parent | add locale on signup (diff) | |
parent | link to in-app changelog on new update notification (diff) | |
download | ferdium-app-821a3192801eb86a06373054e90150f73473d30c.tar.gz ferdium-app-821a3192801eb86a06373054e90150f73473d30c.tar.zst ferdium-app-821a3192801eb86a06373054e90150f73473d30c.zip |
Merge branch 'feature/announcements' into develop
Diffstat (limited to 'src/features/announcements/api.js')
-rw-r--r-- | src/features/announcements/api.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/features/announcements/api.js b/src/features/announcements/api.js new file mode 100644 index 000000000..a581bd8de --- /dev/null +++ b/src/features/announcements/api.js | |||
@@ -0,0 +1,33 @@ | |||
1 | import { remote } from 'electron'; | ||
2 | import Request from '../../stores/lib/Request'; | ||
3 | import { API, API_VERSION } from '../../environment'; | ||
4 | |||
5 | const debug = require('debug')('Franz:feature:announcements:api'); | ||
6 | |||
7 | export const announcementsApi = { | ||
8 | async getCurrentVersion() { | ||
9 | debug('getting current version of electron app'); | ||
10 | return Promise.resolve(remote.app.getVersion()); | ||
11 | }, | ||
12 | |||
13 | async getChangelog(version) { | ||
14 | debug('fetching release changelog from Github'); | ||
15 | const url = `https://api.github.com/repos/meetfranz/franz/releases/tags/v${version}`; | ||
16 | const request = await window.fetch(url, { method: 'GET' }); | ||
17 | if (!request.ok) return null; | ||
18 | const data = await request.json(); | ||
19 | return data.body; | ||
20 | }, | ||
21 | |||
22 | async getAnnouncement(version) { | ||
23 | debug('fetching release announcement from api'); | ||
24 | const url = `${API}/${API_VERSION}/announcements/${version}`; | ||
25 | const response = await window.fetch(url, { method: 'GET' }); | ||
26 | if (!response.ok) return null; | ||
27 | return response.json(); | ||
28 | }, | ||
29 | }; | ||
30 | |||
31 | export const getCurrentVersionRequest = new Request(announcementsApi, 'getCurrentVersion'); | ||
32 | export const getChangelogRequest = new Request(announcementsApi, 'getChangelog'); | ||
33 | export const getAnnouncementRequest = new Request(announcementsApi, 'getAnnouncement'); | ||