-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refresh related entries on changes #1377
base: develop
Are you sure you want to change the base?
Conversation
UI unit Tests12 tests 12 ✅ 0s ⏱️ Results for commit ec39418. ♻️ This comment has been updated with latest results. |
C# Unit Tests104 tests 104 ✅ 5s ⏱️ Results for commit ec39418. ♻️ This comment has been updated with latest results. |
@hahn-kev - Although this is marked as draft, it's fully functional except for the two flaws I mentioned in the description, one of which I'm going to fix tomorrow morning. So this isn't going to change much, and it should be suitable for a review right now. |
Managed to fix the second flaw I mentioned in the description before going home for the evening, so I've updated the description to remove any mention of that second flaw (see edit history if you want to see it). So this PR has come as far as I'm going to be able to take it, unless we decide to make major structural changes to how we store entries so that we can update a selected subset. So now I'm going to take this out of draft status and mark it as ready for review. |
for the issue of not being able to update a single entry, take a look at the That said, considering we have all the pluming for I bring this up because I don't really like bringing back change detection code inside |
@rmunn only I think I like the idea of moving the related entry change detection to the backend. 😬 But, yeah...it's the first time we'll start shooting off events without exactly knowing what context we're in, so it's a new concept. |
yeah I wouldn't trigger the events from inside EntrySync, I would trigger them inside |
Okay, I'll rewrite this to move the "entry changed" notification to the backend. Here's my summary of the design, please speak up if it looks like I'm misunderstanding something:
One thing I don't know yet is how CrdtMiniLcmApi should get hold of an instance of CrdtMiniLcmApiHub to call NotifyEntryUpdated. That's a part of the system whose design I haven't yet studied. I'll look into that and see if I can wrap my head around it myself, or if I need to ask Kevin some questions later. |
No, CrdtMiniLcmApi shouldn't be referencing the hub, because the hub references CrdtMiniLcmApi. Can't have a circular dependency chain. So I need to rethink how the code in CrdtMiniLcmApi is going to fire off the EntryUpdated event. |
Take a look at ChangeEventBus that's where you notify changes from, everything else listens to that for changes. Also remember that Hub you were looking at is in the Web project, meaning it won't work for the Maui version |
Prepares for the 'refreshEntries' event coming soon
Now instead of dispatching multiple `refreshEnrtry` events, when complex forms or comonents change and we need to refresh the related entries, we will dispatch only one event so that a single API call can be made to refresh all relevant entries at once.
2376f9a
to
ec39418
Compare
Rebased on top of most recent |
I've been looking at this code for a while now, and unless I'm completely blind and missing something obvious, these two suggestions aren't both possible. CrdtMiniLcmApi is in the LcmCrdt project, which has minimal dependencies; in particular, it doesn't have ChangeEventBus available to it, because ChangeEventBus is in FwLiteShared. FwLiteShared depends on LcmCrdt, so LcmCrdt can't depend on FwLiteShared, so there's no way to make ChangeEventBus available to CrdtMiniLcmApi in order to use it. Instead, from what I can see, we would need to create a new method in IMiniLcmWriteApi called NotifyEntryChanged (or something), and then both FwLiteWeb and FwLiteMaui would be set up to listen to those EntryChanged notifications and pass them on to the ChangeEventBus. ... Or something along those lines, anyway. I think I want to discuss this before finalizing on a design. So I'm going to put this PR on hold for now and go work on something else. |
yeah I didn't expect it to be easy, I'm not really sure what the best way is to do it right now, I've got a bunch of ideas but none of them are great |
Fixes #1333.
One flaw in this design is that the
$entries
list in viewer/src/ProjectView.svelte comes from aderived
, meaning it's read-only, so the only way to refresh an entry is to refresh the entire list. That's why I've left in aconsole.log('TODO: ...')
line: so that if we decide to merge this as-is despite this flaw, we have an annoying console message nagging at us to find a better solution. I might want to work with Tim on fixing this, since it might involve a major rewrite to how we store entries. (Or we might decide it's not worth fixing, and we're okay with refreshing the entire entries list every time an entry's list of components or complex forms is changed).Other than that, this works as desired: when you add a complex form or a component, the related entry is refreshed. When you delete a complex form or a component, the related entry is also refreshed.