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

Avoid cloning all profiles when subscribing and unsubscribing #5289

Merged

Conversation

absidue
Copy link
Member

@absidue absidue commented Jun 18, 2024

Avoid cloning all profiles when subscribing and unsubscribing

Pull Request Type

  • Performance improvement

Description

Here is a summary of the main improvements:

  • Update just the subscriptions list in the affected profiles, instead of creating a copy/clone of all profiles, even if they weren't affected
  • Subscribing in multiple profiles and unsubscribing in multiple profiles now only requires on database call and window sync per batch update
  • Only send the necessary data between windows.

Testing

Subscribe to and unsubscribe from channels in invididual profiles as well as the "All Channels" one. Additionally make sure that the changes are correctly synced between windows.

Desktop

  • OS: Windows
  • OS Version: 10
  • FreeTube version: 81cf817

@absidue absidue added the PR: low priority For pull requests that don't require a fast review. e.g. code cleanup label Jun 18, 2024
@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Jun 18, 2024
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) June 18, 2024 19:54
showToast(this.$t('Channel.Channel has been removed from your subscriptions'))

if (profile._id === MAIN_PROFILE_ID && profileIds.length > 1) {
showToast(this.$t('Channel.Removed subscription from {count} other channel(s)', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion (non-blocking, minor): Can do as a separate PR, as this is a pre-existing "issue", but we might as well pluralize the label instead of doing (s)

const profile = state.profileList.find(profile => profile._id === id)

// use filter instead of splice in case the subscription appears multiple times
// https://github.com/FreeTubeApp/FreeTube/pull/3468#discussion_r1179290877
Copy link
Collaborator

Choose a reason for hiding this comment

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

question (non-blocking, minor): Doesn't have to be considered for this PR, but wouldn't a user know that they're subscribed to a channel multiple times? That + the amount of time since this bug has been fixed (unsure exactly when) means maybe this is safe to make a splice now.

@FreeTubeBot FreeTubeBot merged commit bb28369 into FreeTubeApp:development Jun 19, 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 Jun 19, 2024
@absidue absidue deleted the better-subscription-logic branch June 19, 2024 04:07
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Jun 20, 2024
* development: (120 commits)
  Update version number to v0.21.0
  Remove limited donation methods (FreeTubeApp#5290)
  Translated using Weblate (Portuguese)
  Translated using Weblate (Portuguese (Portugal))
  Avoid cloning all profiles when subscribing and unsubscribing (FreeTubeApp#5289)
  Fix arrow keys not working in the Create New Playlist prompt (FreeTubeApp#5243)
  Bump ws from 8.16.0 to 8.17.1 (FreeTubeApp#5291)
  Remove a few bits of unused code (FreeTubeApp#5287)
  Update About page to display correct Freetube logo based on currently set theme (FreeTubeApp#5126)
  Translated using Weblate (Croatian)
  * Update playlist page titles (FreeTubeApp#5271)
  Update Invidious instances list (FreeTubeApp#5288)
  Translated using Weblate (Polish)
  Bump the eslint group with 2 updates (FreeTubeApp#5275)
  Bump marked from 12.0.2 to 13.0.0 (FreeTubeApp#5276)
  Bump sass from 1.77.4 to 1.77.5 (FreeTubeApp#5277)
  Bump lefthook from 1.6.15 to 1.6.16 (FreeTubeApp#5279)
  Bump webpack from 5.91.0 to 5.92.0 (FreeTubeApp#5278)
  Update Flatpak PR Workflow to work with updated module (FreeTubeApp#5270)
  Translated using Weblate (Portuguese)
  ...
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Jun 20, 2024
* development: (102 commits)
  Update version number to v0.21.0
  Remove limited donation methods (FreeTubeApp#5290)
  Translated using Weblate (Portuguese)
  Translated using Weblate (Portuguese (Portugal))
  Avoid cloning all profiles when subscribing and unsubscribing (FreeTubeApp#5289)
  Fix arrow keys not working in the Create New Playlist prompt (FreeTubeApp#5243)
  Bump ws from 8.16.0 to 8.17.1 (FreeTubeApp#5291)
  Remove a few bits of unused code (FreeTubeApp#5287)
  Update About page to display correct Freetube logo based on currently set theme (FreeTubeApp#5126)
  Translated using Weblate (Croatian)
  * Update playlist page titles (FreeTubeApp#5271)
  Update Invidious instances list (FreeTubeApp#5288)
  Translated using Weblate (Polish)
  Bump the eslint group with 2 updates (FreeTubeApp#5275)
  Bump marked from 12.0.2 to 13.0.0 (FreeTubeApp#5276)
  Bump sass from 1.77.4 to 1.77.5 (FreeTubeApp#5277)
  Bump lefthook from 1.6.15 to 1.6.16 (FreeTubeApp#5279)
  Bump webpack from 5.91.0 to 5.92.0 (FreeTubeApp#5278)
  Update Flatpak PR Workflow to work with updated module (FreeTubeApp#5270)
  Translated using Weblate (Portuguese)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: low priority For pull requests that don't require a fast review. e.g. code cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants