diff options
author | 2019-04-11 16:44:16 +0200 | |
---|---|---|
committer | 2019-04-11 16:44:16 +0200 | |
commit | eaf4aff646eed56e65c8dd8e70143ab5634ad4b4 (patch) | |
tree | ae400dca67edfd828a30da1e11d7e5e507785860 /src/features/announcements/api.js | |
parent | refactor announcements to newest feature pattern (diff) | |
download | ferdium-app-eaf4aff646eed56e65c8dd8e70143ab5634ad4b4.tar.gz ferdium-app-eaf4aff646eed56e65c8dd8e70143ab5634ad4b4.tar.zst ferdium-app-eaf4aff646eed56e65c8dd8e70143ab5634ad4b4.zip |
WIP: announcement feature and workspace fixes
Diffstat (limited to 'src/features/announcements/api.js')
-rw-r--r-- | src/features/announcements/api.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/features/announcements/api.js b/src/features/announcements/api.js index 09fcb8235..a581bd8de 100644 --- a/src/features/announcements/api.js +++ b/src/features/announcements/api.js | |||
@@ -1,5 +1,6 @@ | |||
1 | import { remote } from 'electron'; | 1 | import { remote } from 'electron'; |
2 | import Request from '../../stores/lib/Request'; | 2 | import Request from '../../stores/lib/Request'; |
3 | import { API, API_VERSION } from '../../environment'; | ||
3 | 4 | ||
4 | const debug = require('debug')('Franz:feature:announcements:api'); | 5 | const debug = require('debug')('Franz:feature:announcements:api'); |
5 | 6 | ||
@@ -9,15 +10,24 @@ export const announcementsApi = { | |||
9 | return Promise.resolve(remote.app.getVersion()); | 10 | return Promise.resolve(remote.app.getVersion()); |
10 | }, | 11 | }, |
11 | 12 | ||
12 | async getAnnouncementForVersion(version) { | 13 | async getChangelog(version) { |
13 | debug('fetching release announcement from Github'); | 14 | debug('fetching release changelog from Github'); |
14 | const url = `https://api.github.com/repos/meetfranz/franz/releases/tags/v${version}`; | 15 | const url = `https://api.github.com/repos/meetfranz/franz/releases/tags/v${version}`; |
15 | const request = await window.fetch(url, { method: 'GET' }); | 16 | const request = await window.fetch(url, { method: 'GET' }); |
16 | if (!request.ok) throw request; | 17 | if (!request.ok) return null; |
17 | const data = await request.json(); | 18 | const data = await request.json(); |
18 | return data.body; | 19 | return data.body; |
19 | }, | 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 | }, | ||
20 | }; | 29 | }; |
21 | 30 | ||
22 | export const getCurrentVersionRequest = new Request(announcementsApi, 'getCurrentVersion'); | 31 | export const getCurrentVersionRequest = new Request(announcementsApi, 'getCurrentVersion'); |
23 | export const getAnnouncementRequest = new Request(announcementsApi, 'getAnnouncementForVersion'); | 32 | export const getChangelogRequest = new Request(announcementsApi, 'getChangelog'); |
33 | export const getAnnouncementRequest = new Request(announcementsApi, 'getAnnouncement'); | ||