diff --git a/js/extension.js b/js/extension.js index 57f7592..986458f 100644 --- a/js/extension.js +++ b/js/extension.js @@ -177,7 +177,7 @@ class NotesSidebar { // Save button: enabled only when there's an active note AND unsaved changes this.saveBtn.disabled = !hasActiveNote || !hasUnsavedChanges; - + // Rename and delete buttons: enabled only when there's an active note this.renameBtn.disabled = !hasActiveNote; this.deleteBtn.disabled = !hasActiveNote; @@ -216,7 +216,7 @@ class NotesSidebar { // Load notes after creating UI await this.loadNotes(); - + // Ensure UI reflects the current state after initialization this.renderTabs(); this.updateTextArea(); @@ -340,7 +340,7 @@ class NotesSidebar { async selectNote(noteName) { // Save current content before switching - if (this.activeNote && this.textArea) { + if (this.activeNote) { this.store.setNoteContent(this.activeNote, this.textArea.value); } @@ -370,8 +370,6 @@ class NotesSidebar { } async saveActiveNote() { - if (!this.activeNote) return; - try { const content = this.textArea.value; const response = await fetch(`/notes_sidebar/note/${encodeURIComponent(this.activeNote)}`, { @@ -395,8 +393,6 @@ class NotesSidebar { } async deleteActiveNote() { - if (!this.activeNote) return; - if (!confirm(`Are you sure you want to delete "${this.activeNote}"?`)) return; try { @@ -421,8 +417,6 @@ class NotesSidebar { } async renameActiveNote() { - if (!this.activeNote) return; - const newName = prompt('Enter new note name:', this.activeNote); if (!newName || newName === this.activeNote) return; @@ -512,12 +506,6 @@ class NotesSidebar { } onTextAreaChange() { - if (!this.activeNote) { - // Clear the textarea if someone types without an active note - this.textArea.value = ''; - return; - } - const currentContent = this.textArea.value; const savedContent = this.savedContent.get(this.activeNote) || '';