Skip to content

Commit c5cab50

Browse files
author
Arpith Siromoney
committed
Optimize: Only fetch labels needed for UI (favorites, reading-list)
Previously fetched ALL labels including 'read' (999KB!) just to check if articles are in favorites/reading-list. Now only fetch the 2 labels actually used in ArticleActions component. Expected improvement: ~1MB less data transferred on page load
1 parent 3900f1e commit c5cab50

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/main.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ function storeLabelArticles(label) {
4141
}
4242

4343
function getLabels() {
44-
return lib.user.labels.get().then((response) => {
45-
if (!response.labels) return;
46-
const promiseArr = response.labels.map(storeLabelArticles);
47-
Promise.all(promiseArr);
48-
}).catch(console.error);
44+
// Only fetch the labels we actually use in the UI
45+
const labelsToFetch = ['favorites', 'reading-list'];
46+
return Promise.all(labelsToFetch.map(storeLabelArticles))
47+
.catch(console.error);
4948
}
5049

5150
function displayArticle(article) {

0 commit comments

Comments
 (0)