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

Update subscription cache when visiting a channel #4667

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

absidue
Copy link
Member

@absidue absidue commented Feb 11, 2024

Update subscription cache when visiting a channel

Pull Request Type

  • Feature Implementation

Description

Currently when you visit a channel, we fetch the latest information from YouTube and display it to the user, we also update the channel name and thumbnail in the subscriptions database. What we don't do yet is update the subscriptions cache with the videos, shorts, live and community post content that we got.

This pull request changes the channel page, so that it updates the subscription cache with the information on the channel page. For the videos, live and community tabs, we just overwrite the current cache for that channel, as what we just received is the last known state (same as what a refresh on the subscriptions page would do). For the shorts tab we unfortunately cannot do that, as the shorts channel tab doesn't have published dates (we need them for sorting on the subscriptions page), on the subscriptions page we always use RSS for the shorts tab, instead this pull request will just update the title, channel name and view count of the existing items in the cache.

You might be wondering what the point of this is, as we don't syncronise the subscription cache across windows (each window has it's own one #4152) and don't persist it on disk, so they disappear between app launches. This is basically a "free" subscription refresh for the visited channel as we already have the information without making any additional API requests. It will mostly benefit users that use the same window for a long time, but will help if we do implement synchronisation across windows in the future or disk persistence, as it would also allow us to reduce API requests (e.g. this channel was refreshed less than 1 minute ago, no need to fetch it again).

Testing

As waiting for any of your subscribed channels to upload a new video would be a slow and unpredictable test case, here are two that allow you to skip the waiting.

Please note that all steps for a given test case have to be performed in the same window, as we don't synchronise the subscription cache between windows yet

Test case 1

This test case will require you to have DeArrow disabled and either not have any watch history or for you to pick a channel that has videos that you haven't watched.

  1. Enable Fetch feeds from RSS in the Subscription Settings section
  2. Refresh your subscriptions
  3. Visit one of the channels that you are subscribed to
  4. Go back to the subscriptions page
  5. Notice that video durations have shown up for the videos on that channel (if you have DeArrow enabled or have watched any of those videos, FreeTube would be showing the duration from there instead of nothing, so you wouldn't notice the difference).

Test case 2

  1. Disable Fetch feed automatically in the Subscription Settings section
  2. Create a new profile
  3. Subscribe to a channel that you aren't subscribed to yet from the search results or watch page (don't visit the channel page yet).
  4. Visit the subscriptions page and notice that it is empty
  5. Visit the channel
  6. Go back to the subscriptions page and notice that the videos, live and community tabs should now be populated (shorts won't be as the shorts channel tab doesn't have published dates, so we can only update the metadata in the existing cache, as we need the published dates for sorting)

Desktop

  • OS: Windows
  • OS Version: 10
  • FreeTube version: 0.19.1

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) February 11, 2024 17:29
@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Feb 11, 2024
@PikachuEXE
Copy link
Collaborator

If this is merged first, #4380 will need to test about this
Otherwise this need to test for that PR
With current state it's probably the earlier

Copy link
Collaborator

@PikachuEXE PikachuEXE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition I also tested:

  • Create/choose profile with >1 profile (auto fetch sub disabled)
  • Confirm no sub shown
  • Visit 1 channel
  • Confirm no sub shown
  • Visit remaining channels
  • Confirm sub (& others) shown

@FreeTubeBot FreeTubeBot merged commit 4020139 into FreeTubeApp:development Mar 1, 2024
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Mar 1, 2024
@absidue absidue deleted the update-sub-cache branch March 1, 2024 13:41
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Mar 4, 2024
* development: (29 commits)
  Translated using Weblate (Chinese (Traditional))
  Fix URL copied via right click menu (FreeTubeApp#4690)
  Translated using Weblate (Croatian)
  Wrap ft-icon buttons below before they go fully vertical (FreeTubeApp#4735)
  * Make activating a chapter selector makes window scroll to top like clicking on timestamp links (FreeTubeApp#4722)
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Portuguese (Brazil))
  Make video thumbnails have certain height before image loading starts to avoid layout shifts (FreeTubeApp#4723)
  Update subscription cache when visiting a channel (FreeTubeApp#4667)
  Fix fallback to Invidious for the podcasts channel tab (FreeTubeApp#4731)
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Arabic)
  Translated using Weblate (Polish)
  Translated using Weblate (Dutch)
  Translated using Weblate (Icelandic)
  Translated using Weblate (Spanish)
  Translated using Weblate (Arabic)
  Translated using Weblate (Icelandic)
  Translated using Weblate (Italian)
  Translated using Weblate (Chinese (Simplified))
  ...
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

Successfully merging this pull request may close these issues.

5 participants