Can't make removeVisitsByTimeframe method work.

Talk about add-ons and extension development.
Post Reply
4meFirst
Posts: 7
Joined: May 6th, 2015, 1:58 am

Can't make removeVisitsByTimeframe method work.

Post by 4meFirst »

So, I don't even know how to describe the problem, here is the code:

Code: Select all

var browserHistory = Cc["@mozilla.org/browser/nav-history-service;1"]
                    .getService(Ci.nsIBrowserHistory);


Code: Select all

// clear one 
var now = Date.now();
browserHistory.removeVisitsByTimeframe(now - (60000 * 60), now);


And it just does nothing, no errors, no warnigs, no logs. I have no idea why this code doesn't clear the history, please help.
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: Can't make removeVisitsByTimeframe method work.

Post by lithopsian »

How do you know it does nothing? This isn't supposed to clear history. It only removes visits in the specified range of times, although this may completely invalidate some cache entries.

In your particular case, the times given are probably not what you intended. You have used milliseconds since epoch, while the function is expecting microseconds since epoch. So you have actually requested to remove visits for a short period in January 1970.
4meFirst
Posts: 7
Joined: May 6th, 2015, 1:58 am

Re: Can't make removeVisitsByTimeframe method work.

Post by 4meFirst »

Thanks lithopsian, I saw no result in history so I thought it does nothing, but this was my problem, I called it with milliseconds, I changed it and now see the results.
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: Can't make removeVisitsByTimeframe method work.

Post by lithopsian »

4meFirst wrote:Thanks lithopsian, I saw no result in history so I thought it does nothing, but this was my problem, I called it with milliseconds, I changed it and now see the results.

Excellent.
Post Reply