mercredi 1 septembre 2021

Data loading issues in Ember 2.17

In ember 2.17 I have the following model :

import DS from 'ember-data';

export default DS.Model.extend({
  sharing_start:DS.attr('date'),
  owner: DS.belongsTo('shop'),
  deleted:DS.attr('boolean'),
  shared:DS.attr('boolean'),
  free_price:DS.attr('boolean'),
  product:DS.belongsTo('product'),
  from_share_products:DS.hasMany('product',{inverse:"shared_from"})
});

I use it in the following model :

import Route from '@ember/routing/route';
import { assign } from '@ember/polyfills';

export default Route.extend({
  model(params){
    return this.get('store').query('shared-product',assign(params,{include:'owner,product'}))
  },
  queryParams: {
    page: {refreshModel: true},
    size: {refreshModel: true},
    scope: {refreshModel: true}
  }
});

The data is rendered in a table, here is the line component used in a each loop :

<td> SP ID :  PRODUCT ID : </td>
<td></td>
<td></td>

If I reload the page on this route It render one line with the product name and ID and the following error :

 "Assertion Failed: You modified \"sp.product\" twice on <marketadmin@model:shared-porduct::ember988:11> in a single render. It was rendered in \"component:shared-products/catalog-line\" and modified in \"component:shared-products/catalog-line\". This was unreliable and slow in Ember 1.x and is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details."

If I go to this route from another route in the app, the array is displayed without console error except that, the first line has no product name or ID, as well as the 8th line (both in FF and chrome), and the following ones have a product name and ID.

The weird part is that in both the refresh or naviguating case, the data is retrieved in one API call that return the data with products as relationship.

I am not sure where to go to diagnose or solve that problem.




Aucun commentaire:

Enregistrer un commentaire