Skip to content

Commit

Permalink
fix: make seedsviewer for long arrays less disgusting
Browse files Browse the repository at this point in the history
  • Loading branch information
zkrising committed Oct 30, 2023
1 parent 8080fa7 commit a6b0744
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 0 additions & 5 deletions client/src/components/tables/cells/ObjCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
5 changes: 5 additions & 0 deletions client/src/util/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a6b0744

Please sign in to comment.