fix: wrap model data in named objects and fix renderGuardMulti empty check

This commit is contained in:
2026-06-23 00:08:40 +00:00
parent b673e87c9b
commit 75aa6fb885
5 changed files with 13 additions and 7 deletions
+8 -2
View File
@@ -80,7 +80,7 @@ export function renderGuard(state, title, subtitle, data) {
*/
export function renderGuardMulti(title, subtitle, ...models) {
const combined = collectLoadingModels(...models);
return renderGuard(combined, title, subtitle);
return renderGuard(combined, title, subtitle, models.map(m => m.data));
}
/**
@@ -90,7 +90,13 @@ export function renderGuardMulti(title, subtitle, ...models) {
*/
function isEmpty(data) {
if (data === null || data === undefined || data === '') return true;
if (Array.isArray(data)) return data.length === 0;
if (Array.isArray(data)) {
// Array of model data values (from renderGuardMulti) — empty only if all models have no data
if (data.length === 0) return true;
return data.every(d => d === null || d === undefined ||
(Array.isArray(d) && d.length === 0) ||
(typeof d === 'object' && Object.keys(d).length === 0));
}
if (typeof data === 'object') return Object.keys(data).length === 0;
if (typeof data === 'number') return false;
return !data;