chore: restore dropdown actions

This commit is contained in:
Aleix 2025-05-21 14:27:59 +02:00
parent a3750d47ae
commit 6cbe46d6ea
3 changed files with 15 additions and 10 deletions

View file

@ -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) => {

View file

@ -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 {

View file

@ -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);