22
22
.status .success {
23
23
color : green;
24
24
}
25
+
26
+ .d-none {
27
+ display : none;
28
+ }
25
29
</ style >
26
30
</ head >
27
31
< body >
@@ -41,8 +45,11 @@ <h3>Auto update</h3>
41
45
< div >
42
46
< button type ="submit "> Save Settings</ button >
43
47
< button id ="checkForUpdateBtn " type ="button "> Check for update</ button >
48
+ < button id ="downloadUpdateBtn " class ="d-none " type ="button "> Download update</ button >
49
+ < button id ="quitAndUpdateBtn " class ="d-none " type ="button "> Quit and update</ button >
44
50
</ div >
45
51
</ form >
52
+
46
53
< div id ="status " class ="status ">
47
54
48
55
</ div >
@@ -53,8 +60,11 @@ <h3>Auto update</h3>
53
60
54
61
< script >
55
62
const autoUpdateForm = document . getElementById ( 'autoUpdateForm' )
56
- const statusDiv = document . getElementById ( 'status'
57
- )
63
+ const statusDiv = document . getElementById ( 'status' )
64
+ const checkForUpdateBtn = document . getElementById ( 'checkForUpdateBtn' )
65
+ const downloadUpdateBtn = document . getElementById ( 'downloadUpdateBtn' )
66
+ const quitAndUpdateBtn = document . getElementById ( 'quitAndUpdateBtn' )
67
+
58
68
ipcRenderer . on ( 'app-settings' , function processAppSettings ( event , settings ) {
59
69
document . getElementById ( 'versionPlaceHolder' ) . innerText = settings . version
60
70
setAutoUpdateForm ( settings . autoUpdate )
@@ -64,6 +74,18 @@ <h3>Auto update</h3>
64
74
statusDiv . innerText = status . message
65
75
statusDiv . classList . remove ( 'info' , 'error' , 'success' )
66
76
statusDiv . classList . add ( status . type )
77
+
78
+ switch ( status . event ) {
79
+ case 'update-available' :
80
+ checkForUpdateBtn . classList . add ( 'd-none' )
81
+ downloadUpdateBtn . classList . remove ( 'd-none' )
82
+ break ;
83
+
84
+ case 'update-downloaded' :
85
+ downloadUpdateBtn . classList . add ( 'd-none' )
86
+ quitAndUpdateBtn . classList . remove ( 'd-none' )
87
+ break ;
88
+ }
67
89
} )
68
90
69
91
autoUpdateForm . addEventListener ( 'submit' , function submitAutoUpdateForm ( event ) {
@@ -73,15 +95,23 @@ <h3>Auto update</h3>
73
95
ipcRenderer . send ( 'save-settings' , settings )
74
96
} )
75
97
76
- document
77
- . getElementById ( 'checkForUpdateBtn' )
78
- . addEventListener ( 'click' , function checkForUpdate ( event ) {
98
+ downloadUpdateBtn . addEventListener ( 'click' , function downloadUpdate ( ) {
99
+ ipcRenderer . send ( 'download-update' )
100
+ downloadUpdateBtn . disabled = true
101
+ } )
102
+
103
+ quitAndUpdateBtn . addEventListener ( 'click' , function quitAndUpdate ( ) {
104
+ ipcRenderer . send ( 'quit-update' )
105
+ } )
106
+
107
+ checkForUpdateBtn . addEventListener ( 'click' , function checkForUpdate ( event ) {
79
108
event . preventDefault ( )
80
109
81
110
const settings = getAutoUpdateSettingsFromForm ( )
82
111
ipcRenderer . send ( 'check-for-update' , settings . preReleaseAllowed )
83
112
} )
84
113
114
+
85
115
function getAutoUpdateSettingsFromForm ( ) {
86
116
const settings = {
87
117
checkForUpdateAtStartup : false ,
0 commit comments