mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
chore: remove unnecessary useCallback
This commit is contained in:
parent
8072e385f8
commit
c6fe580d33
3 changed files with 15 additions and 26 deletions
|
|
@ -41,10 +41,6 @@ export function SideBar() {
|
|||
|
||||
const blockLeaveRef = React.useRef(false)
|
||||
const { sidebarToggleMode } = configContext.value
|
||||
const onMouseLeaveSideBar: React.MouseEventHandler<HTMLElement> = React.useCallback(() => {
|
||||
if (blockLeaveRef.current) return
|
||||
if (sidebarToggleMode === 'float') setShouldExpand(false)
|
||||
}, [sidebarToggleMode, setShouldExpand])
|
||||
const onResizeStateChange = React.useCallback((state: ResizeState) => {
|
||||
blockLeaveRef.current = state === 'resizing'
|
||||
}, [])
|
||||
|
|
@ -79,7 +75,10 @@ export function SideBar() {
|
|||
collapsed: error || !shouldExpand,
|
||||
})}
|
||||
style={{ height: heightForSafari }}
|
||||
onMouseLeave={onMouseLeaveSideBar}
|
||||
onMouseLeave={() => {
|
||||
if (blockLeaveRef.current) return
|
||||
if (sidebarToggleMode === 'float') setShouldExpand(false)
|
||||
}}
|
||||
>
|
||||
<div className={'gitako-side-bar-body'}>
|
||||
<div className={'gitako-side-bar-content'}>
|
||||
|
|
|
|||
|
|
@ -29,16 +29,6 @@ export function AccessTokenSettings() {
|
|||
setAccessTokenInputValue('')
|
||||
}, [accessToken])
|
||||
|
||||
const onInputAccessToken = React.useCallback(
|
||||
({ currentTarget: { value } }: React.FormEvent<HTMLInputElement>) => {
|
||||
setAccessTokenInputValue(value)
|
||||
useAccessTokenHint.onChange(
|
||||
ACCESS_TOKEN_REGEXP.test(value) ? '' : 'Gitako does not recognize the token.',
|
||||
)
|
||||
},
|
||||
[], // eslint-disable-line react-hooks/exhaustive-deps
|
||||
)
|
||||
|
||||
const saveToken = React.useCallback(
|
||||
async (
|
||||
hint: typeof useAccessTokenHint.value = (
|
||||
|
|
@ -59,13 +49,6 @@ export function AccessTokenSettings() {
|
|||
[accessTokenInputValue], // eslint-disable-line react-hooks/exhaustive-deps
|
||||
)
|
||||
|
||||
const onPressAccessToken = React.useCallback(
|
||||
({ key }: React.KeyboardEvent) => {
|
||||
if (key === 'Enter') saveToken()
|
||||
},
|
||||
[saveToken],
|
||||
)
|
||||
|
||||
return (
|
||||
<SettingsSection
|
||||
title={
|
||||
|
|
@ -163,8 +146,15 @@ export function AccessTokenSettings() {
|
|||
placeholder="Or input here manually"
|
||||
onFocus={() => focusInput.onChange(true)}
|
||||
onBlur={() => focusInput.onChange(false)}
|
||||
onChange={onInputAccessToken}
|
||||
onKeyPress={onPressAccessToken}
|
||||
onChange={({ currentTarget: { value } }) => {
|
||||
setAccessTokenInputValue(value)
|
||||
useAccessTokenHint.onChange(
|
||||
ACCESS_TOKEN_REGEXP.test(value) ? '' : 'Gitako does not recognize the token.',
|
||||
)
|
||||
}}
|
||||
onKeyPress={({ key }) => {
|
||||
if (key === 'Enter') saveToken()
|
||||
}}
|
||||
/>
|
||||
<Button onClick={() => saveToken()} disabled={!accessTokenInputValue}>
|
||||
Save
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ function ToggleSidebarShortcutSettings() {
|
|||
placeholder={focused.value ? 'Press key combination' : 'Click here to set'}
|
||||
value={friendlyFormatShortcut(toggleShowSideBarShortcut)}
|
||||
onChange={noop}
|
||||
onKeyDown={React.useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
onKeyDown={e => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
// Clear shortcut with backspace
|
||||
const shortcut = e.key === 'Backspace' ? '' : keyHelper.parseEvent(e)
|
||||
useToggleShowSideBarShortcut.onChange(shortcut)
|
||||
}, [])} // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}}
|
||||
/>
|
||||
{shortcut === toggleShowSideBarShortcut ? (
|
||||
<Button
|
||||
|
|
|
|||
Loading…
Reference in a new issue