From 1d9ba83c9a4473ef5128e72a1cca91b0e9202070 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 7 Nov 2023 18:59:50 -0500 Subject: [PATCH 1/2] fix: did:peer:2 abbreviations not working quite right Signed-off-by: Daniel Bluhm --- src/lib/peer2.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/lib/peer2.ts b/src/lib/peer2.ts index 2cf15e9..23a677a 100644 --- a/src/lib/peer2.ts +++ b/src/lib/peer2.ts @@ -114,10 +114,14 @@ export default class DIDPeer { const expanded = Object.fromEntries( Object.entries(input).map(([key, value]) => { const expandedKey = reverseCommonStringAbbreviations[key] || key - const expandedValue = - typeof value === "string" - ? reverseCommonStringAbbreviations[value] || value - : value + let expandedValue = value; + if (typeof value == "string") { + expandedValue = reverseCommonStringAbbreviations[value] || value + } else if (Array.isArray(value)) { + expandedValue = value.map((item: any) => reverseCommonStringAbbreviations[item] || item) + } else if (typeof value == "object") { + expandedValue = DIDPeer.expandCommonStringAbbreviations(expandedValue) + } return [expandedKey, expandedValue] }) ) @@ -128,10 +132,14 @@ export default class DIDPeer { const abbreviated = Object.fromEntries( Object.entries(input).map(([key, value]) => { const abbreviatedKey = commonStringAbbreviations[key] || key - const abbreviatedValue = - typeof value === "string" - ? commonStringAbbreviations[value] || value - : value + let abbreviatedValue = value + if (typeof value == "string") { + abbreviatedValue = commonStringAbbreviations[value] || value + } else if (Array.isArray(value)) { + abbreviatedValue = value.map((item: any) => commonStringAbbreviations[item] || item) + } else if (typeof value == "object") { + abbreviatedValue = DIDPeer.abbreviateCommonStrings(abbreviatedValue) + } return [abbreviatedKey, abbreviatedValue] }) ) From 8225a4d9f4075a7b408fb6a0d11f0e96a505913f Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 7 Nov 2023 19:02:16 -0500 Subject: [PATCH 2/2] chore: remove logs Signed-off-by: Daniel Bluhm --- src/pages/profile/compose.ts | 3 --- src/pages/profile/jsoneditor.ts | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/pages/profile/compose.ts b/src/pages/profile/compose.ts index 90839e8..e8dffc4 100644 --- a/src/pages/profile/compose.ts +++ b/src/pages/profile/compose.ts @@ -25,18 +25,15 @@ export default class ComposeComponent implements m.ClassComponent { } oncreate(vnode: m.VnodeDOM<{}, this>) { - console.log("LOGGING SAMPLES", SAMPLES["Trust Ping"]) this.content = JSON.stringify(SAMPLES["Trust Ping"], null, 2) } onSampleSelected(e: Event) { - console.log((e.target as HTMLSelectElement).value) this.content = JSON.stringify( SAMPLES[(e.target as HTMLSelectElement).value], null, 2 ) - console.log(this.content) m.redraw() } diff --git a/src/pages/profile/jsoneditor.ts b/src/pages/profile/jsoneditor.ts index c41bb3f..5944eb7 100644 --- a/src/pages/profile/jsoneditor.ts +++ b/src/pages/profile/jsoneditor.ts @@ -36,9 +36,7 @@ export default class JSONEditor return m("lit-code", { language: "json", linenumbers: true, - onupdate: (e: any) => { - console.log("onupdate", e) - }, + onupdate: (e: any) => {}, }) } }