git ssb

0+

Piet / ssb-loomio



Commit 52f72d412dda4d495dd26c896b6703ecf5a8a612

PR review changes

mix irving committed on 3/9/2018, 5:04:33 AM
Parent: d8df11e7ac40f71635d7ffabe8a76e9fcd0a61fa

Files changed

poll/async/get.jschanged
poll/async/get.jsView
@@ -1,9 +1,8 @@
11 const pull = require('pull-stream')
22 const sort = require('ssb-sort')
33 const isPoll = require('../../isPoll')
44 const isPosition = require('../../isPosition')
5-const isChooseOnePoll = require('../../poll/sync/isChooseOnePoll')
65 const { ERROR_POSITION_TYPE } = require('../../types')
76 const getResults = require('../../position/sync/chooseOneResults')
87 const getMsgContent = require('../../lib/getMsgContent')
98
@@ -40,11 +39,19 @@
4039 }
4140 }
4241
4342 function decoratedPoll (rawPoll, msgs = []) {
44- const { author, content: { title, body } } = rawPoll.value
43 + const {
44 + author,
45 + content: {
46 + title,
47 + body,
48 + pollDetails: { type }
49 + }
50 + } = rawPoll.value
4551
4652 const poll = Object.assign({}, rawPoll, {
53 + type,
4754 author,
4855 title,
4956 body,
5057
@@ -57,11 +64,8 @@
5764
5865 // TODO add missingContext warnings to each msg
5966 msgs = sort(msgs)
6067
61- // filter position message into 'positions' and 'errors'
62- const type = poll.value.content.pollDetails.type
63-
6468 poll.positions = msgs
6569 .filter(msg => msg.value.content.root === poll.key)
6670 .filter(isPosition[type])
6771 .map(position => {
@@ -89,11 +93,12 @@
8993 function decoratePosition ({position: rawPosition, poll: rawPoll}) {
9094 var position = getMsgContent(rawPosition)
9195 var poll = getMsgContent(rawPoll)
9296
97 + // NOTE this isn't deep enough to be a safe clone
9398 var newPosition = Object.assign({}, rawPosition)
9499
95- if (isChooseOnePoll(poll)) {
100 + if (isPoll.chooseOne(poll)) {
96101 var choiceIndex = position.positionDetails.choice
97102 newPosition.choice = poll.pollDetails.choices[choiceIndex]
98103 }
99104 return newPosition

Built with git-ssb-web