mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-09 12:19:46 -04:00
Refactor deprecated Promise patterns
Former-commit-id: e5c04a1b74f6d3966f417eac5877c8f3c8cf242d [formerly 55758bc977941dee22ad775dc1a194861ba0fbb9] Former-commit-id: 53998f482d0ee6a506cac9a4858b813092208821
This commit is contained in:
parent
3dc24fbaed
commit
1829399560
@ -2616,7 +2616,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
|
||||
});
|
||||
}
|
||||
};
|
||||
state.selectedArchive.getDirEntryByTitle(title).then(readFile).fail(function (err) {
|
||||
state.selectedArchive.getDirEntryByTitle(title).then(readFile).catch(function (err) {
|
||||
console.error('Failed to read ' + title, err);
|
||||
messagePort.postMessage({
|
||||
'action': 'giveContent',
|
||||
@ -2935,7 +2935,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
|
||||
cssBlobCache.set(newURL[0], newURL[1]);
|
||||
injectCSS(); //DO NOT move this: it must run within .then function to pass correct values
|
||||
});
|
||||
}).fail(function (e) {
|
||||
}).catch(function (e) {
|
||||
console.error("could not find DirEntry for CSS : " + title, e);
|
||||
//@TODO Change this to push an array of [title, title] afters simplified code in injectCSS()
|
||||
blobArray.push(title);
|
||||
@ -3473,7 +3473,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
|
||||
uiUtil.feedNodeWithBlob(script, 'src', content, 'text/javascript', params.allowHTMLExtraction);
|
||||
});
|
||||
}
|
||||
}).fail(function (e) {
|
||||
}).catch(function (e) {
|
||||
console.error("could not find DirEntry for javascript : " + title, e);
|
||||
});
|
||||
});
|
||||
@ -3537,7 +3537,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
|
||||
$('.alert').hide();
|
||||
readArticle(dirEntry);
|
||||
}
|
||||
}).fail(function () {
|
||||
}).catch(function () {
|
||||
console.error("Error reading article with title " + title);
|
||||
if (params.appIsLaunching) goToMainArticle();
|
||||
// Line below prevents bootloop
|
||||
|
@ -144,16 +144,16 @@ define(['q'], function(Q) {
|
||||
});
|
||||
};
|
||||
var readInternal = function(file, begin, end) {
|
||||
var deferred = Q.defer();
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
deferred.resolve(new Uint8Array(e.target.result));
|
||||
};
|
||||
reader.onerror = reader.onabort = function(e) {
|
||||
deferred.reject(e);
|
||||
};
|
||||
reader.readAsArrayBuffer(file.slice(begin, end));
|
||||
return deferred.promise;
|
||||
return Q.Promise(function(resolve, reject) {
|
||||
var reader = new FileReader();
|
||||
reader.readAsArrayBuffer(file.slice(begin, end));
|
||||
reader.onload = function(e) {
|
||||
resolve(new Uint8Array(e.target.result));
|
||||
};
|
||||
reader.onerror = reader.onabort = function(e) {
|
||||
reject(e);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -94,7 +94,7 @@ define(['uiUtil'], function (uiUtil) {
|
||||
image.style.transition = 'opacity 0.5s ease-in';
|
||||
image.style.opacity = '1';
|
||||
});
|
||||
}).fail(function (e) {
|
||||
}).catch(function (e) {
|
||||
console.error('Could not find DirEntry for image: ' + title, e);
|
||||
checkBatch();
|
||||
});
|
||||
|
@ -315,7 +315,7 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8'],
|
||||
callback(data);
|
||||
});
|
||||
}
|
||||
}).fail(function (e) {
|
||||
}).catch(function (e) {
|
||||
console.warn("Metadata with key " + key + " not found in the archive", e);
|
||||
callback();
|
||||
});
|
||||
|
@ -241,7 +241,7 @@ define(['xzdec_wrapper', 'util', 'utf8', 'q', 'zimDirEntry'], function(xz, util,
|
||||
}
|
||||
}
|
||||
return typeMap;
|
||||
}).fail(function(err) {
|
||||
}).catch(function(err) {
|
||||
console.error('Unable to read MIME type list', err);
|
||||
return new Map;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user