Skip to content

Commit

Permalink
fix: if flat array of number or string type (or empty), display array…
Browse files Browse the repository at this point in the history
… as key value
  • Loading branch information
donnyquixotic committed Nov 12, 2023
1 parent c5e83d2 commit c9cfb92
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/transaction/PrettyPayload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ export default defineComponent({
'payload__indent': depth.value > 0,
}));
function isArrayOfStringsOrNumbers(value: unknown): value is string[] | number[] {
return Array.isArray(value) && value.every(item => typeof item === 'string' || typeof item === 'number');
}
return {
type,
list,
classObject,
isAccount,
isArrayOfStringsOrNumbers,
};
},
Expand All @@ -56,7 +61,7 @@ export default defineComponent({
>
<template v-if="Array.isArray(payload[key])">
<span class="text-bold">{{ key }}:</span>
<span v-if="payload[key].length === 0">{{` [ ]`}}</span>
<span v-if="isArrayOfStringsOrNumbers(payload[key])">{{[...payload[key]]}}</span>
<ul v-else class="payload__list">
<li
v-for="(item, index) in payload[key]"
Expand Down

0 comments on commit c9cfb92

Please sign in to comment.