googlecodelabs / your-first-pwapp

Code associated with Your First Progressive Web App codelab
https://g.co/codelabs/pwa
Apache License 2.0
638 stars 555 forks source link

update app to use yahoo weather api #52

Closed kaycebasques closed 8 years ago

kaycebasques commented 8 years ago

@marcacohen @petele please review my updates to use the Yahoo Weather API.

So far I've only made the updates in the final directory. Once we're all on the same page I'll update the other directories.

kaycebasques commented 8 years ago

Adding comments to the commits now...

petele commented 8 years ago

To fix the app.hasRequestPending issues:

  1. In initialWeatherForecast add created: '2016-07-22T01:00:00Z', to the object (line ~12)
  2. Remove hasRequestPending from the app object, (line ~46)
  3. Add var dataLastUpdated = new Date(data.created); to the top of app.updateForecastCard
  4. Add the following below var card = app.visibleCards[data.key]
    // Verifies the data provide is newer than what's already visible
    // on the card, if it's not bail, if it is, continue and update the
    // time saved in the card
    var cardLastUpdatedElem = card.querySelector('.card-last-updated');
    var cardLastUpdated = cardLastUpdatedElem.textContent;
    if (cardLastUpdated) {
      cardLastUpdated = new Date(cardLastUpdated);
      // Bail if the card has more recent data then the data
      if (dataLastUpdated.getTime() < cardLastUpdated.getTime()) {
        return;
      }
    }
    cardLastUpdatedElem.textContent = data.created;
  1. Add results.create = json.query.created; to the caches.match and XHR in app.getForecast
  2. In index.html, add <div class="card-last-updated" hidden></div> to the card template.

I'll send you the JS file with my updates.

petele commented 8 years ago

LGTM! Thanks @kaycebasques!!

kaycebasques commented 8 years ago

cool thanks @petele I'll clean up the code and then merge

kaycebasques commented 8 years ago

I also need to update the rest of the directories...