diff --git a/.gitignore b/.gitignore index e09a007..2c116ac 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ data.json # Exclude macOS Finder (System Explorer) View States .DS_Store +styles.css diff --git a/ui/components/status-dropdown-component.ts b/ui/components/status-dropdown-component.ts index 03445f9..d733be1 100644 --- a/ui/components/status-dropdown-component.ts +++ b/ui/components/status-dropdown-component.ts @@ -299,16 +299,18 @@ export class StatusDropdownComponent { private async removeStatus(status: string): Promise { if (!this.targetFile) return; - await this.statusService.handleStatusChange({ + await this.statusService.modifyNoteStatus({ files: this.targetFile, statuses: status, - allowMultipleStatuses: false, // Queremos eliminar específicamente - afterChange: (updatedStatuses) => { - this.currentStatuses = updatedStatuses; - this.refreshDropdownContent(); - this.onStatusChange(updatedStatuses); - } + operation: 'remove', + showNotice: false }); + + // Get fresh statuses after the change + const updatedStatuses = this.statusService.getFileStatuses(this.targetFile); + this.currentStatuses = updatedStatuses; + this.refreshDropdownContent(); + this.onStatusChange(updatedStatuses); } /** @@ -396,7 +398,7 @@ export class StatusDropdownComponent { /** * Handle click on a status option */ - private async handleStatusOptionClick(optionEl: HTMLElement, status: Status): void { + private handleStatusOptionClick(optionEl: HTMLElement, status: Status): void { optionEl.addClass('note-status-option-selecting'); setTimeout(async () => { diff --git a/ui/components/status-dropdown.ts b/ui/components/status-dropdown.ts index 320540d..322ce6c 100644 --- a/ui/components/status-dropdown.ts +++ b/ui/components/status-dropdown.ts @@ -149,13 +149,17 @@ export class StatusDropdown { * Update a file's status */ private async updateFileStatus(file: TFile, statuses: string[]): Promise { - await this.statusService.handleStatusChange({ + const operation = this.settings.useMultipleStatuses ? 'toggle' : 'set'; + + await this.statusService.modifyNoteStatus({ files: file, statuses: statuses, - afterChange: (updatedStatuses) => { - this.notifyStatusChanged(updatedStatuses); - } + operation: operation, + showNotice: false }); + + const updatedStatuses = this.statusService.getFileStatuses(file); + this.notifyStatusChanged(updatedStatuses); } /** diff --git a/ui/menus/status-context-menu.ts b/ui/menus/status-context-menu.ts index 1c7e09a..c33f55e 100644 --- a/ui/menus/status-context-menu.ts +++ b/ui/menus/status-context-menu.ts @@ -125,30 +125,30 @@ export class StatusContextMenu { */ private async handleStatusUpdateForFile(file: TFile, statuses: string[]): Promise { if (!(file instanceof TFile) || file.extension !== 'md' || statuses.length === 0) return; + const operation = this.settings.useMultipleStatuses ? 'toggle' : 'set'; - await this.statusService.handleStatusChange({ + await this.statusService.modifyNoteStatus({ files: file, statuses: statuses, - afterChange: (updatedStatuses) => { - // Force explorer icon update - this.app.metadataCache.trigger('changed', file); - this.updateExplorerIcon(file); - - // Dispatch events to update other UI components - window.dispatchEvent(new CustomEvent('note-status:status-changed', { - detail: { statuses: updatedStatuses, file: file.path } - })); - - window.dispatchEvent(new CustomEvent('note-status:refresh-ui')); - - // Force a full UI refresh with slight delay - setTimeout(() => { - window.dispatchEvent(new CustomEvent('note-status:force-refresh')); - }, 100); - } + operation: operation, + showNotice: false }); + + // Get fresh statuses + const updatedStatuses = this.statusService.getFileStatuses(file); + this.notifyStatusChanged(updatedStatuses); + } - + /** + * Notify that status has changed + */ + private notifyStatusChanged(statuses: string[]): void { + window.dispatchEvent(new CustomEvent('note-status:status-changed', { + detail: { statuses } + })); + window.dispatchEvent(new CustomEvent('note-status:refresh-ui')); + } + /** * Update file status based on settings */