Properly sort bots for dashboard

This commit is contained in:
Matthias 2023-04-22 14:30:31 +02:00
parent a75a6e2882
commit 1653386da9

View File

@ -99,14 +99,17 @@ export class UserService {
public static getAvailableBots(): BotDescriptors { public static getAvailableBots(): BotDescriptors {
const allInfo = UserService.getAllLoginInfos(); const allInfo = UserService.getAllLoginInfos();
const response: BotDescriptors = {}; const response: BotDescriptors = {};
Object.entries(allInfo).forEach(([k, v], idx) => { Object.keys(allInfo)
.sort((a, b) => (allInfo[a].sortId ?? 0) - (allInfo[b].sortId ?? 0))
.forEach((k, idx) => {
response[k] = { response[k] = {
botId: k, botId: k,
botName: v.botName, botName: allInfo[k].botName,
botUrl: v.apiUrl, botUrl: allInfo[k].apiUrl,
sortId: v.sortId ?? idx, sortId: allInfo[k].sortId ?? idx,
}; };
}); });
return response; return response;
} }