fix: settings props not being correctly set

This commit is contained in:
SethBurkart123
2025-03-30 12:04:39 +11:00
parent 19cc1a5600
commit 647a32fbac
9 changed files with 247 additions and 280 deletions
+16 -6
View File
@@ -1,18 +1,26 @@
import type { Plugin } from '../../core/types';
import { BasePlugin, BooleanSetting } from '../../core/settings';
import type { Plugin } from '@/plugins/core/types';
import { BasePlugin } from '@/plugins/core/settings';
import { defineSettings, booleanSetting, Setting } from '@/plugins/core/settingsHelpers';
class TestPluginClass extends BasePlugin {
@BooleanSetting({
// Step 1: Define settings with proper typing
const settings = defineSettings({
someSetting: booleanSetting({
default: true,
title: "Test Plugin",
description: "Some random setting",
})
});
// Step 2: Create the plugin class with @Setting decorators
class TestPluginClass extends BasePlugin<typeof settings> {
@Setting(settings.someSetting)
someSetting!: boolean;
}
// Step 3: Instantiate and plug it in
const settingsInstance = new TestPluginClass();
const testPlugin: Plugin<typeof settingsInstance.settings> = {
const testPlugin: Plugin<typeof settings> = {
id: 'test',
name: 'Test Plugin',
description: 'A test plugin for BetterSEQTA+',
@@ -24,6 +32,8 @@ const testPlugin: Plugin<typeof settingsInstance.settings> = {
const { unregister } = api.seqta.onPageChange((page) => {
console.log('Page changed to', page);
console.log('Current setting value:', api.settings.someSetting);
});
return () => {
@@ -33,4 +43,4 @@ const testPlugin: Plugin<typeof settingsInstance.settings> = {
}
};
export default testPlugin;
export default testPlugin;