mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 18:50:41 +01:00
fix(split pane): hide the close button when no split panes exist
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
import { t } from "../../services/i18n";
|
||||
import ActionButton from "../react/ActionButton";
|
||||
import { useNoteContext, useTriliumEvent } from "../react/hooks";
|
||||
import { useNoteContext, useTriliumEvents } from "../react/hooks";
|
||||
import appContext from "../../components/app_context";
|
||||
|
||||
export default function ClosePaneButton() {
|
||||
const { noteContext, ntxId, parentComponent } = useNoteContext();
|
||||
const [isEnabled, setIsEnabled] = useState(false);
|
||||
|
||||
function refresh() {
|
||||
setIsEnabled(!!noteContext);
|
||||
const isMainOfSomeContext = appContext.tabManager.noteContexts.some(c => c.mainNtxId === ntxId);
|
||||
setIsEnabled(!!(noteContext && (!!noteContext.mainNtxId || isMainOfSomeContext)));
|
||||
}
|
||||
|
||||
useTriliumEvent("noteContextReorder", refresh);
|
||||
useTriliumEvents(["noteContextRemoved", "noteContextReorder", "newNoteContextCreated"], refresh);
|
||||
useEffect(refresh, [ntxId]);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user