Remove dependency on webContents.history
The history field of Electron's webContents module is no longer present beyond Electron 10, so we have to stop using it in order to upgrade.
webContents.history is used to manage a subset of browsing history within the app. My observation is that the global history (which includes itch:// URLs) is a superset of the webContents.history, so the theory is that we could rely entirely on the global history and back-forward navigation would work just as well.
Closes #2598
I tested this manually and back-forward navigation seems to work almost as well as before. I did notice that this introduces a minor bug which is that you can't (easily) go back from the Explore page; it goes to https://itch.io and then back to https://itch.io/. I figured I would still publish what I have since this new minor bug has workarounds, and/or in case someone can figure out a fix for it and/or is willing to accept this new bug in exchange for actually being able to run the app on Electron 11 without crashing right away.
Also it occurs to me that deleting this much code is pretty fishy, even to me. If I'm way out of line, I wouldn't be surprised. But this just seemed like the easiest path forward.
Updated this PR with 3 changes:
- Updated commit message to describe the new bug (back button ineffective if URL morphs)
- Added workaround specifically for the Explore sidebar entry so that it doesn't suffer from the new bug
- Removed
did-navigate-in-pagehooks so that embedded URLs don't get added to the history (noticed this in a devlog on itch.io, tested with https://help.twitter.com/en/using-twitter/how-to-embed-a-tweet)
At this point the only problem is that if you manually type a URL (e.g. example.com) and press back, it effectively reloads the page you're on. The workaround (not ideal) is right-clicking the back button and selecting the second entry in the dropdown menu.
Thanks for the contribution. I also spent time time investigating this. I think that at this point working on getting electron updated is more important that the bug that's left from removing the custom navigation code. There's a lot of refactoring that needs to take place going forward but I'm happy to accept this so we can push out a build with electron 11 at least.