You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Something I think we can improve on this "go to last tab" feature is to avoid having it do nothing. Right now, if we go from tab A to tab B and then close tab A, using the "go to last tab" feature will not do anything.
Solution
I think one clean solution that will fix all of the issues mentioned here and in other issues ( #30 , #14 , #32 , #39 ) is to use a stack to keep track of the previous pages in the background script. Basically, we keep track of a variable called current_tab_id and, every time a new tab becomes active, we push (the now outdated) current_tab_id onto the stack (we can limit the size of the stack to avoid memory issues) and update current_tab_id to the value of the new tab's id. This way, when the "go to last tab" command is called, the background script just keeps popping off the stack until it finds a tab that is not the current tab and is not closed (and then it updates the stack because it will move to a new tab).
That way, if we are in the hotkey flow of tab search, then we'll be able to go to the correct previous tab because the "tab search tab" will have been closed whether or not you use the "tab search page" or just close it.
Benefits of doing this
We don't need search_launch_tab_id anymore
openTabSearch() can be simplified
During the Hotkey flow of the "search tabs" functionality, we don't have to switch to the previous tab and the navigate to the new one anymore (because this makes the code kind of obscure).
We no longer need to check if a search is occurring from a tab or from a popup
The popup does not need to exchange messages with the background script and we can decouple the two (which is always good from a development standpoint).
The use of the stack makes our code more concise and to the point
Overall, I think this is a better way because it simplifies the logic (fewer if conditionals), is more expressive, can do more, decouples the popup from the background script, and makes the code easier to read.
The text was updated successfully, but these errors were encountered:
Something I think we can improve on this "go to last tab" feature is to avoid having it do nothing. Right now, if we go from tab A to tab B and then close tab A, using the "go to last tab" feature will not do anything.
Solution
I think one clean solution that will fix all of the issues mentioned here and in other issues ( #30 , #14 , #32 , #39 ) is to use a stack to keep track of the previous pages in the background script. Basically, we keep track of a variable called
current_tab_id
and, every time a new tab becomes active, we push (the now outdated)current_tab_id
onto the stack (we can limit the size of the stack to avoid memory issues) and updatecurrent_tab_id
to the value of the new tab's id. This way, when the "go to last tab" command is called, the background script just keeps popping off the stack until it finds a tab that is not the current tab and is not closed (and then it updates the stack because it will move to a new tab).That way, if we are in the hotkey flow of tab search, then we'll be able to go to the correct previous tab because the "tab search tab" will have been closed whether or not you use the "tab search page" or just close it.
Benefits of doing this
search_launch_tab_id
anymoreopenTabSearch()
can be simplifiedOverall, I think this is a better way because it simplifies the logic (fewer if conditionals), is more expressive, can do more, decouples the popup from the background script, and makes the code easier to read.
The text was updated successfully, but these errors were encountered: