Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

nit: fix perf regression in hotkeys (#10302)

Co-authored-by: Samuel Newman <mozzius@protonmail.com>

authored by

Thomas May
Samuel Newman
and committed by
GitHub
dddc0227 5df51bde

+23 -13
+11 -4
src/lib/hotkeys/index.native.tsx
··· 1 + import {useMemo} from 'react' 2 + 1 3 export function Provider({children}: {children: React.ReactNode}) { 2 4 return children 3 5 } 6 + 7 + const noop = () => {} 4 8 5 9 export function useHotkeysContext() { 6 - return { 7 - enableScope: () => {}, 8 - disableScope: () => {}, 9 - } 10 + return useMemo( 11 + () => ({ 12 + enableScope: noop, 13 + disableScope: noop, 14 + }), 15 + [], 16 + ) 10 17 }
+12 -9
src/state/shell/drawer-open.tsx
··· 1 - import {createContext, useContext, useState} from 'react' 1 + import {createContext, useCallback, useContext, useState} from 'react' 2 2 3 3 import {useHotkeysContext} from '#/lib/hotkeys' 4 4 ··· 14 14 const [state, setState] = useState(false) 15 15 const {disableScope, enableScope} = useHotkeysContext() 16 16 17 - const setDrawerOpen = (open: boolean) => { 18 - if (open) { 19 - disableScope('global') 20 - } else { 21 - enableScope('global') 22 - } 23 - setState(open) 24 - } 17 + const setDrawerOpen = useCallback( 18 + (open: boolean) => { 19 + if (open) { 20 + disableScope('global') 21 + } else { 22 + enableScope('global') 23 + } 24 + setState(open) 25 + }, 26 + [disableScope, enableScope], 27 + ) 25 28 26 29 return ( 27 30 <stateContext.Provider value={state}>