ilpianista / harbour-SailHN

An unofficial Hacker News client for Sailfish OS
MIT License
3 stars 5 forks source link

Rewrite in QML? #5

Open szopin opened 1 year ago

szopin commented 1 year ago

There are so many little bugs, everytime you refresh you get different posts, comments are not loading properly, even after refresh half seem missing, would you oppose rewriting some of the app in pure QML (that allows me to work on an app on the bus etc). The nesting could be copied from SailSN (which is a poor man's quickditt copy), I'm sure we can find a way to get the posts in json format so maybe parts of sfv could be re-used too. Let me know what you think

ilpianista commented 1 year ago

Honestly? I would use that time to fix the little bugs instead.

If you want to send PRs or even fork SailHN go ahead, no problem from my side and we could even merge the fork once it's stable (if you wish).

szopin commented 1 year ago

I was thinking about moving the data pulling logic to qml/xhr to be able to troubleshoot on device, as when it's in cpp that cuts out like 90% of my available tinkering time out (unless I revisit creating chroot on device... maybe not a bad idea). Thanks for the reply, just wanted to reach out to see if you're open to changes or if it's a mostly done project (and I find myself browsing hn more recently too somehow so noticed discrepancies between desktop and mobile). I'll have a closer look and see if my approach is feasible, maybe the logged-out part can be easily done in qml for a start, if it's working and performant enough rewriting the rest might make sense

On Tuesday, 20 June 2023, Andrea Scarpino wrote:

Honestly? I would use that time to fix the little bugs instead.

If you want to send PRs or even fork SailHN go ahead, no problem from my side and we could even merge the fork once it's stable (if you wish).

-- Reply to this email directly or view it on GitHub: https://github.com/ilpianista/harbour-SailHN/issues/5#issuecomment-1598974366 You are receiving this because you authored the thread.

Message ID: @.***

-- Sent from my Jolla

ilpianista commented 1 year ago

Sounds good! :-)

szopin commented 1 year ago

Heya, it took quite a while and a few approaches that failed (synchronous requests, worker scripts...) but I finally got something that works: https://github.com/szopin/harbour-SailHN/tree/master Reworked the topstories to qml only (editing this in sfos browser on github was a pain as it ate all the CR/LFs, hope I didn't miss any) and then Story.qml is the meat, as it loads all comments and then sorts them to more or less the same order as they appear in browser. It takes ~8 seconds for 150 comment story on xperia XIII, which is not bad vs synchronous xhrs, of course the bigger comment trees will take longer but it seems to work good enough for 95% of stories. Let me know what you think and feel free to use any of the code (it's ugly but just to showcase functionality, sorting ends up being surprisingly quick about a secon for 1.5k comments)

edit: there is a small bug not sure how to tackle yet, 1-2 comments seem to not get moved properly, not sure if descendants are unreliable or my sorting is bit borked, but as the data is constantly changing and only some threads seem impacted... Annoying to debug edit2: should be fixed now, dead and deleted comments were not counted by them, even though they were returned from api, the problematic threads now sort properly I think

edit3: apparently not all, I think the returned number of kids is also impacted by deads/deletes, resorted to calling the simple sort twice and seems to work reliably on the one thread previous broke (calling it once is enough but shorter branches get bumped then and the order of branches ends up upside down, calling it twice gives the more or less same ordering as on the webpage with longer branches closer to parent comment)