mardi 3 avril 2018

Emberjs computed firing and logic running, but not updating the view

I have a computed property on a controller which I can see is being called when it should (when the route loads and when a button is pressed) however the newsItem record isn't being removed from the view.

  filteredNews: computed('user.read', function () {
    const newsItems = get(this, 'newsItems');
    const userClassifications = get(this, 'user.classification');
    const userRead = get(this, 'user.read');

    newsItems.forEach((newsItem) => {
      userClassifications.forEach(userClassification => {
        if (newsItem.get('classification').includes(userClassification)) {
          newsItem.unloadRecord();
        }
      });

      if (userRead.includes(newsItem)) {
        console.log("read: " + get(newsItem, 'title'));
        newsItem.unloadRecord();
      }
    });

    return newsItems;
  }),

The console.log(...) is being called each time, so I know the logic is correct.

Is there an obvious reason this isn't working as I expect?




Aucun commentaire:

Enregistrer un commentaire