Disable usePresence flags by default (#226)
This commit is contained in:
parent
e8c8168f0b
commit
4e4b8f83e9
1 changed files with 7 additions and 3 deletions
|
@ -21,7 +21,9 @@ export enum PresenceFlag {
|
||||||
const undefinedD = prism(() => undefined)
|
const undefinedD = prism(() => undefined)
|
||||||
undefinedD.keepHot() // constant anyway...
|
undefinedD.keepHot() // constant anyway...
|
||||||
|
|
||||||
function createPresenceContext(): InternalPresenceContext {
|
function createPresenceContext(options: {
|
||||||
|
enabled: boolean
|
||||||
|
}): InternalPresenceContext {
|
||||||
const currentUserHoverItemB = new Box<StudioSheetItemKey | undefined>(
|
const currentUserHoverItemB = new Box<StudioSheetItemKey | undefined>(
|
||||||
undefined,
|
undefined,
|
||||||
)
|
)
|
||||||
|
@ -61,6 +63,8 @@ function createPresenceContext(): InternalPresenceContext {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
usePresenceFlag(itemKey) {
|
usePresenceFlag(itemKey) {
|
||||||
|
if (!options.enabled) return undefined
|
||||||
|
|
||||||
const focusD = useMemo(() => {
|
const focusD = useMemo(() => {
|
||||||
if (!itemKey) return undefinedD
|
if (!itemKey) return undefinedD
|
||||||
// this is the thing being hovered
|
// this is the thing being hovered
|
||||||
|
@ -127,10 +131,10 @@ type InternalPresenceContext = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const presenceInternalCtx = React.createContext<InternalPresenceContext>(
|
const presenceInternalCtx = React.createContext<InternalPresenceContext>(
|
||||||
createPresenceContext(),
|
createPresenceContext({enabled: false}),
|
||||||
)
|
)
|
||||||
export function ProvidePresenceRoot({children}: React.PropsWithChildren<{}>) {
|
export function ProvidePresenceRoot({children}: React.PropsWithChildren<{}>) {
|
||||||
const presence = useMemo(() => createPresenceContext(), [])
|
const presence = useMemo(() => createPresenceContext({enabled: false}), [])
|
||||||
return React.createElement(
|
return React.createElement(
|
||||||
presenceInternalCtx.Provider,
|
presenceInternalCtx.Provider,
|
||||||
{children, value: presence},
|
{children, value: presence},
|
||||||
|
|
Loading…
Reference in a new issue