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

[front] feat: display unavailable video message on comparison page for unavaible video #1431

Merged
merged 19 commits into from
Apr 21, 2023

Conversation

GresilleSiffle
Copy link
Collaborator

@GresilleSiffle GresilleSiffle commented Mar 8, 2023

related to #1070


This PR attempts to fix the conflicts between #1426 and the branch main.

@OoIwazaruoO I've imported all your code as-is here, you can continue on this branch.

to-do

  • simplify the introduced complexity if possible
  • hunt bugs

this commit attempts to fix the conflict between main and
front-reload-unavailable-video-in-comparisons-page
@GresilleSiffle GresilleSiffle changed the title code imported from front-reload-unavailable-video-in-comparisons-page [rebased] Front reload unavailable video in comparisons page Mar 8, 2023
@GresilleSiffle GresilleSiffle changed the title [rebased] Front reload unavailable video in comparisons page [front] feat: reload unavailable videos in comparisons page Mar 14, 2023
@GresilleSiffle
Copy link
Collaborator Author

Hello @tournesol-app/maintainers

I've reviewed those changes and I'd like your input before going further.

(1) about the usage setTimeout to modify the states

The function handleChange and the useEffect hook, responsible of asking for new videos when an unavailable one is returned by the Auto button, use the setTimeout to set a state after a certain delay. I don't know if it's a common practice or something that should be avoided. What do you think @amatissart and @lfaucon ?

Regarding the useEffect, the timeout is used to enable the access again to the function getVideoForComparison, previously blocked by the setLoading(true).

See:

(2) about the auto-load feature

When opening a comparison link, the EntitySelectors will automatically replace the unavailable videos by available ones. As a result, opening or sharing a previously made comparison involving unavailable entities redirects to a different comparison. It's not possible anymore to see or edit those comparisons.

In my opinion this is a small problem, but a problem still: redirecting users to an unexpected place, and preventing them to edit their comparisons could be a source of frustration. This is something I'd like to avoid as much as possible in the UX: unexpected behaviours.

Propositions:

  • allow the users to disable the auto-load feature in the settings (out of scope)
  • allow the users to see and update their own comparisons even if the auto-load feature is enabled

(3) about the getVideoForComparison

We currently call a non-generic function in a supposedly generic effect.

As we don't have a generic getEntityForComparison, we could bypass this feature for non-video entities.

The feedback are more than welcome on this : )

@GresilleSiffle GresilleSiffle marked this pull request as ready for review March 14, 2023 08:38
Copy link
Member

@amatissart amatissart left a comment

Choose a reason for hiding this comment

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

The behavior on this branch has a few problems:

  • it's not possible to access a past comparison related to an unavailable video. The video is automatically replaced with another video without any explanation, which is very confusing for the user.
  • when selecting an unavailable video manually in one of the selectors, I can see the message "Only available videos can be compared". However it's still possible to submit the comparison.

But more importantly, I'm not confident with how the EntitySelector uses setTimeout in multiple places . It's not clear what is the problem they are supposed to solve, and if they are actually fixed especially when some requests would be slower than expected.

This problem seems to arise because the video availability is achieved independently from the existing requests to the API. This creates a lot of potential race conditions.
I think it could make sense to move the state related to the selected entities in a new dedicated state/context, in order to reduce the complexity of EntitySelector and define a single validation flow, to check the video availability, fetch the contributor rating, etc.

frontend/public/locales/en/translation.json Outdated Show resolved Hide resolved
frontend/src/features/entity_selector/EntitySelector.tsx Outdated Show resolved Hide resolved
frontend/src/features/comparisons/Comparison.tsx Outdated Show resolved Hide resolved
frontend/src/features/entity_selector/EntitySelector.tsx Outdated Show resolved Hide resolved
frontend/src/features/entity_selector/EntitySelector.tsx Outdated Show resolved Hide resolved
frontend/src/features/entity_selector/EntitySelector.tsx Outdated Show resolved Hide resolved
frontend/src/features/entity_selector/EntitySelector.tsx Outdated Show resolved Hide resolved
frontend/src/features/entity_selector/EntitySelector.tsx Outdated Show resolved Hide resolved
Copy link
Member

@amatissart amatissart left a comment

Choose a reason for hiding this comment

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

After discussion, let's remove the "autoReload" feature for now.

We can allow unavailable videos to be compared (or their past comparisons to be modified). The message used on the entity selector should be modified to clarify that.

cc @OoIwazaruoO

@OoIwazaruoO OoIwazaruoO changed the title [front] feat: reload unavailable videos in comparisons page [front] display unavailable video message on comparison page for unavaible video Apr 17, 2023
GresilleSiffle and others added 4 commits April 18, 2023 08:47
Co-authored-by: Adrien Matissart <amatissart@users.noreply.github.com>
entities -> elements
youtube -> YouTube

use a generic message in EntitySelector when the poll is not `videos`
Copy link
Collaborator Author

@GresilleSiffle GresilleSiffle left a comment

Choose a reason for hiding this comment

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

I can't approve a pull request I opened myself, but the code looks good to me 👍

It's far more simple now : ) @amatissart do you want to have a final look before approving?

Next step

We now have a small display bug making the duration not easy to read when the entities are not available (see the bottom right corner of the capture):

edit fixed by 1d7b731

capture

Copy link
Member

@amatissart amatissart left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the simplification @OoIwazaruoO @GresilleSiffle !

frontend/src/features/entity_selector/EntitySelector.tsx Outdated Show resolved Hide resolved
Co-authored-by: Adrien Matissart <amatissart@users.noreply.github.com>
@GresilleSiffle GresilleSiffle merged commit 0315379 into main Apr 21, 2023
@GresilleSiffle GresilleSiffle deleted the front-unavailable_video_in_comparison_ui branch April 21, 2023 12:07
@GresilleSiffle GresilleSiffle changed the title [front] display unavailable video message on comparison page for unavaible video [front] feat: display unavailable video message on comparison page for unavaible video Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend Front-end code of Tournesol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants