specklesystems / speckle-blender

https://speckle.systems/tag/blender/
Apache License 2.0
52 stars 9 forks source link

Recover branch selection #196

Closed overengineer closed 5 months ago

overengineer commented 6 months ago

When user refreshes the stream, branch selection resets. As a workaround, I stored selected branch in a class member. Then used that value to get active branch. Better solutions are possible of course.

JR-Morgan commented 6 months ago

I haven't had a deep look at your PR just yet @overengineer I'll make this a priority for next week.

Not sure if it relates to this PR. But I just thought I'd share my thoughts regardless.

In other connectors, we have tried to use the account id / stream id / branch id / commit id as the key for the selection instead of a sequential index.

I haven't investigated how possible this is, but we do look to be setting a Key here with str(i) (and similar elsewhere for accounts, commits, etc.)

This concept could also fix #98

overengineer commented 5 months ago

Hi @JR-Morgan I updated my changes. Now I am matching objects by IDs. Also I am checking if user and stream changed before restoring branch and commit selections.

I used hooks to listen user actions. because I could not find a way to access selection states. BTW, I had to use those class members because all scene objects were resetting on update user.

I would prefer putting the code for selection states to a seperate file. But I hesitated because I do not know your folder structure conventions. If you have a suggestion, I can refactor.

overengineer commented 5 months ago

@JR-Morgan I made some changes according to your comments.

Also I converted class members to object members and instantiated the class. This way is less ugly I think.

JR-Morgan commented 5 months ago

Thanks @overengineer for your patience, I've made a couple tiny tweaks to the type hinting, and merged.

Thanks for you contribution!

JR-Morgan commented 5 months ago

Change is now in 2.20.0-wip