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

feat: Added awarenessStateFilter option for filtering awareness.getState() #140

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

RubaXa
Copy link
Contributor

@RubaXa RubaXa commented Sep 6, 2023

This option is needed when we want to remove self "cursor" when opened N-tabs or other logic.

For example, in "GoogleDocs", this is exactly the behavior, they display N-1 "cursors" (N — number of tabs), but in the case of "Notion", they do not display their own "cursor".

yCursorPlugin(provider.awareness, {
  awarenessStateFilter: (_, __, user) => user.id !== getAuthUserId(),
})

@dmonad
Copy link
Member

dmonad commented Sep 7, 2023

Please explain the usecase first. Have you considered other solutions?

Also, this doesn't really prevent unauthorized users from sending awareness states. Instead, you should filter messages from unauthorized users.

@dmonad dmonad closed this Sep 7, 2023
@RubaXa
Copy link
Contributor Author

RubaXa commented Sep 7, 2023

@dmonad If I open a document in 2-tabs, I will see "cursor" from myself.

For example, in "GoogleDocs", this is exactly the behavior, they display N-1 "cursors" (N — number of tabs), but in the case of "Notion", they do not display their own "cursor".

Therefore, I want to be able to regulate this behavior, for example, through filtering.

@dmonad dmonad reopened this Sep 8, 2023
@dmonad dmonad merged commit 8ea7487 into yjs:master Sep 8, 2023
@dmonad
Copy link
Member

dmonad commented Sep 8, 2023

Okay, makes sense. Will get this into the next release.

@RubaXa
Copy link
Contributor Author

RubaXa commented Sep 8, 2023

Thanks a million lot 🔥

@eldh
Copy link

eldh commented Nov 29, 2023

Any chance we'll see a new release soon? Just found myself needing this…

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.

None yet

3 participants