-
Notifications
You must be signed in to change notification settings - Fork 394
Impls #1792 adds an ability to reopen current tab in the specific container with a shortcut #2721
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: main
Are you sure you want to change the base?
Impls #1792 adds an ability to reopen current tab in the specific container with a shortcut #2721
Conversation
|
Hey, guys. |
😭😭😭 |
|
@antondudakov this is open source and sometimes people just have no time to pay attentions because completely overloaded on their regular job. What I could advise to increase chances for faster review and acceptance of PR:
|
This is exactly what I did.
|
2647db2 to
81ee998
Compare
|
Hey @achernyakevich-sc, I hope you're doing well. |
|
@achernyakevich-sc, if you have a spare minute, please review. All addressed |
src/manifest.json
Outdated
| }, | ||
| "reopen_in_container_0": { | ||
| "suggested_key": { | ||
| "default": "Alt+Shift+1" |
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.
It would be best to let the default empty because conflicts with other addons or the browser are too common since there isn't a lot of key combos that are still free.
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.
Thanks, will do
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.
done
| if (command === "sort_tabs") { | ||
| backgroundLogic.sortTabs(); | ||
| return; | ||
| } | ||
|
|
||
| for (let i=0; i < backgroundLogic.NUMBER_OF_KEYBOARD_SHORTCUTS; i++) { | ||
| const key = "open_container_" + i; | ||
| const reopenKey = "reopen_in_container_" + i; | ||
| const cookieStoreId = identityState.keyboardShortcut[key]; | ||
|
|
||
| if (cookieStoreId === "none") { | ||
| continue; | ||
| } | ||
|
|
||
| if (command === key) { | ||
| if (cookieStoreId === "none") return; | ||
| browser.tabs.create({cookieStoreId}); | ||
| return; | ||
| } | ||
|
|
||
| if (command === reopenKey) { | ||
| backgroundLogic.reopenInContainer(cookieStoreId); | ||
| return; | ||
| } |
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.
I have returned to this piece of code third time and got in mind that it is quite hard for reading and understanding the logic. As in this PR @antondudakov add support of additional shortcuts then it would be reasonable as well to make small refactoring to make more transparent the shortcuts matching conditions and make it optimized as it is not possible at the same time initiate several shortcusts. :)
So I would propose to have flow controlling construction like:
if (command === "sort_tabs") {
backgroundLogic.sortTabs();
} else if (command.startsWith("open_container_")) {
for (let i=0; i < backgroundLogic.NUMBER_OF_KEYBOARD_SHORTCUTS; i++) {
const key = "open_container_" + i;
const cookieStoreId = identityState.keyboardShortcut[key];
if (command === key) {
if (cookieStoreId !== "none") {
browser.tabs.create({cookieStoreId});
}
break;
}
}
} else if (command.startsWith("reopen_in_container_")) {
for (let i=0; i < backgroundLogic.NUMBER_OF_KEYBOARD_SHORTCUTS; i++) {
const key = "reopen_in_container_" + i;
const cookieStoreId = identityState.keyboardShortcut[key];
if (command === key) {
if (cookieStoreId !== "none") {
backgroundLogic.reopenInContainer(cookieStoreId);
}
break;
}
}
}I didn't check this code but I hope you got my idea.
But finally to make it working it looks we need to change loadKeyboardShortcuts() function in identityState.js.
Some another changes I would propose:
- at the moment
reopenInContainer()function is not used anywhere so maybe we could move its functionality back to the correspondingelse if. At the moment there is no good reason for extraction. - I see at least three places where string literals like
open_container_andreopen_in_container_will be used so maybe it would be reasonable to place it somewhere as constant. But maybe not for this PR but for some separated.
@antondudakov if you agree, could you update PR's code correspondingly.
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.
Thanks, will do. I'll have some time next week
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.
Done
|
Hey, @bakulf, can you give feedback on this PR as well? I would really appreciate it. |
04d52b7 to
beb4a68
Compare
Before submitting your pull request
npm testand all tests passed.Description
Issue #1792
Type of change
Select all that apply.
reopen.in.container.with.shortcut.mov
PR to localization: mozilla-l10n/multi-account-containers-l10n#31