mozilla-mobile / prox

[INACTIVE] A search and discovery app for the "here & now". We're experimenting with ideas on mobile that can better surface content from the open web.
https://wiki.mozilla.org/New_Mobile_Experience
Mozilla Public License 2.0
22 stars 12 forks source link

"Didn't find places" appears before rendering places #519

Closed mcomella closed 7 years ago

mcomella commented 7 years ago

This gives the false impression the app didn't load places when we're, I think, actually just waiting for the UI to render.

This is especially visible on device with Mock Location for "Chicago Cultural Center".

mcomella commented 7 years ago

The problem is the places in the PlacesProvider is updated after we check if the number of places are zero, to determine if we should show the "Try again" text.

In PlacesController.swift:

    private func didFinishFetchingPlaces(places: [Place], forLocation location: CLLocation) {
        ...
        eventsProvider.getEventsWithPlaces(forLocation: location, usingPlacesDatabase: self.database) { placesWithEvents in
            ...
            self.displayPlaces(places: Array(union), forLocation: location) // <- waits on promise to set places
            DispatchQueue.main.async {
                ...
                self.delegate?.placesProviderDidFinishFetchingPlaces(self) // <- checks if places.count == 0
            }
        }
    }

The Delegate is located in PlaceCarouselViewController.

The promise waited on in self.displayPlaces is waiting for the places to get their travel times and for the places to be correctly sorted, before setting them.

fwiw, I think this is a regression from 6228e378d406852441554f738313dcb194090561.

mcomella commented 7 years ago

WIP in https://github.com/mcomella/prox/tree/i519-dont-find, Brian is going to take this over.