Skip to content

Commit

Permalink
add sorting to all
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Jan 28, 2022
1 parent 338777b commit ef99523
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,11 @@ class ArweaveClient {
}

// safe to get first item as we specify specific tags in the query building stage
const txIds = versions.length === 0 ?
resultEdges.map(e => e.node.id) :
resultEdges.sort((a, b) => {
// we reverse sort edges if version is not defined to get latest version
const getVersion = (edge) => edge.node.tags.find(tag => tag.name === VERSION).value || 0
return getVersion(b) - getVersion(a)
}).map(e => e.node.id)
const txIds = resultEdges.sort((a, b) => {
// we reverse sort edges if version is not defined to get latest version
const getVersion = (edge) => edge.node.tags.find(tag => tag.name === VERSION).value || 0
return getVersion(b) - getVersion(a)
}).map(e => e.node.id)

// fetch document, update cache
const promises = txIds.map(txId => this.getDocumentByTxId(txId, options))
Expand Down

0 comments on commit ef99523

Please sign in to comment.