The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "perf: eagerly compute explorer nodes to avoid re-render in memoized value"

This reverts commit 16a9caa555a2d63b7ff8af0731fbfd3231d6225c.

+45 -44
+36 -40
quartz/components/Explorer.tsx
··· 7 7 import { QuartzPluginData } from "../plugins/vfile" 8 8 import { classNames } from "../util/lang" 9 9 import { i18n } from "../i18n" 10 - import { VNode } from "preact" 11 10 12 11 // Options interface defined in `ExplorerNode` to avoid circular dependency 13 12 const defaultOptions = { ··· 45 44 // memoized 46 45 let fileTree: FileNode 47 46 let jsonTree: string 48 - let component: VNode 49 47 let lastBuildId: string = "" 50 48 51 49 function constructFileTree(allFiles: QuartzPluginData[]) { ··· 84 82 if (ctx.buildId !== lastBuildId) { 85 83 lastBuildId = ctx.buildId 86 84 constructFileTree(allFiles) 87 - const tree = ExplorerNode({ node: fileTree, opts, fileData }) 88 - component = ( 89 - <div class={classNames(displayClass, "explorer")}> 90 - <button 91 - type="button" 92 - id="explorer" 93 - data-behavior={opts.folderClickBehavior} 94 - data-collapsed={opts.folderDefaultState} 95 - data-savestate={opts.useSavedState} 96 - data-tree={jsonTree} 97 - aria-controls="explorer-content" 98 - aria-expanded={opts.folderDefaultState === "open"} 99 - > 100 - <h2>{opts.title ?? i18n(cfg.locale).components.explorer.title}</h2> 101 - <svg 102 - xmlns="http://www.w3.org/2000/svg" 103 - width="14" 104 - height="14" 105 - viewBox="5 8 14 8" 106 - fill="none" 107 - stroke="currentColor" 108 - stroke-width="2" 109 - stroke-linecap="round" 110 - stroke-linejoin="round" 111 - class="fold" 112 - > 113 - <polyline points="6 9 12 15 18 9"></polyline> 114 - </svg> 115 - </button> 116 - <div id="explorer-content"> 117 - <ul class="overflow" id="explorer-ul"> 118 - {tree} 119 - <li id="explorer-end" /> 120 - </ul> 121 - </div> 122 - </div> 123 - ) 124 85 } 125 86 126 - return component 87 + return ( 88 + <div class={classNames(displayClass, "explorer")}> 89 + <button 90 + type="button" 91 + id="explorer" 92 + data-behavior={opts.folderClickBehavior} 93 + data-collapsed={opts.folderDefaultState} 94 + data-savestate={opts.useSavedState} 95 + data-tree={jsonTree} 96 + aria-controls="explorer-content" 97 + aria-expanded={opts.folderDefaultState === "open"} 98 + > 99 + <h2>{opts.title ?? i18n(cfg.locale).components.explorer.title}</h2> 100 + <svg 101 + xmlns="http://www.w3.org/2000/svg" 102 + width="14" 103 + height="14" 104 + viewBox="5 8 14 8" 105 + fill="none" 106 + stroke="currentColor" 107 + stroke-width="2" 108 + stroke-linecap="round" 109 + stroke-linejoin="round" 110 + class="fold" 111 + > 112 + <polyline points="6 9 12 15 18 9"></polyline> 113 + </svg> 114 + </button> 115 + <div id="explorer-content"> 116 + <ul class="overflow" id="explorer-ul"> 117 + <ExplorerNode node={fileTree} opts={opts} fileData={fileData} /> 118 + <li id="explorer-end" /> 119 + </ul> 120 + </div> 121 + </div> 122 + ) 127 123 } 128 124 129 125 Explorer.css = explorerStyle
+9 -4
quartz/components/ExplorerNode.tsx
··· 224 224 class="content" 225 225 data-folderul={folderPath} 226 226 > 227 - {node.children.map((childNode) => 228 - // eagerly render children so we can memoize properly 229 - ExplorerNode({ node: childNode, opts, fileData, fullPath: folderPath }), 230 - )} 227 + {node.children.map((childNode, i) => ( 228 + <ExplorerNode 229 + node={childNode} 230 + key={i} 231 + opts={opts} 232 + fullPath={folderPath} 233 + fileData={fileData} 234 + /> 235 + ))} 231 236 </ul> 232 237 </div> 233 238 </li>