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

[Bug]: Presence object does not have localUser object #640

Closed
1 task done
mscherotter opened this issue Jun 8, 2023 · 3 comments
Closed
1 task done

[Bug]: Presence object does not have localUser object #640

mscherotter opened this issue Jun 8, 2023 · 3 comments
Labels
bug Something isn't working new submission Issues that have been filed and not yet processed by DRI

Comments

@mscherotter
Copy link

mscherotter commented Jun 8, 2023

  • I have reviewed the FAQ and known issues and did not find my topic

I have updated my code to use the new localUser object on the LivePresence class. Using the test live share server running on localHost, the presence object that is the first argument of the presenceChanged event does not have the localUser object. It has the previous userId, data, and state properties.

image

Provide a clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

Provide a clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop(s) (please complete the following information):

  • OS: [e.g. macOS]
  • Browser [e.g. chrome, safari]
  • Version liveShare 1.0.1

Smartphone (please complete the following information):

  • Device: Wndows
  • OS: Windows 11
  • Browser Edge
  • Version [e.g. 22]

Additional context

Add any other context about the problem here.

@mscherotter mscherotter added bug Something isn't working new submission Issues that have been filed and not yet processed by DRI labels Jun 8, 2023
@huntj88
Copy link
Contributor

huntj88 commented Jun 9, 2023

The LivePresenceUser userPresence variable in your screenshot still has userId, data, and state properties, which are the grayed out properties in your screenshot.

LivePresence.localUser is a property on the top level LivePresence object, not the LivePresenceUser object returned in onPresenceChanged.

The localUser property returns a LivePresenceUser object which is the same type as the one returned in onPresenceChanged.

Does that help?

LivePresence also starts to listen for other presence updates before the local user is finished initializing.
If you use the top level LivePresence.localUser, there is a chance you could receive onPresenceChanged updates for other clients before the localUser is defined.

@mscherotter
Copy link
Author

This is after the initialization. The problem is that the Typescript definition of the LivePresence object no longer has the userId, data, and state properties - I have to cast to have my TypeScript code compile.

@ryanbliss
Copy link
Contributor

@mscherotter I'd recommend making your app robust around whether or not the localUser is defined or not. That can take a second before it is ready, since it is an asynchronous operation to fetch the user info. There should be no reason to cast as long as your app can handle localUser being undefined temporarily.

@ryanbliss ryanbliss closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new submission Issues that have been filed and not yet processed by DRI
Projects
None yet
Development

No branches or pull requests

3 participants