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

Disable Create Timeline button until derivative loads #4058

Merged
merged 2 commits into from
Mar 24, 2020

Conversation

Dananji
Copy link
Contributor

@Dananji Dananji commented Mar 20, 2020

No description provided.

Copy link
Member

@cjcolvar cjcolvar left a comment

Choose a reason for hiding this comment

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

Currently there is some JS which does a similar check and then reloads the page when a player can be displayed. Does it make sense to do it that way instead of adding another JS check? I'm thinking of adding the check:

<% if @currentStream.present? and @currentStream.derivatives.present? %>

around the partial render here:

<%= render partial: 'timeline' if current_ability.can? :create, Timeline %>

@Dananji
Copy link
Contributor Author

Dananji commented Mar 23, 2020

Currently there is some JS which does a similar check and then reloads the page when a player can be displayed. Does it make sense to do it that way instead of adding another JS check? I'm thinking of adding the check:

<% if @currentStream.present? and @currentStream.derivatives.present? %>

around the partial render here:

<%= render partial: 'timeline' if current_ability.can? :create, Timeline %>

@cjcolvar I tried using this if-block within the button, but I was not able to make it work. Let me try this way and see if it works 👍
But this will stop rendering the create timeline button until the derivative is present, which is different from disabling the button..

@cjcolvar
Copy link
Member

@Dananji Oh, that's a good point. We probably just want to disable instead of not render so the UI is consistent.

@Dananji
Copy link
Contributor Author

Dananji commented Mar 23, 2020

I used @currentStream.present? and @currentStream.derivatives.present? condition on timeline partial render. It renders the Create Timeline button on page reload, it did not stop it from rendering as I expected.
So I used it on the button like this;

<button type="button" class="btn btn-default" id="timeline-btn" data-toggle="modal" data-target="#timelineModal" style="margin-top: 10px;" <% if !@currentStream.present? and !@currentStream.derivatives.present? %>disabled<% end %> >
    Create Timeline
</button>

And the button is not disabled when the player shows 00:00 as the duration of the media (which means the derivative is not loaded)
It seems the condition @currentStream.present? and @currentStream.derivatives.present? evaluates to true from the start.

@cjcolvar
Copy link
Member

Ok, sorry, I think I understand now what this PR was initially trying to solve. I was thinking this was for the corner case where the derivatives were still being generated, but maybe this is more about just disabling the button until the player finishes loading the stream (to avoid issues with initializing the custom timeline start/end times?). If this is the case then maybe we want to do the same for the Add to Playlist button? And maybe the button should be disabled on page render but enabled by JS?

@Dananji
Copy link
Contributor Author

Dananji commented Mar 23, 2020

@cjcolvar Yeah, I thought the same initially.
Yes, this is to avoid initializing the custom timeline start/end times in the modal form.
Add to Playlist button => the ones in the accordion or the icon on mediaelement player ?

@cjcolvar
Copy link
Member

I think just the icon on the player since it has custom start/end times but the buttons on the accordion don't.

Copy link
Member

@cjcolvar cjcolvar left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me.

@Dananji Dananji merged commit b0a163e into develop Mar 24, 2020
@Dananji Dananji deleted the timeline-create-bug branch March 24, 2020 18:10
@joncameron joncameron mentioned this pull request Jun 9, 2020
22 tasks
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.

2 participants