refactor(editor): split B1 navigation hooks, category count on the overview card

This commit is contained in:
bchanot committed 2026-11-06 20:31:26 +01:00
1 parent bc2dba7c14
commit ca184da4d9
6 files changed
+166 -82

No files matched your search

@@ -78,12 +78,13 @@ function useViewFallback(
}, [doc, shown, dispatch])
}
function useScene({ doc, navigate, onOpenSection, focus }: Props): Scene {
const [ui, dispatch] = useReducer(uiReducer, initialUi)
const [root, setRoot] = useState<RootAttributes | null>(null)
const viewId = ui.viewId ?? mainViewId(doc)
const model = useViewModel(doc, viewId)
const own = model.measured && root?.viewId === viewId
/** « Aller à » an annotation: the request, with what it needs of the drawing's state. */
function useSceneRequest(
{ doc, focus }: Props,
ui: UiState,
viewId: string,
dispatch: Dispatch<UiAction>,
) {
useViewFallback(doc, ui.viewId, dispatch)
useAnnotationRequest(focus, doc, {
viewId,
@@ -94,6 +95,16 @@ function useScene({ doc, navigate, onOpenSection, focus }: Props): Scene {
dispatch({ type: 'select', id })
},
})
}
function useScene(props: Props): Scene {
const { doc, navigate, onOpenSection } = props
const [ui, dispatch] = useReducer(uiReducer, initialUi)
const [root, setRoot] = useState<RootAttributes | null>(null)
const viewId = ui.viewId ?? mainViewId(doc)
const model = useViewModel(doc, viewId)
const own = model.measured && root?.viewId === viewId
useSceneRequest(props, ui, viewId, dispatch)
return {
doc,
ui,