Skip to content

Commit

Permalink
Merge pull request #233 from unipept/fix/release-notes-cache
Browse files Browse the repository at this point in the history
Cache release notes in communicator
  • Loading branch information
pverscha authored Oct 7, 2022
2 parents f2fb6da + 9da5a60 commit 48a0132
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/logic/communication/github/GitHubCommunicator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { NetworkUtils } from "unipept-web-components";

export default class GitHubCommunicator {
private static releaseNotesCache: string = "";
private static releaseNotesVersion: string = ""

/**
* Returns the release content for a specific release version. This content is formatted as MarkDown.
*
Expand All @@ -10,10 +13,14 @@ export default class GitHubCommunicator {
* @throws Error if the given release could not be found, or if no internet connection is established.
*/
public async getReleaseNotes(appVersion: string): Promise<string> {
const result = await NetworkUtils.getJSON(
`https://api.github.com/repos/unipept/unipept-desktop/releases/tags/v${appVersion}`
);
return result.body;
if (GitHubCommunicator.releaseNotesCache === "" || GitHubCommunicator.releaseNotesVersion !== appVersion) {
GitHubCommunicator.releaseNotesCache = (await NetworkUtils.getJSON(
`https://api.github.com/repos/unipept/unipept-desktop/releases/tags/v${appVersion}`
)).body;
GitHubCommunicator.releaseNotesVersion = appVersion;
}

return GitHubCommunicator.releaseNotesCache;
}

public async getAllReleases(): Promise<string[]> {
Expand Down

0 comments on commit 48a0132

Please sign in to comment.