Skip to content

Commit

Permalink
Merge pull request #65 from decentralized-identity/fix/peer2-abbrevia…
Browse files Browse the repository at this point in the history
…tiosn

fix: did:peer:2 abbreviations
  • Loading branch information
Frostyfrog authored Nov 8, 2023
2 parents 3d21f4b + 8225a4d commit 7381290
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
24 changes: 16 additions & 8 deletions src/lib/peer2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
})
)
Expand All @@ -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]
})
)
Expand Down
3 changes: 0 additions & 3 deletions src/pages/profile/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
4 changes: 1 addition & 3 deletions src/pages/profile/jsoneditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {},
})
}
}

0 comments on commit 7381290

Please sign in to comment.