SurfSense/surfsense_web/lib/layout-events.ts
suryo12 d571cb23fa refactor(web): use last-seen-tick comparison for slideout listener
Replace the boolean "skip first render" ref with a ref that stores the
previously-seen tick value. The effect now compares against the stored
value and only fires when it differs, which makes the dependency
naturally used (removes the `void slideoutOpenedTick;` acknowledgement)
and self-documents the intent of the guard.

Behavior is unchanged — both forms preserve the one-shot-per-event
semantics of the prior window-event implementation. The JSDoc on
`slideoutOpenedTickAtom` is updated to describe the new pattern.
2026-05-24 18:13:36 +07:00

11 lines
479 B
TypeScript

import { atom } from "jotai";
/**
* Tick counter that increments each time a sidebar slide-out panel opens.
* Consumers read this with `useAtomValue` and store the last-seen value in
* a ref so the effect fires only when the tick changes. This preserves the
* one-shot semantics of the previous window-event implementation: a
* subscriber that mounts after a panel has already opened does not
* retroactively re-trigger.
*/
export const slideoutOpenedTickAtom = atom(0);