fix: make seedsviewer for long arrays less disgusting

This commit is contained in:
zkldi
2023-10-30 15:49:15 +00:00
parent 8080fa711e
commit a6b0744378
2 changed files with 5 additions and 5 deletions
@@ -4,13 +4,8 @@ import React from "react";
export default function ObjCell({ data }: { data: unknown }) {
return (
<td className="text-start">
{/* this kinda sucks. have we got a better way to do this? */}
{FlattenValue(data)
.filter((e) => e.value !== null)
.filter(
// hack to hide some annoying itg properties
(e) => e.keychain[0] !== "npsPerMeasure" && e.keychain[0] !== "notesPerMeasure"
)
.map((e) => (
<>
<code>{StringifyKeyChain(e.keychain)}</code>: {JSON.stringify(e.value)}
+5
View File
@@ -384,6 +384,11 @@ export function FlattenValue(
keychain: string[] = []
): Array<{ keychain: string[]; value: unknown }> {
if (Array.isArray(value)) {
// probably not a tuple, don't make this thing super long.
if (value.length > 5) {
return [{ keychain, value: value.join(", ") }];
}
return value.flatMap((e, i) => FlattenValue(e, [...keychain, i.toString()]));
} else if (typeof value === "object" && value !== null) {
return FlattenRecord(value as Record<string, unknown>, keychain);