LycheeOrg / Lychee-front

JS implementation of Lychee frontend
https://lycheeorg.github.io/
MIT License
48 stars 53 forks source link

Rework scroll position saving #266

Closed kamil4 closed 3 years ago

kamil4 commented 3 years ago

Fixes https://github.com/LycheeOrg/Lychee/issues/1027

This is essentially a cleanup of #230, which was restricted to albums with subalbums, as well as of some old code dating presumably to v3.

The bug in https://github.com/LycheeOrg/Lychee/issues/1027 was I believe due to a race condition between two callbacks with timeouts in album.js: one loading the content, the other restoring the scroll position. I solved that by moving the restoring code to view.js (where it gets invoked from the content loading callback).

In the process I noticed that there were two different versions of scroll position restoring code: one for the top level albums view (probably an old code dating back to v3), and another for albums with subalbums (from #230). We also didn't save the scroll position of albums without subalbums, which would trigger https://github.com/LycheeOrg/Lychee/issues/1027 as well. So I generalized the code to handle (hopefully) all cases: now the positions of all albums should be preserved, including the top level view and albums without subalbums.

sonarcloud[bot] commented 3 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

kamil4 commented 3 years ago

OK, I made an additional tweak for search results but this should be ready for review now.