ios
ios copied to clipboard
iPad only: Change in user location does not immediately update representative list
In the views for the iPad app, the user can set a location with a pop-up style window while viewing an issue. This is convenient.
If the user changes location in the "Set your location" window, ideally the list of representatives shown at the bottom of the issue view would update immediately to reflect the new location. In the current version of the iPad app, the representatives in the "Call your representatives" list reflect the previous location until a new issue is tapped.
I can take this one.
Posting this mostly for my own future self: I know why this is happening, but I haven't decided yet how I would want to fix it. The IssueDetailViewController
is setting itself as the delegate for the EditLocationViewController
when it is launched via a segue on the IssueDetailViewController
but that only happens when the device is a particular size. Subscribing to notifications might be better, but will have to be reconciled with the delegate code so the two aren't stepping on each other.
@erikkrietsch Sounds like we need to set the delegate in the other case maybe when the popup is launched?
If that seems too hard to do properly, I'd be game for listening for a notification across the app for this. Will make it easier going forward to adding setting location from other places in the future.
There actually already is a notification for when a user changes their location, so I was going to just tap into that. I've got the fix just about ready, I just need to extract out a common function for the two scenarios.
It's actually a little more complicated than I initially thought, and my original assessment wasn't quite right. If the user hasn't yet set their location, then they can do that via a special table cell in the IssueDetailViewController. That's when the IDVC sets itself as the delegate for the location controller. This can happen on any size device. The iPad can also set the location through a specially added button to the header in the navigation controller, but the IDVC has no direct interaction with it. Subscribing to the notification works well in this case, but in the prior scenario, we double dip and wind up hitting the network twice—once for the delegate call and once for the notification.
I'm still working on it. I think what I'm going to do is separate out the work that was happening on the delegate call and move the networking and UI refresh into the notification handler.