fix group sort to prevent possible loss
This commit is contained in:
parent
e4c0a62fd9
commit
92d456dbf4
1 changed files with 6 additions and 5 deletions
|
@ -76,7 +76,8 @@ export async function servicesResponse() {
|
|||
...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;
|
||||
|
||||
mergedGroupsNames.forEach((groupName) => {
|
||||
|
@ -90,12 +91,12 @@ export async function servicesResponse() {
|
|||
|
||||
if (definedLayouts) {
|
||||
const layoutIndex = definedLayouts.findIndex(layout => layout === mergedGroup.name);
|
||||
if (layoutIndex > -1) mergedGroups[layoutIndex] = mergedGroup;
|
||||
else mergedGroups.push(mergedGroup);
|
||||
if (layoutIndex > -1) sortedGroups[layoutIndex] = mergedGroup;
|
||||
else unsortedGroups.push(mergedGroup);
|
||||
} else {
|
||||
mergedGroups.push(mergedGroup);
|
||||
unsortedGroups.push(mergedGroup);
|
||||
}
|
||||
});
|
||||
|
||||
return mergedGroups.filter(g => g);
|
||||
return [...sortedGroups.filter(g => g), ...unsortedGroups];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue