diff --git a/frontend/app/block/blockframe.tsx b/frontend/app/block/blockframe.tsx index 8bdb259e7..92ea79a56 100644 --- a/frontend/app/block/blockframe.tsx +++ b/frontend/app/block/blockframe.tsx @@ -71,12 +71,29 @@ function getViewIconElem(viewIconUnion: string | HeaderIconButton, blockData: Bl } } +const OptMagnifyButton = React.memo( + ({ blockData, layoutModel }: { blockData: Block; layoutModel: LayoutComponentModel }) => { + const tabId = globalStore.get(atoms.activeTabId); + const tabAtom = WOS.getWaveObjectAtom(WOS.makeORef("tab", tabId)); + const layoutTreeState = util.useAtomValueSafe(getLayoutStateAtomForTab(tabId, tabAtom)); + if (!isBlockMagnified(layoutTreeState, blockData.oid)) { + return null; + } + const magnifyDecl: HeaderIconButton = { + elemtype: "iconbutton", + icon: "regular@magnifying-glass-minus", + title: "Minimize", + click: layoutModel?.onMagnifyToggle, + }; + return ( + + ); + } +); + function computeEndIcons(blockData: Block, viewModel: ViewModel, layoutModel: LayoutComponentModel): JSX.Element[] { const endIconsElem: JSX.Element[] = []; const endIconButtons = util.useAtomValueSafe(viewModel.endIconButtons); - const tabId = globalStore.get(atoms.activeTabId); - const tabAtom = WOS.getWaveObjectAtom(WOS.makeORef("tab", tabId)); - const layoutTreeState = util.useAtomValueSafe(getLayoutStateAtomForTab(tabId, tabAtom)); if (endIconButtons && endIconButtons.length > 0) { endIconsElem.push( @@ -95,17 +112,7 @@ function computeEndIcons(blockData: Block, viewModel: ViewModel, layoutModel: La endIconsElem.push( ); - if (isBlockMagnified(layoutTreeState, blockData.oid)) { - const magnifyDecl: HeaderIconButton = { - elemtype: "iconbutton", - icon: "regular@magnifying-glass-minus", - title: "Minimize", - click: layoutModel?.onMagnifyToggle, - }; - endIconsElem.push( - - ); - } + endIconsElem.push(); const closeDecl: HeaderIconButton = { elemtype: "iconbutton", icon: "xmark-large", @@ -127,7 +134,6 @@ const BlockFrame_Header = ({ blockId, layoutModel, viewModel }: BlockFrameProps) const headerTextUnion = util.useAtomValueSafe(viewModel.viewText); const endIconsElem = computeEndIcons(blockData, viewModel, layoutModel); - const viewIconElem = getViewIconElem(viewIconUnion, blockData); let preIconButtonElem: JSX.Element = null; if (preIconButton) { @@ -174,51 +180,44 @@ const BlockFrame_Header = ({ blockId, layoutModel, viewModel }: BlockFrameProps) ); }; +const HeaderTextElem = React.memo(({ elem }: { elem: HeaderElem }) => { + if (elem.elemtype == "iconbutton") { + return ; + } else if (elem.elemtype == "input") { + return ; + } else if (elem.elemtype == "text") { + return
{elem.text}
; + } else if (elem.elemtype == "textbutton") { + return ( + + ); + } else if (elem.elemtype == "div") { + return ( +
+ {elem.children.map((child, childIdx) => ( + + ))} +
+ ); + } + return null; +}); + function renderHeaderElements(headerTextUnion: HeaderElem[]): JSX.Element[] { const headerTextElems: JSX.Element[] = []; - - function renderElement(elem: HeaderElem, key: number): JSX.Element { - if (elem.elemtype == "iconbutton") { - return ( - - ); - } else if (elem.elemtype == "input") { - return ; - } else if (elem.elemtype == "text") { - return ( -
- {elem.text} -
- ); - } else if (elem.elemtype == "textbutton") { - return ( - - ); - } else if (elem.elemtype == "div") { - return ( -
- {elem.children.map((child, childIdx) => renderElement(child, childIdx))} -
- ); - } - return null; - } - for (let idx = 0; idx < headerTextUnion.length; idx++) { const elem = headerTextUnion[idx]; - const renderedElement = renderElement(elem, idx); + const renderedElement = ; if (renderedElement) { headerTextElems.push(renderedElement); } } - return headerTextElems; } diff --git a/frontend/app/view/cpuplot/cpuplot.tsx b/frontend/app/view/cpuplot/cpuplot.tsx index 1b407a309..61e6d1c43 100644 --- a/frontend/app/view/cpuplot/cpuplot.tsx +++ b/frontend/app/view/cpuplot/cpuplot.tsx @@ -80,10 +80,6 @@ function CpuPlotView({ model }: { model: CpuPlotViewModel }) { const block = jotai.useAtomValue(model.blockAtom); const incrementCount = jotai.useSetAtom(model.incrementCount); // temporary - React.useEffect(() => { - console.log("plotData:", plotData); - }, [plotData]); - React.useEffect(() => { const temp = async () => { await incrementCount();