quickadd icon indicating copy to clipboard operation
quickadd copied to clipboard

[BUG] User script settings default value not set

Open Yohe-Am opened this issue 2 years ago • 0 comments

I understand this is an undocumented and so perhaps a yet not stable feature but yes, unless the user explicitly opens the settings modal for the user script, the setting object passed to the entry function is empty.

To Reproduce

Steps to reproduce the behavior:

  1. Install the following user script:
const OPTION_1 = "MyOption;
module.exports = {
    entry: start,
    settings: {
        name: "My Script",
        options: {
            [OPTION_1]: {
                type: "text",
                defaultValue: "hello",
            },
        },
    },
};

async function start({ app, obsidian, quickAddApi, variables }, settings) {
    console.log(settings);
    new Notice(settings[OPTION_1]);
}
  1. Run the script and observe WITHOUT opening the settings modal.
  2. Open the settings modal.
  3. Run the script again.

Expected behavior

Default values for settings to be set without requiring the user to open the settings modal.

Desktop

  • OS:: Linux 5.13.19-2-MANJARO x86_64
  • Obsidian:: 0.14.15
  • QuickAdd:: 0.5.5

Yohe-Am avatar Jul 04 '22 14:07 Yohe-Am