wlonk / fvtt-r-maps

Add relationship maps to your Foundry VTT game.
MIT License
3 stars 2 forks source link

Delete Relation when deleting token #16

Open brunocalado opened 1 year ago

brunocalado commented 1 year ago

Hi.

What do you think about delete relations when deleting a token?

https://github.com/wlonk/fvtt-r-maps/assets/4999783/a4679980-3eea-468a-9edd-3bbc4bb8e36b

Tks

wlonk commented 1 year ago

Thank you so much for the feedback (here, and with the other issues you raised)!

I’ve begun working on a fix for this one, but there are some weird edge cases that are remaining tricky. I hope I can resolve it this weekend.

wlonk commented 1 year ago

Well, I've gotten it to the point where it works, but there's an error thrown for the client that originated the deletion, for every outbound edge from the token. There's something happening where a socket event comes in late that tells the client to do… what it's just done, but the relevant token is already gone and so it can't find it to clean up data.

At this point, that's just a wart I'm going to have to live with for it, because I don't have the capacity to clean it up.

brunocalado commented 1 year ago

Thank you for fix this!

About the error, I have some suggestions:

wlonk commented 1 year ago

Thanks; I'm active in that Discord already.

I don't see how to bring socketlib to bear on this, yet. I'll keep pondering this for a bit. I think that socketlib is most clearly applicable to situations where you need an action to run consistently, once, or with elevated permissions, once, and then have the results spread out; in this case, it has to do with the originator receiving something like a bounced socket event. As I say, I'll contemplate it.

wlonk commented 1 year ago

I just tried the re-architecture where everything goes through socketlib to happen via one GM user, and no good; the error is still a loopback-shaped one (in broad terms). I think if this feature's going to be present, it'll take someone with a deeper knowledge of Foundry internals and patterns than I have to make it error-free.