qzb / dustman

🗑 Firefox extension for closing tabs you no longer need

Home Page:https://addons.mozilla.org/addon/dustman

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pause the timer for all tabs when tabCount <= minTabCount

furkanarabaci opened this issue · comments

Problem : When you have <=5 ( at default ) tabs inactive for longer than 20 minutes ( default ) and when opened 6th tab, the first tab that went inactive for 20 minutes is closed instantly.

What should be happening : Only schedule tabs for closing when you have >5 tabs and stop timer when <=5 tabs.

I will try fixing this myself. If i am successful, i will make PR.

Hi there,
I actually like the current behavior, but I'd gladly merge a PR that allows setting an appropriate flag in the settings.

The problem is that I don't want to change the architecture of the addon significantly for this. But I think there is a way to implement it. Currently, the addon determines whether a tab should be discarded via firefox's built-in tabs.tab lastAccessed field, see here: https://github.com/qzb/dustman/blob/master/lib/autoclose.js#L39-L49

If you can implement this feature without changing the whole architecture, go ahead. I think the easiest way would be to keep track of times when only n tabs have been open recently, and then add the sum of these times in the comparison here.

I don't want to merge a solution that polls the browser every few seconds to check for tab status. The addon is comparatively lightweight currently and I'd like to keep it that way.

Well, i tried. The problem is, algorithm only relies on current time and lastAccessed time as you provided. There is nothing to stop in the first place. I thought of adding timer; starts at lastAccessed and ends at minInactiveMilliseconds. But only ticks if numTabsToClose>0.

The easiest way would be this, but it gives answer to " Does it really necessary" question a big no. It is O.K the way it is, but i will try implementing this at near future, maybe without changing the architecture.