History dialog entries jump position and lose their titles when loaded
Watch this video in which I load a page from my history:
Screencast_from_06-23-2019_02_05_21_PM
Notice that when the page loads:
- It disappears from its original place in the history
- It appears at the top of the history
- The page title is replaced with the page URL (so the URL is listed twice)
Screenshot showing the poor final result, with the topmost history item missing its title:
We know the page relocates itself in history because the history dialog is based on the URLs table, not the visits table. Our history database is divided into hosts table, URLs table, and visits table. The hosts table tracks the number of times a host (e.g. example.com) has been visited. The URLs table tracks the number of times a particular URL (e.g. https://example.com/example) has been visited and also the last visit time. Only the visits table tracks all visits to a URL. Because the history dialog uses the URLs table, and the URLs table only tracks the last visit to that URL, the history item therefore disappears from the original history and jumps to the top of the page.
Chrome tracks all visits to a URL. I presume Firefox does too, but haven't checked. I kinda think we should probably display all visits. That would prevent the jumping issue: the visited URL would still appear at the top of the list, but it would not disappear from its previous location. Of course, this change would cause far more history items to appear in the history dialog, but that's probably OK since we're already saving them all anyway.
Then the next problem is that when a page starts loading, the page title is not available until partway through the load, so the URL gets displayed as a placeholder instead. The history database will be updated with the actual page title once the load is finished. I don't immediately have a suggestion for what we could do to make this look better. Maybe we could store the saved page title from history, assume it will be the same for the new page load, and show the old title instead of falling back to the URL. Or perhaps we could omit the subtitle and show only the URL as the page title, so at least we're not showing the URL twice.