Skip to content

Conversation

@antondudakov
Copy link

@antondudakov antondudakov commented Feb 21, 2025

Before submitting your pull request

  • I agree to license my code under the MPL 2.0 license.
  • I rebased my work on top of the main branch.
  • I ran npm test and all tests passed.
  • I added test coverages if relevant.

Description

Issue #1792

Type of change

Select all that apply.

  • Bug fix
  • New feature
  • Major change (fix or feature that would cause existing functionality to work differently than in the current version)
Screenshot 2025-02-21 at 2 54 37 PM
reopen.in.container.with.shortcut.mov

PR to localization: mozilla-l10n/multi-account-containers-l10n#31

@antondudakov
Copy link
Author

Hey, guys.
Can I have a review, please?
@dannycolin
@groovecoder
@rafeerahman

@antondudakov
Copy link
Author

Hey, guys.
Can I have a review, please?
@dannycolin
@groovecoder
@rafeerahman

😭😭😭
Can we have this?

@antondudakov
Copy link
Author

Hey, guys.
Can I have a review, please?
@dannycolin
@groovecoder
@rafeerahman

😭😭😭 Can we have this?

@lesleyjanenorton

@achernyakevich-sc
Copy link

Hey, guys.
Can I have a review, please?
@dannycolin
@groovecoder
@rafeerahman

😭😭😭 Can we have this?

@lesleyjanenorton

@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:

  • implement only functionality that you would like to get: less code to review - easier to review and bigger chance to be reviewed.
  • if you would like to have code refactored - create separate PR: less code to review and with no new functionality - easier to review and bigger chance to be reviewed.
  • create a GitHub Issue that will describe what is the feature and how it will work, sometimes discussion in the issue result to completely different direction of feature implementation than initially it was expected.

@antondudakov
Copy link
Author

Hey, guys.
Can I have a review, please?
@dannycolin
@groovecoder
@rafeerahman

😭😭😭 Can we have this?

@lesleyjanenorton

@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:

* implement only functionality that you would like to get: less code to review - easier to review and bigger chance to be reviewed.

* if you would like to have code refactored - create separate PR: less code to review and with no new functionality - easier to review and bigger chance to be reviewed.

* create a GitHub Issue that will describe what is the feature and how it will work, sometimes discussion in the issue result to completely different direction of feature implementation than initially it was expected.

This is exactly what I did.

  1. The code that implement feature is just around 50 lines of code;
  2. it's not a refactoring;
  3. There's an issue Keyboard shortcut for "Reopen this site in" #1792, I also mentioned my PR in comments in the issue

@antondudakov antondudakov force-pushed the antondudakov/reopen-shortcuts branch 2 times, most recently from 2647db2 to 81ee998 Compare July 15, 2025 06:59
@antondudakov
Copy link
Author

Hey @achernyakevich-sc, I hope you're doing well.
Could you provide a review, please? I've addressed all your comments. 🙏🥹

@antondudakov antondudakov changed the title adds an ability to reopen current tab in the specific container with a shortcut Impls #1792 adds an ability to reopen current tab in the specific container with a shortcut Aug 25, 2025
@antondudakov
Copy link
Author

antondudakov commented Aug 25, 2025

@achernyakevich-sc, if you have a spare minute, please review. All addressed

},
"reopen_in_container_0": {
"suggested_key": {
"default": "Alt+Shift+1"
Copy link
Collaborator

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will do

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 19 to 44
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;
}
Copy link

@achernyakevich-sc achernyakevich-sc Aug 30, 2025

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 corresponding else if. At the moment there is no good reason for extraction.
  • I see at least three places where string literals like open_container_ and reopen_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.

Copy link
Author

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@antondudakov
Copy link
Author

Hey, @bakulf, can you give feedback on this PR as well? I would really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants