Skip to content

Commit 8cf9581

Browse files
committed
feat: Show release notes when there's update available
1 parent b267321 commit 8cf9581

5 files changed

Lines changed: 44 additions & 4 deletions

File tree

packages/neuron-ui/src/components/GeneralSetting/index.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,37 @@ import { NeuronWalletContext } from 'states/stateProvider'
55
import { StateWithDispatch } from 'states/stateProvider/reducer'
66
import { addPopup } from 'states/stateProvider/actionCreators'
77
import { checkForUpdates, downloadUpdate, installUpdate, clearCellCache } from 'services/remote'
8+
import { releaseNotesStyle } from './style.module.scss'
89

910
const UpdateDownloadStatus = ({
1011
progress = 0,
1112
newVersion = '',
12-
}: React.PropsWithoutRef<{ progress: number; newVersion: string }>) => {
13+
releaseNotes = '',
14+
}: React.PropsWithoutRef<{ progress: number; newVersion: string; releaseNotes: string }>) => {
1315
const [t] = useTranslation()
14-
const available = newVersion !== '' && progress <= 0
16+
const available = newVersion !== '' && progress < 0
1517
const downloaded = progress >= 1
1618

1719
if (available) {
1820
const download = () => {
1921
downloadUpdate()
2022
}
2123

24+
const releaseNotesHtml = () => {
25+
return { __html: releaseNotes }
26+
}
27+
28+
/* eslint-disable react/no-danger */
29+
2230
return (
2331
<Stack>
2432
<Text as="p" variant="medium">
2533
{t('updates.updates-found-do-you-want-to-update', { version: newVersion })}
2634
</Text>
35+
<h3>{t('updates.release-notes')}</h3>
36+
<div className={releaseNotesStyle}>
37+
<div dangerouslySetInnerHTML={releaseNotesHtml()} />
38+
</div>
2739
<Stack horizontal horizontalAlign="start">
2840
<PrimaryButton
2941
onClick={download}
@@ -101,7 +113,11 @@ const GeneralSetting = ({ dispatch }: React.PropsWithoutRef<StateWithDispatch>)
101113
<Stack>
102114
<Stack horizontal horizontalAlign="start">
103115
{updater.version !== '' || updater.downloadProgress >= 0 ? (
104-
<UpdateDownloadStatus progress={updater.downloadProgress} newVersion={updater.version} />
116+
<UpdateDownloadStatus
117+
progress={updater.downloadProgress}
118+
newVersion={updater.version}
119+
releaseNotes={updater.releaseNotes}
120+
/>
105121
) : (
106122
<PrimaryButton
107123
onClick={checkUpdates}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.releaseNotesStyle {
2+
overflow: scroll;
3+
height: 200px;
4+
margin-bottom: 20px;
5+
padding: 10px 15px 15px 15px;
6+
border: solid 1px #ccc;
7+
8+
ul {
9+
list-style-type: disc;
10+
padding-left: 30px;
11+
12+
li {
13+
margin: 5px 0;
14+
}
15+
}
16+
17+
a {
18+
text-decoration: none;
19+
pointer-events: none;
20+
}
21+
}

packages/neuron-ui/src/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@
348348
"check-updates": "Check for Updates",
349349
"downloading-update": "Downloading update...",
350350
"update-not-available": "There are currently no updates available.",
351+
"release-notes": "Release Notes:",
351352
"updates-found-do-you-want-to-update": "An update ({{version}}) is available, do you want to download and update now?",
352353
"download-update": "Download Update",
353354
"updates-downloaded-about-to-quit-and-install": "Update downloaded. Please quit to install the update.",

packages/neuron-ui/src/locales/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@
348348
"check-updates": "检查更新",
349349
"downloading-update": "正在下载更新...",
350350
"update-not-available": "没有可供升级的新版本。",
351+
"release-notes": "Release Notes:",
351352
"updates-found-do-you-want-to-update": "有可供升级的新版本({{version}})。现在进行下载和升级吗?",
352353
"download-update": "下载更新以升级",
353354
"updates-downloaded-about-to-quit-and-install": "下载完成。请退出并安装新版本。",

packages/neuron-wallet/src/controllers/update.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default class UpdateController {
3131
}
3232

3333
public downloadUpdate() {
34+
this.notify(0)
3435
autoUpdater.downloadUpdate()
3536
}
3637

@@ -46,7 +47,7 @@ export default class UpdateController {
4647

4748
autoUpdater.on('update-available', (info: UpdateInfo) => {
4849
UpdateController.isChecking = false
49-
this.notify(-1, info.version, 'todo')
50+
this.notify(-1, info.version, info.releaseNotes as string)
5051
})
5152

5253
autoUpdater.on('update-not-available', () => {

0 commit comments

Comments
 (0)