diff --git a/components/status-dropdown/dropdown-manager.ts b/components/status-dropdown/dropdown-manager.ts index 835d0d3..e34b400 100644 --- a/components/status-dropdown/dropdown-manager.ts +++ b/components/status-dropdown/dropdown-manager.ts @@ -35,7 +35,7 @@ export class DropdownManager { this.dropdownUI.setOnStatusChange((statuses) => { this.currentStatuses = [...statuses]; this.updateToolbarButton(); - this.statusService.notifyStatusChanged(statuses); + // this.statusService.notifyStatusChanged(statuses); }); this.dropdownUI.setOnRemoveStatusHandler(async (status, targetFile) => { diff --git a/integrations/editor/toolbar-integration.ts b/integrations/editor/toolbar-integration.ts index 3674e72..be57a95 100644 --- a/integrations/editor/toolbar-integration.ts +++ b/integrations/editor/toolbar-integration.ts @@ -19,11 +19,12 @@ export class ToolbarIntegration { app: App, settings: NoteStatusSettings, statusService: StatusService, + statusDropdown: StatusDropdown ) { this.app = app; this.settings = settings; this.statusService = statusService; - this.statusDropdown = new StatusDropdown(this.app, this.settings, this.statusService); + this.statusDropdown = statusDropdown; this.buttonView = new ToolbarButton(settings, statusService); } @@ -33,7 +34,7 @@ export class ToolbarIntegration { this.updateStatusDisplay([]); } - public addToolbarButtonToActiveLeaf(): void { + public addToolbarButtonToActiveLeaf(statuses?: string[]): void { const activeLeaf = this.app.workspace.activeLeaf; if (!activeLeaf?.view || !(activeLeaf.view instanceof MarkdownView)) return; @@ -53,7 +54,7 @@ export class ToolbarIntegration { toolbarContainer.appendChild(this.buttonElement); } - this.updateButtonDisplay(); + this.updateButtonDisplay(statuses); } private removeToolbarButton(): void { @@ -71,11 +72,12 @@ export class ToolbarIntegration { this.buttonElement = null; } - private updateButtonDisplay(): void { + private updateButtonDisplay(overrideStatutes?: string[]): void { const activeFile = this.app.workspace.getActiveFile(); if (!activeFile || !this.buttonElement) return; - const statuses = this.statusService.getFileStatuses(activeFile); + + const statuses = overrideStatutes?.length ? overrideStatutes : this.statusService.getFileStatuses(activeFile); this.buttonView.updateDisplay(statuses); } @@ -94,7 +96,7 @@ export class ToolbarIntegration { public updateStatusDisplay(statuses: string[]): void { this.removeToolbarButton(); - this.addToolbarButtonToActiveLeaf(); + this.addToolbarButtonToActiveLeaf(statuses); } public unload(): void { diff --git a/main.ts b/main.ts index 87a0541..293c528 100644 --- a/main.ts +++ b/main.ts @@ -13,6 +13,7 @@ import { WorkspaceIntegration } from './integrations/workspace'; // Importar componentes UI import { NoteStatusSettingTab } from 'integrations/settings/settings-tab'; import { StatusBar } from 'components/status-bar'; +import { StatusDropdown } from 'components/status-dropdown'; export default class NoteStatus extends Plugin { settings: NoteStatusSettings; @@ -23,6 +24,7 @@ export default class NoteStatus extends Plugin { // Componentes UI statusBar: StatusBar; + statusDropdown: StatusDropdown // Integraciones explorerIntegration: ExplorerIntegration; @@ -84,10 +86,9 @@ export default class NoteStatus extends Plugin { private initializeIntegrations() { // Crear integraciones en orden de dependencia - // // 1. Integraciones básicas primero // this.explorerIntegration = new ExplorerIntegration(this.app, this.settings, this.statusService); - this.toolbarIntegration = new ToolbarIntegration(this.app, this.settings, this.statusService); + this.toolbarIntegration = new ToolbarIntegration(this.app, this.settings, this.statusService, this.statusDropdown); // // 2. Integraciones que dependen de otras // this.fileMenuIntegration = new FileMenuIntegration( @@ -168,6 +169,8 @@ export default class NoteStatus extends Plugin { } private initializeUI() { + this.statusDropdown = new StatusDropdown(this.app, this.settings, this.statusService); + // Inicializar barra de estado this.statusBar = new StatusBar( this.addStatusBarItem(), @@ -192,7 +195,7 @@ export default class NoteStatus extends Plugin { // // Actualizar toolbar this.toolbarIntegration.updateStatusDisplay(statuses); - + this.statusDropdown.update(statuses); // // Actualizar explorador si es necesario // if (file) { // const fileObj = this.app.vault.getFileByPath(file);