raain-app 1.6.21 → 1.6.22

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.
@@ -1478,6 +1478,9 @@ class CompareManager {
1478
1478
  }
1479
1479
  }
1480
1480
  async setGaugesInMap() {
1481
+ // Get all gauge IDs linked to this rainNode
1482
+ const rainNodeGaugeIds = this.rainNode.getLinks(GaugeNode.TYPE).map((l) => l.getId());
1483
+ // Fetch gauges from API (may be filtered/limited)
1481
1484
  let gaugesToFilter = await this.profileService.getGauges(this.rainNode?.id, this.rainNode.getCenter());
1482
1485
  gaugesToFilter = gaugesToFilter
1483
1486
  .sort((a, b) => {
@@ -1485,9 +1488,29 @@ class CompareManager {
1485
1488
  b.approxDistanceFrom(this.rainNode.getCenter()));
1486
1489
  })
1487
1490
  .filter((v, index) => index < 200);
1488
- const rainNodeGaugeIds = this.rainNode.getLinks(GaugeNode.TYPE).map((l) => l.getId());
1489
- const visibleGauges = gaugesToFilter.filter((g) => rainNodeGaugeIds.indexOf(g.id) > -1);
1490
- console.log('visibleGauges:', visibleGauges);
1491
+ // Build a map of gauges from API response
1492
+ const gaugesFromApi = new Map();
1493
+ for (const gauge of gaugesToFilter) {
1494
+ gaugesFromApi.set(gauge.id, gauge);
1495
+ }
1496
+ // Fetch missing gauges individually (those linked but not in API response)
1497
+ const missingGaugeIds = rainNodeGaugeIds.filter((id) => !gaugesFromApi.has(id));
1498
+ for (const gaugeId of missingGaugeIds) {
1499
+ try {
1500
+ const gauge = await this.profileService.getGauge(gaugeId);
1501
+ if (gauge) {
1502
+ gaugesFromApi.set(gauge.id, gauge);
1503
+ }
1504
+ }
1505
+ catch (e) {
1506
+ console.warn(`Failed to fetch gauge ${gaugeId}:`, e);
1507
+ }
1508
+ }
1509
+ // Filter to only gauges linked to this rainNode
1510
+ const visibleGauges = rainNodeGaugeIds
1511
+ .map((id) => gaugesFromApi.get(id))
1512
+ .filter((g) => !!g);
1513
+ console.log('visibleGauges:', visibleGauges.length, '/', rainNodeGaugeIds.length);
1491
1514
  const gaugesLatLng = [];
1492
1515
  for (const gauge of visibleGauges) {
1493
1516
  gaugesLatLng.push(new MapLatLng(gauge.latitude, gauge.longitude, undefined, gauge.id, gauge.name));
@@ -2518,6 +2541,8 @@ class RaainDetailsComponent {
2518
2541
  const center = this.rainNode.getCenter();
2519
2542
  this.coordinates = new MapLatLng(center.lat, center.lng);
2520
2543
  this.teamNode = await this.profileService.getTeam(this.rainNode.getLink(TeamNode.TYPE).getId());
2544
+ // Load all gauges linked to the rainNode on map
2545
+ await this.compareManager.setGaugesInMap();
2521
2546
  if (this.periodBegin && this.periodEnd) {
2522
2547
  this.updateRefreshManagerPeriod();
2523
2548
  await this.refreshManager.refresh(false, this.toggleAdmin);