mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	fix(leftpaneVisibility): Make leftpane visibility switch no longer depend on entitiesReloadedEvent
This commit is contained in:
		@@ -283,6 +283,9 @@ export type CommandMappings = {
 | 
				
			|||||||
type EventMappings = {
 | 
					type EventMappings = {
 | 
				
			||||||
    initialRenderComplete: {};
 | 
					    initialRenderComplete: {};
 | 
				
			||||||
    frocaReloaded: {};
 | 
					    frocaReloaded: {};
 | 
				
			||||||
 | 
					    setLeftPaneVisibility: {
 | 
				
			||||||
 | 
					        leftPaneVisible: boolean | null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    protectedSessionStarted: {};
 | 
					    protectedSessionStarted: {};
 | 
				
			||||||
    notesReloaded: {
 | 
					    notesReloaded: {
 | 
				
			||||||
        noteIds: string[];
 | 
					        noteIds: string[];
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,15 +78,15 @@ export default class RootCommandExecutor extends Component {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hideLeftPaneCommand() {
 | 
					    hideLeftPaneCommand() {
 | 
				
			||||||
        options.save(`leftPaneVisible`, "false");
 | 
					        appContext.triggerEvent("setLeftPaneVisibility", { leftPaneVisible: false });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    showLeftPaneCommand() {
 | 
					    showLeftPaneCommand() {
 | 
				
			||||||
        options.save(`leftPaneVisible`, "true");
 | 
					        appContext.triggerEvent("setLeftPaneVisibility", { leftPaneVisible: true });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    toggleLeftPaneCommand() {
 | 
					    toggleLeftPaneCommand() {
 | 
				
			||||||
        options.toggle("leftPaneVisible");
 | 
					        appContext.triggerEvent("setLeftPaneVisibility", { leftPaneVisible: null });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async showBackendLogCommand() {
 | 
					    async showBackendLogCommand() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,12 +36,8 @@ export default class LeftPaneToggleWidget extends CommandButtonWidget {
 | 
				
			|||||||
        splitService.setupLeftPaneResizer(this.currentLeftPaneVisible);
 | 
					        splitService.setupLeftPaneResizer(this.currentLeftPaneVisible);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
 | 
					    setLeftPaneVisibilityEvent({ leftPaneVisible }: EventData<"setLeftPaneVisibility">) {
 | 
				
			||||||
        if (loadResults.isOptionReloaded("leftPaneVisible") && document.hasFocus()) {
 | 
					        this.currentLeftPaneVisible = leftPaneVisible ?? !this.currentLeftPaneVisible;
 | 
				
			||||||
            // options.is("leftPaneVisible") changed — it may or may not be the same as currentLeftPaneVisible, but as long as the window is focused, the left pane visibility should be toggled.
 | 
					 | 
				
			||||||
            // See PR description for detailed explanation of multi-window edge cases: https://github.com/TriliumNext/Notes/pull/1962
 | 
					 | 
				
			||||||
            this.currentLeftPaneVisible = !this.currentLeftPaneVisible;        
 | 
					 | 
				
			||||||
        this.refreshIcon();
 | 
					        this.refreshIcon();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,10 +20,8 @@ export default class LeftPaneContainer extends FlexContainer<Component> {
 | 
				
			|||||||
        return super.isEnabled() && this.currentLeftPaneVisible;
 | 
					        return super.isEnabled() && this.currentLeftPaneVisible;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
 | 
					    setLeftPaneVisibilityEvent({ leftPaneVisible }: EventData<"setLeftPaneVisibility">) {
 | 
				
			||||||
        if (loadResults.isOptionReloaded("leftPaneVisible") && document.hasFocus()) {
 | 
					        this.currentLeftPaneVisible = leftPaneVisible ?? !this.currentLeftPaneVisible;
 | 
				
			||||||
            // options.is("leftPaneVisible") changed — it may or may not be the same as currentLeftPaneVisible, but as long as the window is focused, the left pane visibility should be toggled.
 | 
					 | 
				
			||||||
            this.currentLeftPaneVisible = !this.currentLeftPaneVisible;
 | 
					 | 
				
			||||||
        const visible = this.isEnabled();
 | 
					        const visible = this.isEnabled();
 | 
				
			||||||
        this.toggleInt(visible);
 | 
					        this.toggleInt(visible);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -32,6 +30,7 @@ export default class LeftPaneContainer extends FlexContainer<Component> {
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            this.triggerEvent("focusOnDetail", { ntxId: appContext.tabManager.getActiveContext()?.ntxId });
 | 
					            this.triggerEvent("focusOnDetail", { ntxId: appContext.tabManager.getActiveContext()?.ntxId });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					
 | 
				
			||||||
 | 
					        options.save("leftPaneVisible", this.currentLeftPaneVisible.toString());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user