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 top nav search input to direct to channel panel when channel URL provided #1221

Conversation

PikachuEXE
Copy link
Collaborator

@PikachuEXE PikachuEXE commented Apr 22, 2021

Pull Request Type
Please select what type of pull request this is:

  • Feature Implementation

Related issue
#1218

Description
This PR makes channel URL input in search input box in top nav handled by redirecting to channel view.
Instead of searching with it
Channel URL expected to be like /channel/{channelID}

Screenshots (if appropriate)

Apr-22-2021.10-01-22.mp4

Testing (for code that is not small enough to be easily understandable)

Desktop (please complete the following information):

  • OS: MacOS
  • OS Version: 10.15.7
  • FreeTube version: 12.0.0 (latest on development actually)

Additional context
Add any other context about the problem here.


return extractors.reduce((a, c) => a || c(), null) || false
},

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea, unfortunately 2 out of 4 channel links are not covered by this.
Channel links can be constructed the following ways:
/channel/id
/user/userName
/c/name
/name

That is the reason @Svallinn wanted to reuse the existing extraction code in #1218

@PikachuEXE PikachuEXE force-pushed the feature/open-channel-url-directly branch from acdb07e to 457696e Compare April 27, 2021 06:03
@PikachuEXE
Copy link
Collaborator Author

PikachuEXE commented Apr 27, 2021

Extracted a function (but not the entire handleYoutubeLink) which tries to extract info from input text if it's Youtube URL
I am assuming the handling of different Youtube URL types might be slightly different in different context

Tested with
https://youtu.be/UlJB3t55u_c (Top nav search box entry & link clicking)
https://www.youtube.com/watch?v=YZCPlbOuxJY (Top nav search box entry & link clicking)
http://www.youtube.com/EEVblog2 (Top nav search box entry & link clicking)
https://www.youtube.com/eevdiscover (Top nav search box entry & link clicking)

https://youtu.be/WDH11NVtxek (Top nav search box entry)
https://www.youtube.com/playlist?list=PLzFTGYa_evXiUoQ4-sWk4-2E2XUbcRLuc (Top nav search box entry & link clicking)

https://www.youtube.com/channel/UCeqUUXaM75wrK5Aalo6UorQ (Top nav search box entry)

Comment on lines 300 to 301
const v = this

Copy link
Member

@Svallinn Svallinn Apr 27, 2021

Choose a reason for hiding this comment

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

Since you're using an arrow function for the callback, you can get rid of the v identifier and replace it with this.
Right now, there's a mixture of the two.


case 'invalid_url':
default: {
router.push({
Copy link
Member

Choose a reason for hiding this comment

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

Should be this.$router.

Copy link
Member

@Svallinn Svallinn left a comment

Choose a reason for hiding this comment

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

It looks pretty good to me :)

The only thing that's really itching at me is the fact that a lot of the result logic is repeated in the two callbacks used in the getYoutubeUrlInfo dispatches.

But the only thing that came to mind in order to "fix" it was gimmicky hacks like passing this to the dispatch and making use of errors and catch callbacks, so I'm just gonna ignore the itching entirely.

@GilgusMaximus
Copy link
Contributor

GilgusMaximus commented Apr 27, 2021

The only thing that's really itching at me is the fact that a lot of the result logic is repeated in the two callbacks used in the getYoutubeUrlInfo dispatches.

In theory yes, but when looking at the proportion of code deleted and code added, I would argue this is fair enough. Also it is not like I have never seen stuff like that in other parts of the code / modules before

@GilgusMaximus
Copy link
Contributor

Code looks good in total. So if you could add the changes @Svallinn annotated, I would test it a last time and then merge it

@PikachuEXE PikachuEXE force-pushed the feature/open-channel-url-directly branch from d0211cd to 74c0701 Compare April 28, 2021 01:49
@PikachuEXE PikachuEXE force-pushed the feature/open-channel-url-directly branch from 74c0701 to 04d29c4 Compare April 28, 2021 01:51
@PikachuEXE PikachuEXE force-pushed the feature/open-channel-url-directly branch from 04d29c4 to 4460cb3 Compare April 28, 2021 01:55
@PikachuEXE
Copy link
Collaborator Author

Requested changes made
The callbacks for getVideoParamsFromUrl in each component are slightly different when handling default and invalid_url cases
e.g. Clicking on a link vs entering a valid but not youtube URL in top nav

Generally I keep this kind of "duplicate" code around (with slight difference) until there is too much copy & paste happening.

For router.push (which can be replaced by this.$router.push)
there is still one occurrence in
https://github.com/FreeTubeApp/FreeTube/blob/development/src/renderer/components/side-nav/side-nav.js#L63

@GilgusMaximus
Copy link
Contributor

Thanks for putting in the work and changes, appreciate it a lot. Works great for all channel types :)

@GilgusMaximus GilgusMaximus merged commit 82aeaac into FreeTubeApp:development Apr 28, 2021
@PikachuEXE PikachuEXE deleted the feature/open-channel-url-directly branch April 29, 2021 01:11
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.

3 participants