diff options
author | Marcus Lundblad <ml@dfupdate.se> | 2023-04-25 22:03:35 +0200 |
---|---|---|
committer | Marcus Lundblad <ml@dfupdate.se> | 2023-04-25 22:03:35 +0200 |
commit | 0fb2c3de95afe02bf2518752297976ac001a1327 (patch) | |
tree | ad0eee96b0b4dff105bb5e347f9284bbe5c07169 | |
parent | 4706517fc8f28a40a84a65146c621fce0c5f20af (diff) | |
download | gnome-maps-wip/mlundblad/fix-wikidata-thumbnail-with-no-sitelinks.tar.gz |
wikipedia: Fetch Wikidata thumbail before checking for articlewip/mlundblad/fix-wikidata-thumbnail-with-no-sitelinks
A Wikidata entry can have a thumbnail without having the sitelinks.
So do the check for sitelinks after fetching the thumbnail to not
miss the thumbnail in cases where the Wikidata entry have a thumbnail
but no linked articles.
-rw-r--r-- | src/wikipedia.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/wikipedia.js b/src/wikipedia.js index 90fe7bf3..8ce4d43c 100644 --- a/src/wikipedia.js +++ b/src/wikipedia.js @@ -253,16 +253,6 @@ export function fetchWikidataForArticle(wiki, cancellable, callback) { function _onWikidataFetched(wikidata, defaultArticle, response, size, metadataCb, thumbnailCb) { - let sitelinks = response?.entities?.[wikidata]?.sitelinks; - - if (!sitelinks) { - Utils.debug('No sitelinks element in response'); - metadataCb(null, {}); - if (thumbnailCb) - thumbnailCb(null); - return; - } - let claims = response?.entities?.[wikidata]?.claims; let imageName = claims?.[WIKIDATA_PROPERTY_IMAGE]?.[0]?.mainsnak?.datavalue?.value; @@ -275,6 +265,16 @@ function _onWikidataFetched(wikidata, defaultArticle, response, size, thumbnailCb = null; } + let sitelinks = response?.entities?.[wikidata]?.sitelinks; + + if (!sitelinks) { + Utils.debug('No sitelinks element in response'); + metadataCb(null, {}); + if (thumbnailCb) + thumbnailCb(null); + return; + } + /* try to find articles in the order of the user's preferred * languages */ |