Skip to content

Commit 7d36a2c

Browse files
authored
Fix: Enable / Disabled #39
2 parents 013cfb1 + 8537373 commit 7d36a2c

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
### Changed
1414
- Migrated to Svelte 5
15+
- `installed` is not a property of Plugin anymore
1516

1617
### Removed
1718
- Removed customElement as it isn't needed

src/plugin-store-item.svelte

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function installExternalPlugin(plugin: Plugin) {
5151
const currentPlugins = getStoredPlugins();
5252
5353
const pluginCopy = { ...plugin };
54-
pluginCopy.installed = true;
54+
pluginCopy.active = true;
5555
currentPlugins.push(pluginCopy);
5656
5757
localPlugins = currentPlugins;
@@ -64,22 +64,23 @@ function installExternalPlugin(plugin: Plugin) {
6464
function uninstallExternalPlugin(plugin: Plugin) {
6565
const currentPlugins = getStoredPlugins();
6666
const updatedPlugins = currentPlugins.filter((it) => it.name !== plugin.name);
67+
6768
localPlugins = updatedPlugins;
6869
6970
dispatchConfigurePlugin(plugin, true);
7071
console.log("Uninstalled external plugin:", plugin.name);
7172
}
7273
73-
// Enables/disables plugin by toggling the "installed" property.
74+
// Enables/disables plugin by toggling the "active" property.
7475
function toggleOfficialPlugin(plugin: Plugin, isEnabled: boolean) {
7576
const currentPlugins = getStoredPlugins();
7677
const foundPlugin = currentPlugins.find((it) => it.name === plugin.name);
77-
if (foundPlugin) {
78-
foundPlugin.installed = isEnabled;
79-
}
80-
78+
if (foundPlugin) {
79+
foundPlugin.active = isEnabled;
80+
}
81+
8182
localPlugins = currentPlugins;
82-
plugin.installed = isEnabled;
83+
plugin.active = isEnabled;
8384
8485
dispatchConfigurePlugin(plugin);
8586
console.log("Set toggle state for", plugin.name);
@@ -150,7 +151,7 @@ function getPluginIcon(plugin: Plugin) {
150151
</div>
151152
</plugin-store-item-meta--wrapper>
152153
</plugin-store-item-meta>
153-
{#if plugin.installed}
154+
{#if plugin.active}
154155
{#if plugin.official}
155156
<Button variant="outlined" onclick={() => toggleOfficialPlugin(plugin, false)}>
156157
Disable
@@ -171,7 +172,7 @@ function getPluginIcon(plugin: Plugin) {
171172
Enable
172173
</Button>
173174
{:else}
174-
{#if localPlugins.includes(plugin)}
175+
{#if localPlugins.some(p => p.name === plugin.name)}
175176
<SplitButton label="Enable" onclick={() => {toggleOfficialPlugin(plugin, true)}} onmenuOpen={() => openPluginMenu(index)}>
176177
<Menu bind:this={menus[index]} open={menuStates[index]} anchorCorner="BOTTOM_LEFT" style="left: -70px;">
177178
<List>

src/plugin-store.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ function combineAllPlugins(local: Plugin[], external: Plugin[]): Plugin[] {
4646
}
4747
4848
function filterInstalledPlugins(plugin: Plugin, isChecked: boolean): boolean {
49-
return !isChecked || localPlugins.includes(plugin);
49+
if (!isChecked) return true;
50+
return localPlugins.some(p => p.name === plugin.name && p.active);
5051
}
5152
5253
function filterSearchResults(plugin: Plugin, filter: string): boolean {

src/plugin-store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export type Plugin = {
66
kind: PluginKind;
77
requireDoc?: boolean;
88
position?: MenuPosition;
9-
installed: boolean;
9+
active: boolean;
10+
activeByDefault?: boolean;
1011
official?: boolean;
1112
description?: string;
1213
};

0 commit comments

Comments
 (0)