Skip to content

Commit

Permalink
Show changelog first open after update, clean updater
Browse files Browse the repository at this point in the history
  • Loading branch information
brandoshizzle committed Jan 5, 2019
1 parent 959dad8 commit 8964fa2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Solo sound options - choose to auto-stop playing sounds when a new sound starts
- Volume control for individual sounds
- Double-click volume bar to reset to 100%
- Show changelog on first time after update

### Fixed
- Fixed issue with playlist not switching song after fade out
Expand Down
6 changes: 3 additions & 3 deletions src/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ <h3>Empty Playlist</h3>
<div id="update-modal" class="modal model-fixed-footer" style="width:500px;">
<div class="modal-content" style="padding:0;">
<div class="header-row">
<h5 id="sound-settings-name" class="header" style="text-align: center; margin:0px; padding: 10px;">Update Available</h5>
<h5 id="update-title" class="header" style="text-align: center; margin:0px; padding: 10px;">Update Available</h5>
</div>
<div style="text-align:center;">
<strong>
Expand All @@ -420,11 +420,11 @@ <h5 id="sound-settings-name" class="header" style="text-align: center; margin:0p
<p>Released: <span id="update-date"></span></p>
</strong>
<div id="update-changelog"></div>
<p>Build Type: <span id="update-prerelease"></span></p>
<p id="build-type">Build Type: <span id="update-prerelease"></span></p>
<a class="btn z-depth-4 waves-effect waves-light" id="download-btn" href="#">Download Now!</a>
</div>
</div>
<div class="modal-footer">
<div class="modal-footer" id="update-modal-footer">
<a href="#" class="modal-action modal-close waves-effect btn-flat">Later</a>
</div>
</div>
Expand Down
5 changes: 1 addition & 4 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ var reloadSound = false;
$(document).ready(function() {
settingsInfo = storage.getInfoObj("settings"); // Load the program settings
storage.checkAgainstDefault(settingsInfo, "settings");
update.checkForUpdate();
update.versionUpdates();
//console.log(settingsInfo);
view.buildKeyboard(); // Create all the keys
playlist.build(); // Set up the playlist (no sounds)
waveforms.buildWaveform(); // Set up the waveform
Expand All @@ -67,8 +64,8 @@ $(document).ready(function() {
playlist.registerPlaylistItems();
Object.keys(pagesInfo).map(function(page, index) {
pagesNumSounds += Object.keys(pagesInfo[page].keyInfo).length;
//console.log(pagesNumSounds);
});
update.checkForUpdate();
totalNumSounds = Object.keys(playlistInfo).length + pagesNumSounds;
if (totalNumSounds === 0) {
$("#loadedContainer").hide();
Expand Down
1 change: 0 additions & 1 deletion src/scripts/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var defaults = {
"soloSound": "off"
},
'utility':{
"firstOpen": true,
"pVersion": "0.1.0"
}
},
Expand Down
55 changes: 27 additions & 28 deletions src/scripts/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ function checkForUpdate(){
if(!(release.prerelease === true && settingsInfo.general.prereleaseUpdates === false)){
var rVersion = release.tag_name.substring(1);
var cVersion = pjson.version;
//cVersion = rVersion; // For testing first time updates
console.log(rVersion);
console.log(cVersion);
console.log(compV(rVersion, cVersion));
if(compV(rVersion, cVersion)){ // NEWER VERSION DETECTED, POPULATE UPDATE FORM

if(compV(rVersion, cVersion)){
// NEWER VERSION DETECTED, POPULATE UPDATE FORM
$('#update-cVersion').text(cVersion);
$('#update-rVersion').text(rVersion);
$('#update-date').text(release.published_at.substring(0, 10));
Expand All @@ -31,24 +33,39 @@ function checkForUpdate(){
}
$('#download-btn').attr('href', release.html_url);
$('#update-link').text('Update to v' + rVersion + "!");

} else if (compV(pjson.version, settingsInfo.utility.pVersion)){
// Flask has been updated and is being run for the first time!
$('#update-title').text('Flask Updated!');
$('#update-cVersion').text(pjson.version);
$('#update-rVersion').text(pjson.version);
$('#update-date').text(release.published_at.substring(0, 10));
$('#update-changelog').html(marked(release.body));
$('#update-changelog > h2').remove();
$('#download-btn').hide();
$('#update-link').text('Updated to v' + pjson.version + "!");
$('#build-type').hide();
$('#download-btn').hide();
$('#update-modal-footer a').text('Okay');

$('#update-modal').modal('open');
versionUpdates();
settingsInfo.utility.pVersion = pjson.version;
storage.storeObj("settings", settingsInfo);
}
}
}
);

}

function versionUpdates(){
// This function will only be run if it's the user's first time with a new version
if(!settingsInfo.utility.firstOpen){
return;
}

// If coming from a version without sound, all sounds will be at 125% instead of 100%. Fix that.
/*
var allHigh = true;
for(var page in pagesInfo){
for(var key in pagesInfo[page].keyInfo){
console.log(pagesInfo[page].keyInfo[key].volume);
if(pagesInfo[page].keyInfo[key].volume < 1){
allHigh = false;
}
Expand All @@ -63,28 +80,10 @@ function versionUpdates(){
for(var sound in playlistInfo){
playlistInfo[sound].volume = 0.8;
}
keyInfo = pagesInfo.page1.keyInfo;
keyInfo = pagesInfo['page1'].keyInfo;
storage.storeObj("pagesInfo", pagesInfo);
storage.storeObj("playlistInfo", playlistInfo);
} */


var changelog = fs.readFileSync("./CHANGELOG.md", "utf8");
var pVersion = settingsInfo.utility.pVersion;

$('#update-cVersion').text(cVersion);
$('#update-rVersion').text(pVersion);
$('#update-changelog').html(marked(changelog));
$('#update-changelog > h2').remove();
$('#update-link').text('Update to v' + pVersion + "!");
settingsInfo.utility.pVersion = cVersion;
$('#update-modal').modal('open');

var cVersion = pjson.version;
settingsInfo.utility.firstOpen = false;
settingsInfo.utility.pVersion = cVersion;
storage.storeObj("settings", settingsInfo);
storage.storeObj("playlistInfo", playlistInfo);
}
}

module.exports = {
Expand Down

0 comments on commit 8964fa2

Please sign in to comment.