CodeforAustralia / heritage-near-me

🔎 Heritage Near Me web app prototype
23 stars 6 forks source link

After page load, fav/pass on first item needed twice #61

Closed techieshark closed 8 years ago

techieshark commented 8 years ago

When you first load the web app, you can click fav or pass buttons but they appear to have no effect the first time. You have to hit one of them a second time to see a new story.

techieshark commented 8 years ago

Fixed by commit 8bea014b86b2dbee87629141369d28209729d10a, specifically this change in App.elm:updateDiscoverableItems():

updateDiscoverableItems discovery items =
    if discovery == initialDiscovery then
        { discovery |
             item = Remote.Data.map List.head items
 -         , items = Remote.Data.get items |> Maybe.withDefault []
 +         , items = Remote.Data.get items |> tailOrEmptyList 
        }
    else
        discovery

That is, when discovery == initialDiscovery, item should be set to the head of the list, and items should get the tail. The commit also adds the tailOrEmptyList function, used above.