Commit 15faa252573d24fb834a5b13c7db4411cf2edb21
Little refactor.
Piet Geursen committed on 5/10/2018, 10:02:18 PMParent: 09ff6ff75629cd4e5197bc32d8146ad5abfdc179
Files changed
poll/async/get.js | changed |
poll/async/get.js | ||
---|---|---|
@@ -83,21 +83,25 @@ | ||
83 | 83 | }, cb) |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | + function doesMsgRefPoll (msg) { | |
88 | + return msg.value.content.root === poll.key | |
89 | + } | |
90 | + | |
87 | 91 | // TODO add missingContext warnings to each msg |
88 | 92 | msgs = sort(msgs) |
89 | 93 | |
90 | 94 | const latestClosingTime = msgs |
91 | - .filter(msg => msg.value.content.root === poll.key) | |
95 | + .filter(doesMsgRefPoll) | |
92 | 96 | .filter(isPollUpdate) |
93 | 97 | .map(msg => parsePollUpdate(msg).closesAt) |
94 | 98 | .pop() |
95 | 99 | |
96 | 100 | if (latestClosingTime) poll.closesAt = latestClosingTime |
97 | 101 | |
98 | 102 | poll.positions = msgs |
99 | - .filter(msg => msg.value.content.root === poll.key) | |
103 | + .filter(doesMsgRefPoll) | |
100 | 104 | .filter(isPosition[type]) |
101 | 105 | .map(position => { |
102 | 106 | return decoratePosition({position, poll}) |
103 | 107 | }) |
@@ -108,9 +112,9 @@ | ||
108 | 112 | return a.value.timestamp > b.value.timestamp ? -1 : +1 |
109 | 113 | })[0] |
110 | 114 | |
111 | 115 | poll.errors = msgs |
112 | - .filter(msg => msg.value.content.root === poll.key) | |
116 | + .filter(doesMsgRefPoll) | |
113 | 117 | .filter(msg => isPosition(msg) && !isPosition[type](msg)) |
114 | 118 | .map(position => { |
115 | 119 | return { |
116 | 120 | type: ERROR_POSITION_TYPE, |
Built with git-ssb-web