cyclestreets / cyclescape

Cyclescape - cycle campaign group toolkit
https://www.cyclescape.org/
MIT License
33 stars 15 forks source link

Message links don't always work as expected #1017

Closed soundplusfury closed 2 years ago

soundplusfury commented 2 years ago

This one for example (last message or #92053) just seems to link to a thread rather than a specific message in it.

https://camcycle.cyclescape.org/threads/832

nikolai-b commented 2 years ago

@mvl22 this is due to https://github.com/cyclestreets/cyclescape/issues/1000 so now we lazily load the messages. The URL fragment is not sent to the server, they are just for the browser, so there is no way for the server to respond to a request

https://www.cyclescape.org/threads/123#message_456

any differently than a request to:

https://www.cyclescape.org/threads/123

and the default is to load threads lazily. We could change the implementation to be

https://www.cyclescape.org/threads/123?load_all_messages=1#message_456

so we would catch all URLs that look like https://www.cyclescape.org/threads/N#message_M and stick a query param in them which stopped the lazy loading. We'd need to update all the links we display and have a way to update links in existing messages.

mvl22 commented 2 years ago

I think the solution here is that the JS lazy loading should check after each AJAX load whether the message number in window.location.hash is present, and if not, to do another loading, etc., until it does get found, or the start of the thread is found (in which case the message number in the URL was invalid).

nikolai-b commented 2 years ago

Should be fixed on live. The solution we have might cause a bit of jerky scrolling but should work now.