Skip to content

Comments

fix: validate default template still has template tag before using it#134

Open
sh1vam31 wants to merge 1 commit intojoplin:masterfrom
sh1vam31:fix/validate-default-template-is-template_#107
Open

fix: validate default template still has template tag before using it#134
sh1vam31 wants to merge 1 commit intojoplin:masterfrom
sh1vam31:fix/validate-default-template-is-template_#107

Conversation

@sh1vam31
Copy link

Fixes #107

If a note was set as the default template and later had its template tag removed, the plugin would silently fail or give a misleading error. It should instead inform the user that the saved default is no longer a template.

Fix

src/utils/templates.ts

  • Added isNoteATemplate(noteId) — checks if a note still has the template tag
  • Updated getTemplateFromId() to return null if the note is no longer a template

src/index.ts

  • Both "Create note from default template" and "Create to-do from default template"
    commands now show a clear, actionable error message:

"The note set as the default template is no longer a template.
Please set a new default template via Tools → Templates → Default templates."

Testing

  1. Created a note, tagged it as template, set it as the default template
  2. Removed the template tag from that note
  3. Clicked Tools → Templates → Create note from default template
  4. The correct error message appeared
  5. Re-added the template tag → default template worked normally again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check if the default template is actually a template

1 participant