@pi-unipi/info-screen 0.1.12 → 0.1.14
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.
- package/package.json +1 -1
- package/tui/info-overlay.ts +29 -16
package/package.json
CHANGED
package/tui/info-overlay.ts
CHANGED
|
@@ -75,6 +75,12 @@ export class InfoOverlay implements Component {
|
|
|
75
75
|
this.unsubscribers.push(
|
|
76
76
|
infoRegistry.subscribeAll((groupId, data) => {
|
|
77
77
|
if (this._destroyed) return;
|
|
78
|
+
// Skip empty data from registration notifications — syncGroups()
|
|
79
|
+
// will trigger the real fetch.
|
|
80
|
+
if (Object.keys(data).length === 0) {
|
|
81
|
+
this.requestRender?.();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
78
84
|
this.groupData.set(groupId, data);
|
|
79
85
|
this.groupLoading.set(groupId, false);
|
|
80
86
|
this.lastGlobalUpdate = Date.now();
|
|
@@ -105,25 +111,32 @@ export class InfoOverlay implements Component {
|
|
|
105
111
|
*/
|
|
106
112
|
private syncGroups(): void {
|
|
107
113
|
const allGroups = infoRegistry.getAllGroups();
|
|
108
|
-
|
|
114
|
+
const hadNewGroups = allGroups.length !== this.groups.length;
|
|
115
|
+
if (hadNewGroups) {
|
|
109
116
|
this.groups = allGroups;
|
|
110
117
|
this.applyOrder();
|
|
118
|
+
}
|
|
111
119
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
// Ensure every group has real (non-empty) data.
|
|
121
|
+
// Registration notifications inject `{}` to trigger re-sync; we must
|
|
122
|
+
// not treat that as fetched data or the stats render as "—".
|
|
123
|
+
for (const group of this.groups) {
|
|
124
|
+
const existing = this.groupData.get(group.id);
|
|
125
|
+
const hasRealData = existing && Object.keys(existing).length > 0;
|
|
126
|
+
if (!hasRealData) {
|
|
127
|
+
const cached = infoRegistry.getCachedData(group.id);
|
|
128
|
+
if (cached && Object.keys(cached).length > 0) {
|
|
129
|
+
this.groupData.set(group.id, cached);
|
|
130
|
+
} else if (!this.groupLoading.get(group.id)) {
|
|
131
|
+
this.groupLoading.set(group.id, true);
|
|
132
|
+
infoRegistry.getGroupData(group.id).then((data) => {
|
|
133
|
+
this.groupData.set(group.id, data);
|
|
134
|
+
this.groupLoading.set(group.id, false);
|
|
135
|
+
this.lastGlobalUpdate = Date.now();
|
|
136
|
+
this.requestRender?.();
|
|
137
|
+
}).catch(() => {
|
|
138
|
+
this.groupLoading.set(group.id, false);
|
|
139
|
+
});
|
|
127
140
|
}
|
|
128
141
|
}
|
|
129
142
|
}
|