Skip to content

Commit bb0a8cc

Browse files
committed
fix: store app version and conditionally remove plugins from localStorage
Signed-off-by: Nora Blomaard <[email protected]>
1 parent 91a920e commit bb0a8cc

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/compas-open-scd/src/open-scd.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import type {
3838
import { classMap } from 'lit-html/directives/class-map.js';
3939
import { newConfigurePluginEvent, ConfigurePluginEvent } from '@openscd/open-scd/src/plugin.events.js';
4040
import { newLogEvent } from '@openscd/core/foundation/deprecated/history.js';
41+
import packageJson from '../package.json';
4142

4243
/** The `<open-scd>` custom element is the main entry point of the
4344
* Open Substation Configuration Designer. */
@@ -166,7 +167,8 @@ export class OpenSCD extends LitElement {
166167

167168
connectedCallback(): void {
168169
super.connectedCallback();
169-
this.loadPlugins()
170+
this.checkAppVersion();
171+
this.loadPlugins();
170172

171173
// TODO: let Lit handle the event listeners, move to render()
172174
this.addEventListener('reset-plugins', this.resetPlugins);
@@ -423,6 +425,16 @@ get parsedPlugins(): Plugin[] {
423425
};
424426
}
425427

428+
private checkAppVersion(): void {
429+
const currentVersion = packageJson.version;
430+
const storedVersion = localStorage.getItem('appVersion');
431+
432+
if (storedVersion !== currentVersion) {
433+
localStorage.setItem('appVersion', currentVersion);
434+
localStorage.removeItem('plugins');
435+
}
436+
}
437+
426438
@state() private loadedPlugins = new Set<string>();
427439

428440
// PLUGGING INTERFACES

0 commit comments

Comments
 (0)