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

Feat/different subscription behavior #2

Conversation

kommunarr
Copy link
Owner

Title

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

Description

Screenshots

Testing

Desktop

  • OS:
  • OS Version:
  • FreeTube version:

Additional context

…ubscriptions can be found in cache"

This reverts commit efd2498.
@kommunarr
Copy link
Owner Author

kommunarr commented Nov 27, 2023

@PikachuEXE Here is the PR with the different behavior. Also moves repeated functions to helper functions and renames certain functions for clarity to make it a bit cleaner. The idea is that it loads all the videos it can from the cache if automatic fetching is disabled.

The debate is whether showing partial videos when switching profiles would confuse any users, who would have Fetch Feed Automatically disabled & make the mistake of assuming that we were grabbing all of their subscriptions for all of their profiles. The main benefit of this change is that users will always have the most information available to them regardless of their actions (e.g., subscribing to a new profile, switching profiles) while still minimizing requests.

One compromise position is that we can show the # of channels updated in the refresh label (e.g., Videos feed from 7 channels last updated: 33 minutes ago). Even though that's technically inaccurate sometimes (some of the cached videos could be from a more recent timestamp; we're just showing the oldest cache date), it's communicating to the user what they need to know.

@kommunarr kommunarr force-pushed the feat/test-different-subscription-behavior branch from 18da33f to 706855c Compare November 27, 2023 04:54
@kommunarr kommunarr force-pushed the feat/test-different-subscription-behavior branch from 706855c to 515597b Compare November 27, 2023 04:56
@PikachuEXE
Copy link

PikachuEXE commented Nov 27, 2023

When users switch profile, and cached entries are shown and entries from some (1 ~ N-1) channels are absent.
They need to know

  • How many channels are in active profile
  • How many channels have remote entry fetching done (coz there might be no entry in remote)

to help determine whether a manual refresh is needed

(Not tested yet, working)

@kommunarr
Copy link
Owner Author

kommunarr commented Nov 27, 2023

So are you thinking something like a Videos feed last updated for X/Y channels: {timestamp} if X < Y? Where X is the # of channels for which remote entry fetching is done.

@PikachuEXE
Copy link

Yup

@kommunarr
Copy link
Owner Author

@PikachuEXE Updated now!
Screenshot_20231128_080800

@kommunarr kommunarr force-pushed the feat/test-different-subscription-behavior branch from 475917a to d589150 Compare November 28, 2023 14:10
@@ -140,3 +140,36 @@ export function addPublishedDatesInvidious(videos) {
return video
})
}

export async function loadSubscriptionVideosFromCacheOrServer(subscriptionComponent) {
subscriptionComponent.isLoading = true

Choose a reason for hiding this comment

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

I don't think this is a good practice to

  • pass the component inside
  • assume the properties of component

This seems like a parent component's job (or mixin?)

Choose a reason for hiding this comment

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

Ask @absidue for more~

Copy link
Owner Author

Choose a reason for hiding this comment

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

Mixins aren't a best practice, and neither is this I imagine. But I'm not sure what's a better practice in Vue 2 for handling code duplication.

Copy link
Owner Author

Choose a reason for hiding this comment

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

A renderless component as a parent, maybe? Not sure, but I can look into it if this is a serious enough code quality concern. Will wait to hear back first, though.

Copy link

@absidue absidue Nov 29, 2023

Choose a reason for hiding this comment

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

I agree with Pikachu here, passing in a component seems like such a bad idea, especially as this looks like it could be restructured to avoid that without too much work.

  1. Don't set loading in here, that can be done in the component before and after the function call.
  2. Use function parameters to pass the values you need in, e.g. fetchSubscriptionsAutomatically or just access that directly from the store in here.
  3. You are allowed to return values from functions, in this case you can do it instead of setting the property on the component.

Copy link
Owner Author

@kommunarr kommunarr Nov 29, 2023

Choose a reason for hiding this comment

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

I get that that's better practice, but it is annoying that all of the glue code requires almost identical code in each file. It ends up not really reducing the code duplication in these files much. Is what is in this commit closer to what you're getting at? (Ignore that the helper should now just be called something like tryLoadSubscriptionVideosFromCacheOrServer now)

Copy link
Owner Author

Choose a reason for hiding this comment

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

I guess I could also move the computed properties of cacheEntriesForAllActiveProfileChannels, videoCacheForAllActiveProfileChannelsPresent, and activeProfileId into the helper function since they're not being used elsewhere in these files to reduce the degree of code duplication, but that also feels bad

@PikachuEXE
Copy link

It works fine though (with a brief test)
Will re-test with test cases in FreeTubeApp#3668 when merged into FreeTubeApp#4380

kommunarr and others added 3 commits November 29, 2023 01:25
Copy link

This PR is stale because it has been open 28 days with no activity. Remove stale label or comment or this will be closed in 14 days.

Copy link

This PR was closed because it has been stalled for 14 days with no activity.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants