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