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

Child list doesn't display after selecting child photo #332

Open
rockfordlhotka opened this issue Dec 16, 2018 · 6 comments
Open

Child list doesn't display after selecting child photo #332

rockfordlhotka opened this issue Dec 16, 2018 · 6 comments
Labels

Comments

@rockfordlhotka
Copy link
Collaborator

After adding a photo to a child that is not the first child in the child list, back out to the child list and it is blank (on iOS at least).

Exit to main menu, go back to child list and the children are listed.

@brunck
Copy link
Collaborator

brunck commented Feb 23, 2019

It seems that after doing this for any child that isn't the first, when navigating back it may lose just the 2nd one in the list, which may or may not be the one selected and had the photo added to.

@brunck
Copy link
Collaborator

brunck commented Feb 23, 2019

The problem seems to appear after this line.

For a Childprofilelist of n items in Model, after this line Model has n-1 items and is missing the 2nd item that was in that list.

@brunck
Copy link
Collaborator

brunck commented Aug 3, 2019

This is still happening on both iOS and Android.

@left-on-red
Copy link
Contributor

left-on-red commented Aug 4, 2019

same visual bug reproducible by deleting a child list item. child 2 gets visually removed but fixes itself by exiting to main menu and returning to children list. not strictly an issue with images

@brunck
Copy link
Collaborator

brunck commented Aug 14, 2019

I think we'd see more than just the 2nd in the list go missing if the Child list was longer when we take an action that repros this (adding a photo to one of the Child entities, etc.)

@brunck
Copy link
Collaborator

brunck commented Aug 15, 2019

What seems to be happening here is a bit complex. It's reproduced in the unit test as part of PR #357 .
It only shows up if you have 3 or more Child entities in the Family. Let's say we have 4 for example.
We see this easily if we add an entity like a Photo to one of the Child entities. We're seeing this in other situations but we'll use a Photo add for this example. All this is the same as what the unit test does. I don't know at the moment why this isn't reproduced when an entity isn't added to one of the Child entities in the list, so we make sure to do that.

After adding the photo and navigating back to the previous page, ChildProfileList.SaveFamilyAsync() is invoked. This does a couple of key things in this case: ISavable.SaveAsync() and shortly after, GraphMerger.MergeBusinessListGraph() are invoked.

Model has 4 Child entities with the IBusinessObject.Identity (implemented in BusinessBase in this case) with values of 1, 2, 3 and 4. Those existed before the SaveAsync() call. saved now contains 4 nearly identical Child entities with identities of 5, 6, 7 and 8. I don't know at this point whether this is proper/expected or not.

MergeBusinessListGraph() then gets invoked with Model as "target" and saved as "source." In this method, the key part is a loop over each item in source, comparing each item with all the items in target. If the source item's identity does not match any of the items in target, target has that source item added to it. The target list now has 5 Child entities with identities of 1, 2, 3, 4 and 5.
Something important happens as part of this Add operation though: The identity of the last item is incremented to 6. So once you get to the next iteration of the loop, the entities in the list have identities of 1, 2, 3, 4, and 6.
The loop continues to the next item in source which has an identity of 6. The following check sees that target does have an item with an identity of 6, so the Add operation is skipped and we move to the next iteration in the loop.

Ultimately (without going into more detail about the rest of the graph merge method) we end up with a Model that has only 3 Child entities, with the 2nd one left out. I think it may have something to do with one of these Child entities having a Parent but I'm not sure at the moment.

rockfordlhotka added a commit that referenced this issue Feb 3, 2020
Alter unit test to reproduce merge graph problem seen in issue #332
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants