lazy_tab
lazy_tab copied to clipboard
Fix regression with discard behavior for new window creation
Fixes https://github.com/Jman/lazy_tab/issues/22 Fixes https://github.com/Jman/lazy_tab/issues/19
There was a regression with https://github.com/Jman/lazy_tab/pull/20 because tearing off a tab fires the window creation event, which would cause all tabs to be discarded. This would also happen if a new window was opened with a hotkey or from the menu.
The PR attempts a different solution for https://github.com/Jman/lazy_tab/issues/19 although in that case, the user needs to click Chrome's popup button to restore within the 7-second delay period (before the extension discards all tabs with the startup action).
These are the notes I wrote in the commit message:
- For the windows.onCreated handler, discard only the specific window that was created.
- This is more efficient because it does not loop over all windows each time a new window is created.
- Opening a new window or tearing off a tab will no longer discard the tabs in all other windows.
- Put a 7-second delay on startup discard of all tabs in all windows.
- This helps to ensure that all inactive tabs are discarded soon after startup, because sometimes the browser tries to reawaken some of the previously-discarded tabs after the browser loads.
- When a session is restored at startup after a crash, Chrome replaces the tabs in the current window (while it might also create new windows if multiple windows were previously open), so this delayed discard of all tabs can handle the existing window. The session restore option must be clicked within 7 seconds of opening the browser.