Merge pull request #1899 from automaton82/BUGFIX-marketplace-sorting

Fix for 1881 sorting for Flowise QnA
pull/1888/head
Henry Heng 2024-03-08 14:25:27 +08:00 committed by GitHub
commit 6eab5cf681
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 6 deletions

View File

@ -1371,13 +1371,12 @@ export class App {
} }
templates.push(template) templates.push(template)
}) })
const FlowiseDocsQnA = templates.find((tmp) => tmp.name === 'Flowise Docs QnA') const sortedTemplates = templates.sort((a, b) => a.templateName.localeCompare(b.templateName))
const FlowiseDocsQnAIndex = templates.findIndex((tmp) => tmp.name === 'Flowise Docs QnA') const FlowiseDocsQnAIndex = sortedTemplates.findIndex((tmp) => tmp.templateName === 'Flowise Docs QnA')
if (FlowiseDocsQnA && FlowiseDocsQnAIndex > 0) { if (FlowiseDocsQnAIndex > 0) {
templates.splice(FlowiseDocsQnAIndex, 1) sortedTemplates.unshift(sortedTemplates.splice(FlowiseDocsQnAIndex, 1)[0])
templates.unshift(FlowiseDocsQnA)
} }
return res.json(templates.sort((a, b) => a.templateName.localeCompare(b.templateName))) return res.json(sortedTemplates)
}) })
// ---------------------------------------- // ----------------------------------------