Skip to content

Commit bd618ad

Browse files
authored
feat(snippets): hide installed snippets if option is enabled (#777)
1 parent 559caf8 commit bd618ad

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/components/Grid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ class Grid extends React.Component<
489489

490490
// Load blacklist and snippets
491491
this.BLACKLIST = await getBlacklist();
492-
this.SNIPPETS = await fetchCssSnippets();
492+
this.SNIPPETS = await fetchCssSnippets(this.CONFIG.visual.hideInstalled);
493493
this.newRequest(ITEMS_PER_REQUEST);
494494
}
495495

src/logic/FetchRemotes.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export const getBlacklist = async () => {
303303
* It fetches the snippets.json file from the Github repository and returns it as an array of snippets.
304304
* @returns Array of snippets
305305
*/
306-
export const fetchCssSnippets = async () => {
306+
export const fetchCssSnippets = async (hideInstalled = false) => {
307307
const snippetsJSON = (await fetch(SNIPPETS_URL)
308308
.then((res) => res.json())
309309
.catch(() => [])) as Snippet[];
@@ -318,8 +318,13 @@ export const fetchCssSnippets = async () => {
318318
snip.preview = undefined;
319319
}
320320

321-
accum.push(snip);
321+
// Hide installed snippets if option is set and it's installed
322+
if (!(hideInstalled && localStorage.getItem(`marketplace:installed:snippet:${snip.title.replaceAll(" ", "-")}`))) {
323+
accum.push(snip);
324+
}
325+
322326
return accum;
323327
}, []);
328+
324329
return snippets;
325330
};

0 commit comments

Comments
 (0)