Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query the primary feed in the background to preload the activities so they can be shown instantly when the user navigates to the feed page #901

Open
1 of 12 tasks
Tracked by #858
mayel opened this issue Mar 4, 2024 · 0 comments

Comments

@mayel
Copy link
Member

mayel commented Mar 4, 2024

That would fetch and cache the activities in a separate elixir process as soon as the user is logged in, to reduce the loading time when showing the feed.

Implementation details

After considering and prototyping several different approaches, it seems like we may have ended up with the most high level optimisation possible (compared to caching DB queries or any steps in between):

Now when signed in to Bonfire, no matter what page you're on you can click to view the feed and it appears instantly (it is already loaded in the background and rendered in a hidden div).

In this way every time you view the feed we avoid using extra resources and time for:

  • DB queries
  • preloads and preparing of the data
  • rendering on server
  • diffing on server
  • network usage / bandwidth
  • diffing on client
  • browser rendering

Of course it comes at the cost (especially when a user doesn't end up viewing their feed) of using extra:

  • queries/processing/diffing/bandwidth/etc loading the feed for every logged in user
  • user's browser CPU/RAM to render and keep it in DOM the whole time

And it requires that we fix and extensively test PubSub (see #839) to make new activities appear at top of the feed since user is not reloading it (and it would be even more of a resource waste to simply reload it every minute or whatever)

Still to-do (eg. broken as a result of this refactor)

  • show feed filters
  • show nav links or tabs for specific feeds (eg. local/fediverse) and/or filter presets (eg. publications/links/pictures/videos/audio/etc)
  • modals in feed activities (when in myfeed) not working - prob is just matter of using the right modal id
  • sometimes when going back from feed to something else it remains an empty page (or feed does not render)
  • lots of LV JS warnings (eg. duplicate ids)
  • actions not appearing in feed (prob because of previous point)
  • url not updated when navigating to feed
  • Feed link in sidebar not highlighted when the feed view is active

Stretch goals

@mayel mayel changed the title Query the primary feed within the PersistentLive background LiveView process (which is linked to an individual active user) to preload the activities so they can be shown instantly when the user navigates to the feed page Query the primary feed in the background to preload the activities so they can be shown instantly when the user navigates to the feed page Mar 9, 2024
mayel added a commit to bonfire-networks/bonfire_spark that referenced this issue Mar 9, 2024
mayel added a commit to bonfire-networks/bonfire_ui_social that referenced this issue Mar 9, 2024
mayel added a commit to bonfire-networks/bonfire_ui_common that referenced this issue Mar 9, 2024
mayel added a commit to bonfire-networks/bonfire_ui_common that referenced this issue Mar 9, 2024
mayel added a commit to bonfire-networks/bonfire_spark that referenced this issue Mar 10, 2024
mayel added a commit to bonfire-networks/bonfire_ui_common that referenced this issue Mar 10, 2024
mayel added a commit to bonfire-networks/bonfire_spark that referenced this issue Mar 10, 2024
mayel added a commit to bonfire-networks/bonfire_ui_social that referenced this issue Mar 10, 2024
mayel added a commit to bonfire-networks/bonfire_ui_common that referenced this issue Mar 10, 2024
mayel added a commit to bonfire-networks/bonfire_ui_social that referenced this issue Mar 11, 2024
mayel added a commit to bonfire-networks/bonfire_ui_common that referenced this issue Mar 11, 2024
@mayel mayel added this to the 0.9.12 - Optimisations milestone Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant