Refactor the Preferences classes to utilize async methods rather than manually returning Promises

This commit is contained in:
Jonas Jenwald 2018-07-30 16:48:16 +02:00
parent 64e70fc16f
commit 233b3274bf
4 changed files with 53 additions and 61 deletions

View file

@ -26,18 +26,12 @@ if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('GENERIC')) {
let GenericCom = {};
class GenericPreferences extends BasePreferences {
_writeToStorage(prefObj) {
return new Promise(function(resolve) {
localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
resolve();
});
async _writeToStorage(prefObj) {
localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
}
_readFromStorage(prefObj) {
return new Promise(function(resolve) {
let readPrefs = JSON.parse(localStorage.getItem('pdfjs.preferences'));
resolve(readPrefs);
});
async _readFromStorage(prefObj) {
return JSON.parse(localStorage.getItem('pdfjs.preferences'));
}
}