-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
feature: Implement Keybind Exclusivity in Task Assignment (#2191) #2312
base: master
Are you sure you want to change the base?
feature: Implement Keybind Exclusivity in Task Assignment (#2191) #2312
Conversation
…ty#2191) PROBLEM: The YouTube extension currently allows users to assign the same keybind to multiple tasks simultaneously, leading to potential conflicts and confusion among users. SOLUTION: Introduce a feature that enables keybind exclusivity when assigning tasks. - Implement a dialog prompt for confirmation before removing a keybind from other tasks. - When a user attempts to assign an already assigned keybind to a new task, a modal dialog is shown asking whether to replace the existing assignment. - If the user confirms, the keybind is removed from the previous task and assigned to the new one. If the user cancels, the new assignment is not made. IMPROVEMENTS: - Resolved inconsistencies in the reset button functionality to ensure it correctly handles keybind assignments. - Enhanced user experience by preventing multiple tasks from having the same keybind, aligning with common application practices. NOTE: New shortcuts only function after refreshing the page, which is due to an existing bug. Similarly, the keybind is only effectively reassigned after a page refresh. This resolves the issue reported in code-charity#2191. Co-authored-by: João Costa <[email protected]>
hi! @PedroBT03 thanks! There could also remain the option to keep the current way (not impossible ever actually wants to do two things with one key) Did you see #1565 ? ( we also made something to forbid website's defaults before https://github.com/code-charity/unlock-keyboard-and-mouse ) |
Thanks! We can definitely add the option to have the key assigned to different tasks and let the user decide, while also keeping the current functionality intact for those who prefer it. I didn't see issue you mentioned initially, but I have reviewed it now. When I refer to "default shortcuts," I mean the ones defined in the skeleton file (shortcuts.js). I believe you are referring to the website's defaults that work for regular YouTube, like the space bar for play/pause. We didn't work with those defaults, but we can make any necessary adaptations if needed. Thanks again for the feedback! Best regards, |
As I stated sometime ago satus Shortcuts code is non complete/broken. For example cant bind '>', it doesnt understand how Shift works. It also shows default YT shortcuts pretending to be able to change them :( Commit review: Tabs instead of spaces please. Those should not be globals:
dont use localstorage:
because it makes getDefaultShortcuts() dont store data in code, read it from extension.skeleton.main.layers.section.shortcuts.on.click instead:
no alerts please :) This is one of the bugs mentioned at the top, Instead we should either
both are outside the scope of this Commit. Just do nothing here :| showDialog
dont iterate over all settings
its unlikely but possible for another setting to have 'keys' property, should iterate only over shortcuts youtube/js&css/web-accessible/www.youtube.com/shortcuts.js Lines 163 to 164 in e57bfc2
It also ignores modifiers, so making 3 shortcuts '1', '1'+Shift (or rather '!'+Shift, impossible because our shortcuts code is bad as states at the top, so rather '!'+Shift), and another '1'+Shift will bring up a modal, answering Yes will delete both '1'+Shift and '1'.
dont close shortcut modal here before popping showDialog, only when user answers Yes inside showDialog.
copy&paste artefact? shortcut modal takes care of it on its own when closing
fine for now. In the future Extension should store only active modifiers (no false values), then this will need to be '!!(a.alt) !== !!(b.alt)' etc |
hi! @PedroBT03 (We didn't mean to have any defaults. Our defaults are just to show youtube's defaults ) Sorry this is more of a small project than a single issue...!... Yet luckily we aren't alone. Following through with @raszpl's review here will be great (and afterwards #1565), since so many people already use our shortcuts inspite of issues - and we can eventually provide the final code for use in other extensions) |
Thank you @raszpl @ImprovedTube for your detailed review and feedback. I will address the issues you pointed out. Firstly, I will convert all spaces to tabs throughout the codebase. Additionally, I will refactor the functions and variables to avoid using global scope as requested. Regarding the use of localStorage, I understand the concern and would appreciate some guidance on the preferred alternative method for storing and retrieving shortcut data. Can you tell us which alternatives we have to implement it? We used localstorage because the already used keybinds were lost when the page is refreshed. I will modify getDefaultShortcuts() to dynamically read from extension.skeleton.main.layers.section.shortcuts.on.click as suggested. Furthermore, I will remove the alert for keybind conflicts and avoid implementing any changes related to default YouTube shortcuts within this commit. I will rename showDialog to overrideShortcut and ensure it informs the user about the specific clashing shortcut. Additionally, I will adjust the iteration logic to ensure it only processes shortcuts, preventing potential conflicts with other settings. Finally, I will ensure the shortcut modal closes correctly only upon user confirmation, addressing the keydown event handling issue. I will proceed with these changes promptly and look forward to your guidance on the best practice for managing shortcut data storage. Thank you again for your guidance. Best regards, |
hi @PedroBT03! thank you! #1446 might explains more still😅 youtube/js&css/web-accessible/core.js Line 180 in 48a579a
"Youtube's defaults: #517 #110 #1566" (from #1565)
BTW, generally, our settings storage yet is loaded into "ImprovedTube.Storage" (in core.js) and can be update from content scripts with chrome.storage.local, while web-accessible scripts need a detour to send a message first. |
#517 had a good idea of displaying YT defaults, but instead of being merely displayed they are currently editable, and afaik that doesnt work. You cant rebind "Seek forward 10 seconds" despite extension pretending you could. Fast option is to display all YT shortcuts either separately on the bottom or in different color and disable Line 2325 in 6d369c1
This table https://www.toptal.com/developers/keycode/table shows how js maps Key Codes. Pressing Shift + 2 returns
which broken code in satus displays as |
thank you! @raszpl
strange!
(We could allow to deny some of YouTube's defaults) |
edited: forgot you need to reload for shortcuts to start working. Ok, so its not as dire as I thought.
only user configured shortcuts are being interpreted by: youtube/js&css/web-accessible/www.youtube.com/shortcuts.js Lines 18 to 21 in e57bfc2
the "default" ones are ignored. Binding something to 'Seek forward 10 seconds' will still trigger for both new and old shortcut unless old one is overridden by another shortcut. In effect You arent rebinding 'Seek forward 10 seconds', you are adding a second 'Seek forward 10 seconds' shortcut. Just realized we are missing an option to delete/unbind default shortcuts, a 4th button to display the shortcut empty and trigger a dummy preventDefault/stopPropagation action. |
turns out extension.skeleton.main.layers.section.shortcuts.on.click doesnt have all default shortcuts, for example its missing M for mute. Discovered by accident by trying to use M for my shortcut :) |
hey there is already a bug for that #1174 :) |
aand another thing: when checking if shortcut collides with one of YT default ones we cant just compare 1:1. For example there is SHIFT+N Next. User might try to configure Control+Shift+N and comparison will let him leading to frustration. EDIT: default
shortcuts show <> but those are rewind/FF 5 seconds on YT |
hi! :) @PedroBT03 |
PROBLEM:
The YouTube extension currently allows users to assign the same keybind to multiple tasks simultaneously, leading to potential conflicts and confusion among users.
SOLUTION:
Introduce a feature that enables keybind exclusivity when assigning tasks.
IMPROVEMENTS:
NOTE:
New shortcuts only function after refreshing the page, which is due to an existing bug. Similarly, the keybind is only effectively reassigned after a page refresh.
This resolves the issue reported in #2191.