mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-30 07:39:06 +08:00
fix(SelectionToolbar): avoid earlier access
This commit is contained in:
parent
4cee09870a
commit
9c318c9526
@ -204,31 +204,6 @@ const SelectionToolbar: FC<{ demo?: boolean }> = ({ demo = false }) => {
|
||||
}
|
||||
}, [setTimeoutTimer])
|
||||
|
||||
const handleAction = useCallback(
|
||||
(action: ActionItem) => {
|
||||
if (demo) return
|
||||
|
||||
/** avoid mutating the original action, it will cause syncing issue */
|
||||
const newAction = { ...action, selectedText: selectedText.current }
|
||||
|
||||
switch (action.id) {
|
||||
case 'copy':
|
||||
handleCopy()
|
||||
break
|
||||
case 'search':
|
||||
handleSearch(newAction)
|
||||
break
|
||||
case 'quote':
|
||||
handleQuote(newAction)
|
||||
break
|
||||
default:
|
||||
handleDefaultAction(newAction)
|
||||
break
|
||||
}
|
||||
},
|
||||
[demo, handleCopy]
|
||||
)
|
||||
|
||||
const handleSearch = (action: ActionItem) => {
|
||||
if (!action.searchEngine) return
|
||||
|
||||
@ -256,6 +231,31 @@ const SelectionToolbar: FC<{ demo?: boolean }> = ({ demo = false }) => {
|
||||
window.api?.selection.hideToolbar()
|
||||
}
|
||||
|
||||
const handleAction = useCallback(
|
||||
(action: ActionItem) => {
|
||||
if (demo) return
|
||||
|
||||
/** avoid mutating the original action, it will cause syncing issue */
|
||||
const newAction = { ...action, selectedText: selectedText.current }
|
||||
|
||||
switch (action.id) {
|
||||
case 'copy':
|
||||
handleCopy()
|
||||
break
|
||||
case 'search':
|
||||
handleSearch(newAction)
|
||||
break
|
||||
case 'quote':
|
||||
handleQuote(newAction)
|
||||
break
|
||||
default:
|
||||
handleDefaultAction(newAction)
|
||||
break
|
||||
}
|
||||
},
|
||||
[demo, handleCopy]
|
||||
)
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<LogoWrapper $draggable={!demo}>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user