Support browser history in routing
Currently routing doesn't fully support browser history functionality, like handling the back button. See routing.kt.
We can add a window.popstate event in JS to send a websockets message with the current URL. The question now becomes how to (a) get the client's WebBrowser and its url, and (b) how to set url in such a way that it won't fire a pushState back onto the client.
(a) get the client's WebBrowser and it
Yes, this might require some rearranging, we could possibly use a handler in RemoteClientState to handle the back-button event, although that feels a bit kludgy.
(b) how to set url in such a way that it won't fire a pushState back onto the client.
We might need to add a boolean flag to url to record whether it was set on the client or the server, this can be used to ensure that a pushState is only sent if the URL change is server-initiated.
I decided to have a potshot at the problem because it's causing a double page reload for us when using the browser forward/back buttons. My first stop is to remove https://github.com/kwebio/kweb-core/blame/720b1d241411854eb27dc30b869a89d2982c2970/src/main/resources/kweb/kweb_bootstrap.js#L275 and see what's affected
Thanks @alkoclick, I've been digging through blame logs to try to remember the purpose of that, but no luck. Hopefully it's unnecessary.
Yeah, I removed and it and run a custom build without it today, it causes no difference for us (and in fact fixes a bunch of problems). I was going to actually test it on one of the test demos as well but my laptop died so tough luck :/
I can remove it and verify it on a few projects?
I think this is done, please reopen if not.