-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from cryptomator/update-check
Fetch and show update info in settings screen
- Loading branch information
Showing
8 changed files
with
112 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import AxiosStatic from 'axios'; | ||
|
||
const axios = AxiosStatic.create(); | ||
|
||
export class LatestVersionDto { | ||
constructor(public stable: string, public beta: string) { } | ||
} | ||
|
||
class UpdatesService { | ||
public async get(localVersion: string): Promise<LatestVersionDto> { | ||
let config = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-Hub-Version': localVersion, | ||
'X-Hub-Instance': 'TODO' //for future uses | ||
} | ||
}; | ||
return axios.get('https://api.cryptomator.org/updates/hub.json', config) | ||
.then(response => response.data) | ||
.catch(err => { | ||
console.error(err); | ||
throw new FetchUpdateError('Unable to get update info.'); | ||
}); | ||
} | ||
} | ||
|
||
export class FetchUpdateError extends Error { | ||
constructor(msg: string) { | ||
super(msg); | ||
} | ||
} | ||
|
||
export const updateChecker = new UpdatesService(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters