|
|
@ -1,25 +1,34 @@ |
|
|
|
import React, { useEffect, useState } from 'react'; |
|
|
|
import { Divider } from 'rsuite'; |
|
|
|
import settings from 'electron-settings'; |
|
|
|
import { shell } from 'electron'; |
|
|
|
import axios from 'axios'; |
|
|
|
import { InfoModal } from './Modal'; |
|
|
|
import { StyledButton } from '../shared/styled'; |
|
|
|
import { ConfigPanel } from '../settings/styled'; |
|
|
|
import CenterLoader from '../loader/CenterLoader'; |
|
|
|
|
|
|
|
const ReleaseNotes = () => { |
|
|
|
const [show, setShow] = useState(Boolean(settings.getSync('autoUpdateNotice'))); |
|
|
|
const [releaseDetails, setReleaseDetails] = useState<any>(); |
|
|
|
const [isLoading, setIsLoading] = useState(false); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
setIsLoading(true); |
|
|
|
const fetchReleaseNotes = async () => { |
|
|
|
const { data } = await axios.get( |
|
|
|
'https://api.github.com/repos/jeffvli/sonixd/releases/latest' |
|
|
|
'https://api.github.com/repos/jeffvli/sonixd/releases?per_page=4' |
|
|
|
); |
|
|
|
|
|
|
|
setReleaseDetails({ tag: data.tag_name, notes: data.body }); |
|
|
|
setReleaseDetails( |
|
|
|
data.map((release: any) => { |
|
|
|
return { tag: release.tag_name, notes: release.body }; |
|
|
|
}) |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
fetchReleaseNotes(); |
|
|
|
setIsLoading(false); |
|
|
|
}, []); |
|
|
|
|
|
|
|
if (!show) { |
|
|
@ -35,18 +44,29 @@ const ReleaseNotes = () => { |
|
|
|
}} |
|
|
|
> |
|
|
|
<ConfigPanel> |
|
|
|
<h1> |
|
|
|
{releaseDetails?.tag} |
|
|
|
<StyledButton |
|
|
|
onClick={() => shell.openExternal('https://github.com/jeffvli/sonixd/releases/latest')} |
|
|
|
appearance="primary" |
|
|
|
size="sm" |
|
|
|
style={{ marginLeft: '10px' }} |
|
|
|
> |
|
|
|
View on GitHub |
|
|
|
</StyledButton> |
|
|
|
</h1> |
|
|
|
<p>{releaseDetails?.notes}</p> |
|
|
|
{isLoading && <CenterLoader />} |
|
|
|
|
|
|
|
{releaseDetails?.map((release: { tag: string; notes: string }) => { |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<h1> |
|
|
|
{release?.tag} |
|
|
|
<StyledButton |
|
|
|
onClick={() => |
|
|
|
shell.openExternal(`https://github.com/jeffvli/sonixd/releases/${release.tag}`) |
|
|
|
} |
|
|
|
appearance="primary" |
|
|
|
size="sm" |
|
|
|
style={{ marginLeft: '10px' }} |
|
|
|
> |
|
|
|
View on GitHub |
|
|
|
</StyledButton> |
|
|
|
</h1> |
|
|
|
<p>{release?.notes}</p> |
|
|
|
<Divider /> |
|
|
|
</> |
|
|
|
); |
|
|
|
})} |
|
|
|
</ConfigPanel> |
|
|
|
</InfoModal> |
|
|
|
); |
|
|
|