MCPcopy
hub / github.com/LegendApp/legend-list / setInitialRenderState

Function setInitialRenderState

src/utils/setInitialRenderState.ts:28–66  ·  view source on GitHub ↗
(
    ctx: StateContext,
    {
        didLayout,
        didInitialScroll,
    }: {
        didLayout?: boolean;
        didInitialScroll?: boolean;
    },
)

Source from the content-addressed store, hash-verified

26}
27
28export function setInitialRenderState(
29 ctx: StateContext,
30 {
31 didLayout,
32 didInitialScroll,
33 }: {
34 didLayout?: boolean;
35 didInitialScroll?: boolean;
36 },
37) {
38 const { state } = ctx;
39 const {
40 loadStartTime,
41 props: { onLoad },
42 } = state;
43 if (didLayout) {
44 state.didContainersLayout = true;
45 }
46 if (didInitialScroll) {
47 state.didFinishInitialScroll = true;
48 }
49
50 const isReadyToRender = Boolean(state.didContainersLayout && state.didFinishInitialScroll);
51 if (isReadyToRender && !peek$(ctx, "readyToRender")) {
52 set$(ctx, "readyToRender", true);
53 setAdaptiveRender(ctx, "normal", "ready");
54
55 if (state.props.drawDistance > INITIAL_DRAW_DISTANCE) {
56 scheduleFullDrawDistancePrewarm(ctx);
57 }
58
59 if (!state.didLoad) {
60 state.didLoad = true;
61 if (onLoad) {
62 onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
63 }
64 }
65 }
66}

Callers 4

setDidLayoutFunction · 0.90
completeFunction · 0.90

Calls 4

peek$Function · 0.90
set$Function · 0.90
setAdaptiveRenderFunction · 0.90

Tested by

no test coverage detected