Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

Conversation

@norybiak
Copy link
Contributor

This fix allows transform subscriptions to pass to the app when actor is an attachment.

Issue #739

This PR is similar to #740 but for the correct branch (red).

Copy link
Contributor

@tombuMS tombuMS left a comment

Choose a reason for hiding this comment

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

Some protection regarding potentially undefined syncActor needs to be added. See comments

const syncActor = session.actorSet.get(message.payload.actorId);
if (syncActor && ((client.authoritative && !syncActor.grabbedBy)
|| (syncActor.grabbedBy === client.id))) {
const attachment = syncActor.initialization.message.payload.actor.attachment;
Copy link
Contributor

Choose a reason for hiding this comment

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

It is possible for syncActor to be undefined here which will cause this to throw an exception. Getting the attachment will need to be moved into the if block below it where syncActor will already be tested for undefined. Alternatively you can do optional chaining on the syncActor like:

const attachment = syncActor?.initialization.message.payload.actor.attachment;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. See latest commit.

message: Message<Payloads.ActorUpdate>
) => {
const syncActor = session.actorSet.get(message.payload.actor.id);
const attachment = syncActor.initialization.message.payload.actor.attachment;
Copy link
Contributor

Choose a reason for hiding this comment

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

See same comment above about syncActyor being undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. See latest commit.

@tombuMS tombuMS merged commit 59c975a into microsoft:red Mar 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants