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

Fix rendering of the participant list #1208

Merged
merged 6 commits into from
Sep 27, 2018

Conversation

danxuliu
Copy link
Member

The participant list was rendered again on every collection event, even if nothing had changed; besides being unnecessary it also caused some flickering and it could also cause the participant menu to be suddenly closed while a moderator had it open to perform some action, like promoting another user.

This pull request fixes it so the participant list is rendered again only when something has actually changed. Moreover, instead of rendering the full list only the specific views of the participants that changed are rendered again.

Backbone requires a unique identifier for each model in a collection to
be able to properly sort the models, merge their state when updating
them... In the case of participants the id is their "userId" or their
"sessionId", depending on whether the participant is a user or a guest.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
The participant list view was rendered on every collection event to
overcome the problem of participant views not being rendered, but that
caused unneeded renderings, for example when the collection was synced
but it had not changed. Now that the id of models in the participant
collection is properly set the view for each participant is rendered
again as expected when the attributes in its model change, so it is no
longer needed to render the participant list on every collection event.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@nickvergessen
Copy link
Member

For me this does not update the online status anymore when a user joins/leaves 😿

Some of the attribute names, as well as the "checkSharingStatus" call,
look like leftovers from a copy-paste; now the proper names are used.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
When the collection is sorted after an update (for example, if a user is
promoted to a moderator) there is no need to render again each subview
of the participant list; Marionette provides "reorderOnSort" for those
cases, which simply reorders the already existing DOM nodes instead of
rendering the whole list again.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
The endpoints for moderation operations do not fit the default setup for
Backbone models, so the operations are performed directly with AJAX
requests on the view. Thus, after a successful request rendering again
the view has no visible effect, as the model it is based on has not
changed yet. Now the model is updated instead, which will trigger the
render with the new state; that state will be later refreshed with the
server state (although it should be the same) when the model is synced
again.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
When a participant is offline the ".participant-offline" CSS class is
added to the element of its view. However, when the view is rendered
again the element itself is reused and only its contents are replaced by
the template. Thus, the CSS class must be explicitly removed from the
element when the view is rendered if the user is now online.

As the CSS class is expected (by the CSS rules) to be set on the
participant element instead of on the link inside it the CSS class was
removed from the template. This makes no difference, though, as
"isOffline" was always undefined and thus the class was never set on the
link.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
@danxuliu danxuliu force-pushed the fix-rendering-of-the-participant-list branch from fc45ecd to b431015 Compare September 25, 2018 14:13
@danxuliu
Copy link
Member Author

For me this does not update the online status anymore when a user joins/leaves 😿

Cheer up, sad cat, it should be fixed now.

@nickvergessen nickvergessen merged commit 6ba97c9 into master Sep 27, 2018
@nickvergessen nickvergessen deleted the fix-rendering-of-the-participant-list branch September 27, 2018 12:55
@danxuliu
Copy link
Member Author

Backported to stable14, should I backport it to stable13 too or not (I have no preference in either way)?

@nickvergessen
Copy link
Member

Im not sure we release another 13

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