@visns-studio/visns-components 5.26.3 → 5.26.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.
package/package.json
CHANGED
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
95
95
|
},
|
|
96
96
|
"name": "@visns-studio/visns-components",
|
|
97
|
-
"version": "5.26.
|
|
97
|
+
"version": "5.26.4",
|
|
98
98
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
99
99
|
"main": "src/index.js",
|
|
100
100
|
"files": [
|
|
@@ -545,13 +545,35 @@ const showModal = (title, content) => {
|
|
|
545
545
|
};
|
|
546
546
|
|
|
547
547
|
|
|
548
|
+
// Duplicate widget ids (seen in saved user layouts) collide in the data map,
|
|
549
|
+
// double-fetch, and can crash the renderer — keep the first occurrence only.
|
|
550
|
+
const dedupeWidgets = (dashSetting) => {
|
|
551
|
+
if (!dashSetting?.widgets) return dashSetting;
|
|
552
|
+
const seen = new Set();
|
|
553
|
+
const widgets = dashSetting.widgets.filter((widget) => {
|
|
554
|
+
if (seen.has(widget.id)) {
|
|
555
|
+
console.warn(
|
|
556
|
+
`GenericDashboard: dropping duplicate widget id "${widget.id}"`
|
|
557
|
+
);
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
seen.add(widget.id);
|
|
561
|
+
return true;
|
|
562
|
+
});
|
|
563
|
+
return widgets.length === dashSetting.widgets.length
|
|
564
|
+
? dashSetting
|
|
565
|
+
: { ...dashSetting, widgets };
|
|
566
|
+
};
|
|
567
|
+
|
|
548
568
|
function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
|
|
549
569
|
const swapy = useRef(null);
|
|
550
570
|
const container = useRef(null);
|
|
551
571
|
const navigate = useNavigate();
|
|
552
572
|
const initialLoadRef = useRef(true); // Ref to track initial load
|
|
553
|
-
const [dashboardSetting, setDashboardSetting] = useState(
|
|
554
|
-
|
|
573
|
+
const [dashboardSetting, setDashboardSetting] = useState(() =>
|
|
574
|
+
dedupeWidgets(
|
|
575
|
+
dynamicDashboard ? userProfile.dashboard_setting || setting : setting
|
|
576
|
+
)
|
|
555
577
|
);
|
|
556
578
|
const [data, setData] = useState({});
|
|
557
579
|
const [dropdowns, setDropdowns] = useState({});
|
|
@@ -1122,11 +1144,10 @@ function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
|
|
|
1122
1144
|
}`}
|
|
1123
1145
|
>
|
|
1124
1146
|
<span>
|
|
1125
|
-
{
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
: widgetData}
|
|
1147
|
+
{typeof widgetData === 'number' ||
|
|
1148
|
+
typeof widgetData === 'string'
|
|
1149
|
+
? widgetData
|
|
1150
|
+
: parse(` `)}
|
|
1130
1151
|
</span>
|
|
1131
1152
|
</div>
|
|
1132
1153
|
{widget.button && (
|