Skip to content

Commit

Permalink
📝 Update Presence example
Browse files Browse the repository at this point in the history
This change updates the Presence example to only send Presence updates
when the user actively changes their selection.

Remote clients automatically update Presence when new ops are applied,
so there's no need to send this information.
  • Loading branch information
alecgibson committed Jan 24, 2022
1 parent 326c5ab commit 0f8df7e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/rich-text-presence/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ function initialiseQuill(doc) {
});
var localPresence = presence.create(presenceId);

quill.on('selection-change', function(range) {
quill.on('selection-change', function(range, oldRange, source) {
// We only need to send updates if the user moves the cursor
// themselves. Cursor updates as a result of text changes will
// automatically be handled by the remote client.
if (source !== 'user') return;
// Ignore blurring, so that we can see lots of users in the
// same window. In real use, you may want to clear the cursor.
if (!range) return;
Expand Down

0 comments on commit 0f8df7e

Please sign in to comment.