nus-cs2103-AY1718S1 / forum

Discussion Forum
5 stars 0 forks source link

Handling Events in Model Manager #206

Closed tshradheya closed 6 years ago

tshradheya commented 6 years ago

I finally figured out what the reason behind one of my bug is.

So the problem is I am trying to handleEvents in ModelManager and because of which the syncronised methods aren't executing properly as the PersonListPanel doesn't get updated.

Can I know where should I handle events which as raised in UI section and require to call ModelManager functions?

TL DR; I want to handle events in ModelManager by raising them in PersonListPanel but it causes the synchronized functions(like addPerson, deletePerson) to not work properly as the PersonList doesn't get refreshed.

Thanks

damithc commented 6 years ago

An example of an event causing this issue?

tshradheya commented 6 years ago

I call an event from UI(PersonListPanel), which gets raised when the selection of the person list is changed. I want to update one of the fields of the selected person, which is done in ModelManager( handled in Model and updatePerson is called through it)

damithc commented 6 years ago

@Zhiyuan-Amos any advice?

tshradheya commented 6 years ago

Some more leads:

If I raise any event from UI(PersonListPanel), [ in my case event is raised when person is selected ] handle it in ModelManager by updating details of a person] and then carry out any command which calls a synchronized[ in this case delete ] on the selected index then later on whenever I try to use delete again, the command only deletes from address book but does not reflect the changes in list of PersonListPanel

damithc commented 6 years ago

If I raise any event from UI(PersonListPanel), [ in my case event is raised when person is selected ] handle it in ModelManager by updating details of a person] and then carry out any command which calls a synchronized[ in this case delete ] on the selected index then later on whenever I try to use delete again, the command only deletes from address book but does not reflect the changes in list of PersonListPanel

Is this a problem even in the original AB4?

tshradheya commented 6 years ago

No it is not. I am assuming the problem is with handling events in ModelManager. In original AB4 no events were handled in ModelManager

tshradheya commented 6 years ago

Sorry for all the confusion caused, I myself am very confused where exactly is the problem.

To phrase it all again :

If I select a person ( it calls an event from UI which is handled in ModelManager which updates the person) and then if I delete the person selected, then later on if I try to delete someone else, even though the person is deleted in address book, it is not reflected in the list of PersonListPanel.

It only happens when the person selected is deleted.

Note: If I remove the raising of event, everything works fine

May I know how is selection in the list changed when person selected is deleted? ( Can I somehow clear selection when delete is executed)

tshradheya commented 6 years ago

The issue is resolved. Thanks to @RonakLakhotia for helping me figure out the bug and sit 5 hours to help find the exact problem and find solution for it.

Closing this issue as it is resolved.

P.S It was nothing wrong with handing Events in ModelManager

damithc commented 6 years ago

Great. Kudos to @RonakLakhotia 👍