a tool for shared writing and social publishing

fix sorts

+11 -3
+11 -3
app/api/rpc/[command]/getFactsFromHomeLeaflets.ts
··· 46 return a.data.position.x - b.data.position.x; 47 return a.data.position.y - b.data.position.y; 48 }) 49 - : scan.eav(rootEntity, "card/block").sort((a, b) => a.data.position - b.data.position); 50 51 // Map to get type and filter for text/heading 52 let blocks = rawBlocks 53 .map((b) => { 54 let type = scan.eav(b.data.value, "block/type")[0]; 55 - if (!type || (type.data.value !== "text" && type.data.value !== "heading")) return null; 56 return b.data; 57 }) 58 - .filter((b) => b !== null); 59 60 let title = blocks[0]; 61
··· 46 return a.data.position.x - b.data.position.x; 47 return a.data.position.y - b.data.position.y; 48 }) 49 + : scan.eav(rootEntity, "card/block").sort((a, b) => { 50 + if (a.data.position === b.data.position) 51 + return a.id > b.id ? 1 : -1; 52 + return a.data.position > b.data.position ? 1 : -1; 53 + }); 54 55 // Map to get type and filter for text/heading 56 let blocks = rawBlocks 57 .map((b) => { 58 let type = scan.eav(b.data.value, "block/type")[0]; 59 + if ( 60 + !type || 61 + (type.data.value !== "text" && type.data.value !== "heading") 62 + ) 63 + return null; 64 return b.data; 65 }) 66 + .filter((b): b is NonNullable<typeof b> => b !== null); 67 68 let title = blocks[0]; 69