Skip to content

Commit

Permalink
Update list on install
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jul 30, 2024
1 parent 14ee1e5 commit 32a45c8
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions source/app.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
}
onMount(async () => {
function fillInTheBlanks(extension) {

Check failure on line 85 in source/app.svelte

View workflow job for this annotation

GitHub Actions / Lint

Move function 'fillInTheBlanks' to the outer scope
extension.shown = true;
extension.indexedName = extension.name.toLowerCase();
return extension;
}
const allExtensions = await chromeP.management.getAll();
extensions = allExtensions
.filter(({type, id}) => type === 'extension' && id !== myid)
Expand All @@ -92,16 +98,18 @@
return a.enabled < b.enabled ? 1 : -1; // Sort by state
})
.map(extension => {
extension.shown = true;
extension.indexedName = extension.name.toLowerCase();
return extension;
});
.map(extension => fillInTheBlanks(extension));
// Update list on uninstall
// Update list on global events
chrome.management.onUninstalled.addListener(deleted => {
extensions = extensions.filter(({id}) => id !== deleted);
});
chrome.management.onInstalled.addListener(installed => {
if (installed.type === 'extension') {
// Place new extension at the top
extensions = [fillInTheBlanks(installed), ...extensions];
}
});
});
// Toggle extra buttons on right click on the name
Expand Down

0 comments on commit 32a45c8

Please sign in to comment.