The first bug we fixed was audio not saving after load. We completely removed our timeupdate event function, which allowed us to recode it into a simple 4-line function which saves our audio data. We then added a .position variable to the Chapter class, and allowed the app to save to this variable when the timeupdate event was fired. You can see Alex's explanation of this here.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#audioSource").on("timeupdate", function(e){ | |
var floatSeconds = $("#audioSource").prop('currentTime'); // change to event | |
appUIState.currentChapter.position = floatSeconds; | |
console.log("new time " + appUIState.currentChapter.position); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Book(args) { | |
this.chapters = args.chapters | |
var json = args.json; | |
this.json = json; | |
this.description = $($.parseHTML(json.description)).text(); | |
this.title = json.title; | |
this.id = json.id; | |
} |
That was about it for today! Refactoring can be time consuming, but in the end it's making it a lot easier to add things on.
EDIT: After further testing, it seems as if we're no longer getting "not well formed" errors, and the page change bug [you had to restart the app to search for a different book] is no longer there!
Your comment that "It's funny, we made so many code changes, but no real feature was changed" is the very essence of what is called refactoring. Once you have automated tests in place, running the tests is supposed to provide you with confidence of that very thing, that despite lots of changes to the implementation details of your program, it still implements the same features it did before.
ReplyDelete