Cache discover options

This commit is contained in:
patrickkfkan 2021-01-23 21:51:22 +08:00
parent 0969dbb794
commit bfe28315a0

View File

@ -69,10 +69,16 @@ async function sanitizeDiscoverParams(params) {
} }
async function getDiscoverOptions() { async function getDiscoverOptions() {
if (cache.discoverOptions !== undefined) {
return cache.discoverOptions;
}
const url = utils.getSiteUrl(); const url = utils.getSiteUrl();
return fetch(url) return fetch(url)
.then( res => res.text() ) .then( res => res.text() )
.then( html => parser.parseDiscoverOptions(html) ); .then( html => {
cache.discoverOptions = parser.parseDiscoverOptions(html);
return cache.discoverOptions;
});
} }
async function getImageFormat(idOrName) { async function getImageFormat(idOrName) {