@hestia-earth/ui-components 0.33.2 → 0.33.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5684,6 +5684,7 @@ const sortNodes = (values) => values?.length
5684
5684
  ? orderBy(values.filter(Boolean), ['original.aggregated', 'original.site.@id', 'original.cycle.@id', 'original.@id'], ['asc', 'asc', 'asc', 'asc'])
5685
5685
  : [];
5686
5686
  const isAggregated = (id = '') => !!id?.match(/^[a-zA-Z]+[-][a-zA-Z]+[-][\d]{4,}[-][\d]{4,}/g);
5687
+ const nodeRequestId = (node, params = {}) => [node['@id'], params?.version].filter(Boolean).join('#');
5687
5688
  const pickHeaderKeys = ['stage', 'maxstage', 'error', 'last-modified'];
5688
5689
  const mergeDataWithHeaders = (data, headers) => ({
5689
5690
  ...data,
@@ -5696,11 +5697,12 @@ class HeNodeStoreService {
5696
5697
  this._nodes = {};
5697
5698
  this._nodes$ = new ReplaySubject(1);
5698
5699
  }
5699
- findNodeIndex(node) {
5700
+ findNodeIndex(node, params = {}) {
5700
5701
  const nodes = this._nodes?.[node['@type']] || [];
5701
- return nodes.findIndex(n => n.type === node['@type'] && n.id === node['@id']);
5702
+ return nodes.findIndex(n => n.type === node['@type'] && n.id === nodeRequestId(node, params));
5702
5703
  }
5703
5704
  loadNode(node, params = {}, dataTransform = data => data) {
5705
+ const id = nodeRequestId(node, params);
5704
5706
  const aggregated = 'aggregated' in node ? node.aggregated : isAggregated(node['@id']);
5705
5707
  const dataStates = nodeTypeDataStates(node['@type'], aggregated);
5706
5708
  const index = this._nodesLoadRequests[node['@type']].length;
@@ -5713,11 +5715,11 @@ class HeNodeStoreService {
5713
5715
  ]))), map(values => ({
5714
5716
  index,
5715
5717
  type: node['@type'],
5716
- id: node['@id'],
5718
+ id,
5717
5719
  ...values
5718
5720
  })));
5719
5721
  this._nodesLoadRequests[node['@type']].push({
5720
- id: node['@id'],
5722
+ id,
5721
5723
  request
5722
5724
  });
5723
5725
  request.subscribe(data => {
@@ -5738,7 +5740,7 @@ class HeNodeStoreService {
5738
5740
  addNode(node, params = {}, dataTransform) {
5739
5741
  this._nodesLoadRequests[node['@type']] = this._nodesLoadRequests[node['@type']] || [];
5740
5742
  this._nodes[node['@type']] = this._nodes[node['@type']] || [];
5741
- const existingRequest = this._nodesLoadRequests[node['@type']].find(({ id }) => id === node['@id']);
5743
+ const existingRequest = this._nodesLoadRequests[node['@type']].find(({ id }) => id === nodeRequestId(node, params));
5742
5744
  return existingRequest ? existingRequest.request : this.loadNode(node, params, dataTransform);
5743
5745
  }
5744
5746
  removeNodeByIndex(nodeType, index) {
@@ -5750,8 +5752,8 @@ class HeNodeStoreService {
5750
5752
  this._nodes[nodeType] = nodes;
5751
5753
  this._nodes$.next(this._nodes);
5752
5754
  }
5753
- removeNode(node) {
5754
- const index = this.findNodeIndex(node);
5755
+ removeNode(node, params = {}) {
5756
+ const index = this.findNodeIndex(node, params);
5755
5757
  return index >= 0 ? this.removeNodeByIndex(node['@type'], index) : null;
5756
5758
  }
5757
5759
  clearNodes() {