-
Notifications
You must be signed in to change notification settings - Fork 839
Add support for custom Selection Tools in right-click context menu #885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
ac11758
06179d9
7cd1777
fe4b856
0ea8bef
ee84477
7a86413
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types' | |||||||||
import { useState } from 'react' | ||||||||||
import { defaultConfig } from '../../config/index.mjs' | ||||||||||
import { PencilIcon, TrashIcon } from '@primer/octicons-react' | ||||||||||
import Browser from 'webextension-polyfill' | ||||||||||
|
||||||||||
SelectionTools.propTypes = { | ||||||||||
config: PropTypes.object.isRequired, | ||||||||||
|
@@ -36,7 +37,7 @@ export function SelectionTools({ config, updateConfig }) { | |||||||||
{t('Cancel')} | ||||||||||
</button> | ||||||||||
<button | ||||||||||
onClick={(e) => { | ||||||||||
onClick={async (e) => { | ||||||||||
e.preventDefault() | ||||||||||
if (!editingTool.name) { | ||||||||||
setErrorMessage(t('Name is required')) | ||||||||||
|
@@ -47,14 +48,17 @@ export function SelectionTools({ config, updateConfig }) { | |||||||||
return | ||||||||||
} | ||||||||||
if (editingIndex === -1) { | ||||||||||
updateConfig({ | ||||||||||
await updateConfig({ | ||||||||||
customSelectionTools: [...config.customSelectionTools, editingTool], | ||||||||||
}) | ||||||||||
} else { | ||||||||||
const customSelectionTools = [...config.customSelectionTools] | ||||||||||
customSelectionTools[editingIndex] = editingTool | ||||||||||
updateConfig({ customSelectionTools }) | ||||||||||
await updateConfig({ customSelectionTools }) | ||||||||||
} | ||||||||||
Browser.runtime.sendMessage({ | ||||||||||
type: 'REFRESH_MENU', | ||||||||||
}) | ||||||||||
PeterDaveHello marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Browser.runtime.sendMessage({ | |
type: 'REFRESH_MENU', | |
}) | |
}).catch(console.error) |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted refreshContextMenu()
helper function to eliminate code duplication across multiple sendMessage calls. (7a86413)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sendMessage call lacks error handling. Add .catch(console.error)
to handle potential messaging failures, consistent with the pattern mentioned in the PR description.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted refreshContextMenu()
helper function to eliminate code duplication across multiple sendMessage calls. (7a86413)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for Browser.runtime.sendMessage call. Add .catch(console.error)
to handle potential messaging failures consistently with other similar calls in the codebase.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted refreshContextMenu()
helper function to eliminate code duplication across multiple sendMessage calls. (7a86413)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sendMessage call lacks error handling. Add .catch(console.error)
to handle potential messaging failures, consistent with the pattern mentioned in the PR description.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted refreshContextMenu()
helper function to eliminate code duplication across multiple sendMessage calls. (7a86413)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for Browser.runtime.sendMessage call. Add .catch(console.error)
to handle potential messaging failures consistently with other similar calls in the codebase.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted refreshContextMenu()
helper function to eliminate code duplication across multiple sendMessage calls. (7a86413)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sendMessage call lacks error handling. Add .catch(console.error)
to handle potential messaging failures, consistent with the pattern mentioned in the PR description.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted refreshContextMenu()
helper function to eliminate code duplication across multiple sendMessage calls. (7a86413)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for Browser.runtime.sendMessage call. Add .catch(console.error)
to handle potential messaging failures consistently with other similar calls in the codebase.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted refreshContextMenu()
helper function to eliminate code duplication across multiple sendMessage calls. (7a86413)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sendMessage call lacks error handling. Add .catch(console.error)
to handle potential messaging failures, consistent with the pattern mentioned in the PR description.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted refreshContextMenu()
helper function to eliminate code duplication across multiple sendMessage calls. (7a86413)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parseInt result should be validated for NaN to prevent accessing invalid array indices. Add a check like
if (!isNaN(customIndex) && customIndex >= 0)
before using customIndex.Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added NaN validation and bounds checking for parseInt to handle edge cases more robustly. The function now validates the parsed index before array access. (7a86413)