diff --git a/ui/component/lastReleaseChanges/index.js b/ui/component/lastReleaseChanges/index.js index 2784fe4d6..a23d1e419 100644 --- a/ui/component/lastReleaseChanges/index.js +++ b/ui/component/lastReleaseChanges/index.js @@ -1,3 +1,12 @@ +import { connect } from 'react-redux'; +import { selectRemoteVersion, selectReleaseNotes } from 'redux/selectors/app'; import LastReleaseChanges from './view'; -export default LastReleaseChanges; +const select = (state) => ({ + releaseVersion: selectRemoteVersion(state), + releaseNotes: selectReleaseNotes(state), +}); + +const perform = () => ({}); + +export default connect(select, perform)(LastReleaseChanges); diff --git a/ui/component/lastReleaseChanges/view.jsx b/ui/component/lastReleaseChanges/view.jsx index a41d2c778..62d129538 100644 --- a/ui/component/lastReleaseChanges/view.jsx +++ b/ui/component/lastReleaseChanges/view.jsx @@ -1,23 +1,21 @@ // @flow -import React, { useState, useEffect } from 'react'; -import MarkdownPreview from 'component/common/markdown-preview'; +import React from 'react'; import Button from 'component/button'; import I18nMessage from 'component/i18nMessage'; type Props = { hideReleaseVersion?: boolean, + releaseVersion: string, + releaseNotes: string, }; const LastReleaseChanges = (props: Props) => { - const { hideReleaseVersion } = props; - const [releaseTag, setReleaseTag] = useState(''); - const [releaseChanges, setReleaseChanges] = useState(''); - const [fetchingReleaseChanges, setFetchingReleaseChanges] = useState(false); - const [fetchReleaseFailed, setFetchReleaseFailed] = useState(false); + const { hideReleaseVersion, releaseVersion, releaseNotes } = props; const releaseVersionTitle = (
- {!hideReleaseVersion && __('A new version %release_tag% of LBRY is ready for you.', { release_tag: releaseTag })} + {!hideReleaseVersion && + __('A new version %release_tag% of LBRY is ready for you.', { release_tag: releaseVersion })}
); const seeReleaseNotes = ( @@ -34,47 +32,10 @@ const LastReleaseChanges = (props: Props) => { ); - useEffect(() => { - const lastReleaseUrl = 'https://api.github.com/repos/lbryio/lbry-desktop/releases/latest'; - 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); - }); - }, []); - - if (fetchingReleaseChanges) { - return{__('Loading...')}
; - } - - if (fetchReleaseFailed) { - return ( -
-