lbry-desktop/ui/component/lastReleaseChanges/view.jsx
Franco Montenegro f065218ff4
Prevent .deb packages from being opened with archive manager. (#7502)
* Prevent .deb packages from being opened with archive manager.

* Allow to properly cancel download upgrade and prevent multiple downloads.

* Fix missing app-update.yml file for .deb builds.

* Small fix for allowPrerelease prop in autoUpdater.

* Use release/tags endpoint to get the release details.

* Handle error case for auto updater.

* Make install now button display the upgrade modal.

* Use GitHub as provider for manual update url.

* Small fixes in updater.

* Fix small lint errors.

* Properly handle auto download on/off.
2022-07-07 16:48:42 -04:00

84 lines
2.4 KiB
JavaScript

// @flow
import React, { useState, useEffect } from 'react';
import MarkdownPreview from 'component/common/markdown-preview';
import Button from 'component/button';
import I18nMessage from 'component/i18nMessage';
type Props = {
releaseVersion: string,
hideReleaseVersion?: boolean,
};
const LastReleaseChanges = (props: Props) => {
const { hideReleaseVersion, releaseVersion } = props;
const [releaseTag, setReleaseTag] = useState('');
const [releaseChanges, setReleaseChanges] = useState('');
const [fetchingReleaseChanges, setFetchingReleaseChanges] = useState(false);
const [fetchReleaseFailed, setFetchReleaseFailed] = useState(false);
const releaseVersionTitle = (
<p>
{!hideReleaseVersion && __('A new version %release_tag% of LBRY is ready for you.', { release_tag: releaseTag })}
</p>
);
const seeReleaseNotes = (
<p className="help">
<I18nMessage
tokens={{
release_notes: (
<Button button="link" label={__('release notes')} href="https://github.com/lbryio/lbry-desktop/releases" />
),
}}
>
Want to know what has changed? See the %release_notes%.
</I18nMessage>
</p>
);
useEffect(() => {
const lastReleaseUrl = `https://api.github.com/repos/lbryio/lbry-desktop/releases/tags/${releaseVersion}`;
const options = {
method: 'GET',
headers: { Accept: 'application/vnd.github.v3+json' },
};
setFetchingReleaseChanges(true);
fetch(lastReleaseUrl, options)
.then((response) => response.json())
.then((response) => {
setReleaseTag(response.tag_name);
setReleaseChanges(response.body);
setFetchingReleaseChanges(false);
setFetchReleaseFailed(false);
})
.catch(() => {
setFetchingReleaseChanges(false);
setFetchReleaseFailed(true);
});
}, [releaseVersion, setFetchingReleaseChanges, setReleaseTag, setReleaseChanges, setFetchReleaseFailed]);
if (fetchingReleaseChanges) {
return <p>{__('Loading...')}</p>;
}
if (fetchReleaseFailed) {
return (
<div>
{releaseVersionTitle}
{seeReleaseNotes}
</div>
);
}
return (
<div className="release__notes">
{releaseVersionTitle}
<p>
<MarkdownPreview content={releaseChanges} />
</p>
{seeReleaseNotes}
</div>
);
};
export default LastReleaseChanges;