fix group sort to prevent possible loss

pull/543/head
Michael Shamoon 2 years ago
parent e4c0a62fd9
commit 92d456dbf4

@ -76,7 +76,8 @@ export async function servicesResponse() {
...new Set([discoveredServices.map((group) => group.name), configuredServices.map((group) => group.name)].flat()), ...new Set([discoveredServices.map((group) => group.name), configuredServices.map((group) => group.name)].flat()),
]; ];
const mergedGroups = []; const sortedGroups = [];
const unsortedGroups = [];
const definedLayouts = initialSettings.layout ? Object.keys(initialSettings.layout) : null; const definedLayouts = initialSettings.layout ? Object.keys(initialSettings.layout) : null;
mergedGroupsNames.forEach((groupName) => { mergedGroupsNames.forEach((groupName) => {
@ -90,12 +91,12 @@ export async function servicesResponse() {
if (definedLayouts) { if (definedLayouts) {
const layoutIndex = definedLayouts.findIndex(layout => layout === mergedGroup.name); const layoutIndex = definedLayouts.findIndex(layout => layout === mergedGroup.name);
if (layoutIndex > -1) mergedGroups[layoutIndex] = mergedGroup; if (layoutIndex > -1) sortedGroups[layoutIndex] = mergedGroup;
else mergedGroups.push(mergedGroup); else unsortedGroups.push(mergedGroup);
} else { } else {
mergedGroups.push(mergedGroup); unsortedGroups.push(mergedGroup);
} }
}); });
return mergedGroups.filter(g => g); return [...sortedGroups.filter(g => g), ...unsortedGroups];
} }

Loading…
Cancel
Save