Skip to content

Commit d982498

Browse files
committed
2.0 - Updating auto updater
1 parent e4f261d commit d982498

File tree

9 files changed

+285
-38
lines changed

9 files changed

+285
-38
lines changed

dist/assets/css/main.css

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,71 @@ a:active {
555555
color: white;
556556
bottom: 0;
557557
font-size: 14px;
558-
padding: 5px 15px;
558+
height: 32px;
559+
padding: 0 15px;
559560
width: 100%;
561+
align-items: center;
560562
display: none;
561563
}
562564

565+
.update-bar #output {
566+
display: inline-block;
567+
}
568+
569+
.update-bar .update-loading {
570+
margin-left: 10px;
571+
}
572+
573+
.update-bar .update-loading .fa {
574+
font-size: 10px;
575+
}
576+
563577
.update-bar.active {
564-
display: block;
578+
display: flex;
579+
}
580+
581+
.update-bar.update-av .fa {
582+
display: none;
583+
}
584+
585+
.update-bar #update-buttons {
586+
margin-left: auto;
587+
height: 100%;
588+
}
589+
590+
.update-bar button {
591+
float: right;
592+
border: none;
593+
margin: 0;
594+
font-size: 12px;
595+
padding: 0 10px;
596+
height: 100%;
597+
text-transform: uppercase;
598+
cursor: pointer;
599+
line-height: 1;
600+
}
601+
602+
.update-bar button + button {
603+
margin-right: 5px;
604+
}
605+
606+
#update-app {
607+
background-color: #007bc3;
608+
color: #ffffff;
609+
}
610+
611+
#update-app:hover {
612+
background-color: #006eaf;
613+
}
614+
615+
#update-app:active {
616+
background-color: #0066a2;
617+
}
618+
619+
#update-app-later {
620+
background-color: transparent;
621+
color: var(--c-white);
622+
text-transform: capitalize;
565623
}
566624

567625
.current-video-all {
@@ -661,7 +719,7 @@ a:active {
661719
position: relative;
662720
border: none;
663721
outline: none;
664-
color: rgba(255, 255, 255, 0.3);
722+
color: var(--c-primary);
665723
height: 30px;
666724
width: 30px;
667725
font-size: 12px;

dist/index.html

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
</head>
1212
<body class="application app-win">
1313
<div class="update-bar">
14-
<div id="output"></div>
14+
<div id="output">Checking for updates...</div>
15+
<span class="update-loading">
16+
<span class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></span>
17+
</span>
18+
<div id="update-buttons"></div>
1519
</div>
1620
<app-yt>
1721
<div class="loading-app">
@@ -23,48 +27,85 @@
2327
const AutoUpdater = require( "nw-autoupdater" ),
2428
updater = new AutoUpdater( require( "./package.json" ) ),
2529
output = document.querySelector( "#output" ),
26-
updateBar = document.getElementsByClassName("update-bar")[0].classList;
27-
30+
updateBar = document.getElementsByClassName("update-bar")[0].classList;
31+
2832
async function main(){
2933
try {
3034
// Update copy is running to replace app with the update
3135
if ( updater.isSwapRequest() ) {
32-
output.innerHTML += `\nSwapping...`;
36+
updateBar.add('active');
37+
output.innerHTML = `Finishing update...`;
3338
await updater.swap();
34-
output.innerHTML += `\nDone...`;
39+
output.innerHTML = `Restarting...`;
3540
await updater.restart();
3641
return;
3742
}
3843
// Download/unpack update if any available
3944
const rManifest = await updater.readRemoteManifest();
4045
const needsUpdate = await updater.checkNewVersion( rManifest );
4146
if ( !needsUpdate ) {
42-
output.innerHTML += `\nis up to date...`;
43-
updateBar.add('active');
47+
updateBar.add('active');
48+
setTimeout(() => {
49+
output.innerHTML = `There is no new updates...`;
50+
}, 2000);
51+
setTimeout(() => {
52+
updateBar.remove('active');
53+
}, 4000);
4454
} else {
45-
output.innerHTML = `There is new update`;
46-
updateBar.add('active');
55+
output.innerHTML = `Update available...`;
56+
updateBar.add('active', 'update-av');
57+
initUpdate();
4758
}
4859
} catch ( e ) {
4960
console.error( e );
5061
}
5162
}
63+
5264
function updateApp() {
65+
var rManifest = updater.readRemoteManifest();
66+
5367
// Subscribe for progress events
5468
updater.on( "download", ( downloadSize, totalSize ) => {
5569
output.innerHTML = `Downloading...`;
5670
console.log( "download progress", Math.floor( downloadSize / totalSize * 100 ), "%" );
5771
});
5872
updater.on( "install", ( installFiles, totalFiles ) => {
59-
output.innerHTML = `Installing...\n`;
73+
output.innerHTML = `Installing...`;
6074
console.log( "install progress", Math.floor( installFiles / totalFiles * 100 ), "%" );
6175
});
6276
const updateFile = updater.download( rManifest );
6377
updater.unpack( updateFile );
64-
alert( `The application will automatically restart to finish installing the update` );
65-
updater.restartToSwap();
78+
updateAppSwap();
6679
}
67-
output.innerHTML = `Application v${nw.App.manifest.version}\n`;
80+
81+
function updateAppSwap() {
82+
output.innerHTML = `The application will automatically restart to finish installing the update...`;
83+
setTimeout(() => {
84+
updater.restartToSwap();
85+
}, 3000);
86+
}
87+
88+
function updateAppLater() {
89+
updateBar.remove('active');
90+
}
91+
92+
function initUpdate() {
93+
var btnUPDLTR = document.createElement("BUTTON");
94+
btnUPDLTR.setAttribute("id", "update-app-later");
95+
btnUPDLTR.innerHTML = 'Later';
96+
97+
document.getElementById("update-buttons").appendChild(btnUPDLTR);
98+
99+
btnUPDLTR.onclick = updateAppLater;
100+
101+
var btnUPD = document.createElement("BUTTON");
102+
btnUPD.setAttribute("id", "update-app");
103+
btnUPD.innerHTML = 'Update';
104+
document.getElementById("update-buttons").appendChild(btnUPD);
105+
106+
btnUPD.onclick = updateApp;
107+
}
108+
68109
main();
69110

70111
</script>

dist/inline.bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"scripts": {
2626
"postversion": "npm run package",
27-
"package": "nwb nwbuild -v 0.25.2-sdk . -o ../release --output-format=ZIP --output-name={name}-v{version}-{target}"
27+
"package": "nwb nwbuild -v 0.25.2 . -o ../release --output-format=ZIP --output-name={name}-v{version}-{target}"
2828
},
2929
"dependencies": {
3030
"nw-autoupdater": "*"

dist/vendor.bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var YoutubePlayerService = (function () {
6565
var /** @type {?} */ doc = YoutubePlayerService.win.document;
6666
var /** @type {?} */ playerApiScript = doc.createElement("script");
6767
playerApiScript.type = "text/javascript";
68-
playerApiScript.src = options.protocol + "://www.youtube.com/iframe_api";
68+
playerApiScript.src = "https://www.youtube.com/iframe_api";
6969
doc.body.appendChild(playerApiScript);
7070
};
7171
/**

scss/_common.scss

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,59 @@
291291
color: white;
292292
bottom: 0;
293293
font-size: 14px;
294-
padding: 5px 15px;
294+
height: 32px;
295+
padding: 0 15px;
295296
width: 100%;
297+
align-items: center;
296298
display: none;
299+
#output {
300+
display: inline-block;
301+
}
302+
.update-loading {
303+
margin-left: 10px;
304+
.fa {
305+
font-size: 10px;
306+
}
307+
}
297308
&.active {
298-
display: block;
309+
display: flex;
310+
}
311+
&.update-av .fa {
312+
display: none;
299313
}
314+
#update-buttons {
315+
margin-left: auto;
316+
height: 100%;
317+
}
318+
button {
319+
float: right;
320+
border: none;
321+
margin: 0;
322+
font-size: 12px;
323+
padding: 0 10px;
324+
height: 100%;
325+
text-transform: uppercase;
326+
cursor: pointer;
327+
line-height: 1;
328+
+ button {
329+
margin-right: 5px;
330+
}
331+
}
332+
}
333+
334+
#update-app {
335+
background-color: #007bc3;
336+
color: #ffffff;
337+
&:hover {
338+
background-color: #006eaf;
339+
}
340+
&:active {
341+
background-color: #0066a2;
342+
}
343+
}
344+
345+
#update-app-later {
346+
background-color: transparent;
347+
color: var(--c-white);
348+
text-transform: capitalize;
300349
}

0 commit comments

Comments
 (0)