I am writing a Firefox extension that automatically sorts bookmarks.
Everything works fine, except one thing:
The bookmarks are not refreshing.
The bookmarks get sorted, but Firefox don’t refresh the bookmark list.
I am using a bookmark observer to know when a bookmark is added.
In the onItemAdded() method, I call my sorting function. The folder gets sorted, but Firefox does not show it. If I close Firefox and reopen it, the folder is sorted. I can also see it sorted if I click on “Show all bookmarks” and click on the folder.
I added a button in my extension and when I click on it, the bookmarks get sorted without any problem. This problem comes when the bookmarks are sorted right after a bookmark insert or move.
By the way, my extension also sort bookmarks when the user moves a bookmark.
The bookmarks get refreshed if I move a bookmark within the same folder.
But they didn’t get refreshed if I move a bookmark in another folder.
So I looking for a way to refresh the Firefox bookmarks to show the sorted folder at the right time.
Is there a way of doing that?
If not, what do you propose?
Thanks.
I solved my problem by using setTimeout() so that the script wait one second before sorting.
This works fine and the bookmarks get sorted and refreshed.