Minor changes based on feedback.

This commit is contained in:
muzam1l
2022-08-17 12:11:36 +05:30
parent dbbbfdb2f0
commit 1fab69ef9b

View File

@@ -47,8 +47,6 @@ export const fetchFiles = async (gistId: string) => {
content: res.data.files?.[filename]?.content || "",
}));
// Sort files so that the source files are first
// In case of other files leave the order as it its
files.sort((a, b) => {
const aBasename = a.name.split('.')?.[0];
const aExt = a.name.split('.').pop() || '';
@@ -62,10 +60,10 @@ export const fetchFiles = async (gistId: string) => {
h: -1
}
if (extPriority[aExt] || extPriority[bExt]) {
// Sort based on extention priorities
const comp = (extPriority[bExt] || 0) - (extPriority[aExt] || 0)
if (comp !== 0) return comp
}
// Otherwise fallback to alphabetical sorting
return aBasename.localeCompare(bBasename)
})