Fixed HUGE bug that was crashing the navigation
This commit is contained in:
parent
262d464734
commit
bec0c9a640
|
@ -48,31 +48,32 @@ export function ScanSet(props: Immutable<Props>): JSX.Element {
|
||||||
languages: languages,
|
languages: languages,
|
||||||
languageExtractor: (item) => item.language?.data?.attributes?.code,
|
languageExtractor: (item) => item.language?.data?.attributes?.code,
|
||||||
transform: (item) => {
|
transform: (item) => {
|
||||||
const newItem = { ...item } as NonNullable<Props["scanSet"][number]>;
|
(item as NonNullable<Props["scanSet"][number]>).pages?.data.sort(
|
||||||
newItem.pages?.data.sort((a, b) => {
|
(a, b) => {
|
||||||
if (a.attributes?.url && b.attributes?.url) {
|
if (a.attributes?.url && b.attributes?.url) {
|
||||||
let aName = getAssetFilename(a.attributes.url);
|
let aName = getAssetFilename(a.attributes.url);
|
||||||
let bName = getAssetFilename(b.attributes.url);
|
let bName = getAssetFilename(b.attributes.url);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the number is a succession of 0s, make the number
|
* If the number is a succession of 0s, make the number
|
||||||
* incrementally smaller than 0 (i.e: 00 becomes -1)
|
* incrementally smaller than 0 (i.e: 00 becomes -1)
|
||||||
*/
|
*/
|
||||||
if (aName.replaceAll("0", "").length === 0) {
|
if (aName.replaceAll("0", "").length === 0) {
|
||||||
aName = (1 - aName.length).toString(10);
|
aName = (1 - aName.length).toString(10);
|
||||||
}
|
}
|
||||||
if (bName.replaceAll("0", "").length === 0) {
|
if (bName.replaceAll("0", "").length === 0) {
|
||||||
bName = (1 - bName.length).toString(10);
|
bName = (1 - bName.length).toString(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInteger(aName) && isInteger(bName)) {
|
if (isInteger(aName) && isInteger(bName)) {
|
||||||
return parseInt(aName, 10) - parseInt(bName, 10);
|
return parseInt(aName, 10) - parseInt(bName, 10);
|
||||||
|
}
|
||||||
|
return a.attributes.url.localeCompare(b.attributes.url);
|
||||||
}
|
}
|
||||||
return a.attributes.url.localeCompare(b.attributes.url);
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
);
|
||||||
});
|
return item;
|
||||||
return newItem;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue