Skip to content

Commit

Permalink
Sort disputes by date (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
glmaljkovich authored Aug 17, 2021
1 parent 574d375 commit b9cad3f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,23 @@ export const listCommand = {
networkSettings,
false,
)
data[chalk.whiteBright.underline(dispute.id)] = disputeEntry
data[dispute.id] = disputeEntry
}),
)
spinner.stop()

// sort disputes
const findDisputeById = (id: string) => disputes.find(d => d.id === id)
const orderedDisputeIds = Object.keys(data).sort((d1, d2) =>
findDisputeById(d1).createdAt > findDisputeById(d2).createdAt ? 1 : -1,
)
const sortedData = {}
orderedDisputeIds.forEach(disputeId => {
sortedData[chalk.whiteBright.underline(disputeId)] = data[disputeId]
})
// Display disputes
log.info('Disputes')
log.info('--------')
log.info(treeify.asTree(data, true, true))
log.info(treeify.asTree(sortedData, true, true))
},
}

0 comments on commit b9cad3f

Please # to comment.