Closed danielweck closed 8 years ago
PS: I should have pointed out that although this.libraryData
was set to undefined
in the _refreshLibraryFromWorker()
callback function, this did not have any observable consequences from the user standpoint. The library of eBooks is stored in a file called epub_library.json
that happened to be reloaded at each import (see retrieveAvailableEpubs()
):
https://github.com/readium/readium-js-viewer/blob/develop/src/js/EpubLibraryManager.js#L53
retrieveAvailableEpubs : function(success, error){
if (this.libraryData){
success(this.libraryData);
return;
}
var self = this;
var indexUrl = moduleConfig.epubLibraryPath
? StorageManager.getPathUrl(moduleConfig.epubLibraryPath)
: StorageManager.getPathUrl('/epub_library.json');
...etc.
Also see the "save" function in EpubLibraryWriter
:
https://github.com/readium/readium-js-viewer/blob/develop/src/js/workers/EpubLibraryWriter.js#L21
_saveLibraryIndex : function(success, error){
var blob = new Blob([JSON.stringify(this.libraryData)]);
StorageManager.saveFile('/epub_library.json', blob, success, error);
},
See
Messages.SUCCESS
below, andlibrary
vs.libraryItems
field name:https://github.com/readium/readium-js-viewer/blob/develop/src/js/workers/EpubLibraryWriter.js#L275
https://github.com/readium/readium-js-viewer/blob/develop/src/js/workers/WorkerProxy.js#L36
This means that the
success()
callback function receivesundefined
, resulting in messing-up the local state inEpubLibraryManager
(see_refreshLibraryFromWorker ()
): https://github.com/readium/readium-js-viewer/blob/develop/src/js/EpubLibraryManager.js#L124...which is for example used when unzipping / importing an EPUB archive into the library: https://github.com/readium/readium-js-viewer/blob/develop/src/js/EpubLibraryManager.js#L128