git ssb

0+

Piet / ssb-loomio



Commit 028237b4b26db208a93b7399ed9575c6608b1999

Merge branch 'master' into reducer-only-counts-latest-vote-by-author

mix irving committed on 3/9/2018, 5:21:43 AM
Parent: 6730668ae7223a39f319ed33a69019c0ef1d8c38
Parent: d73dadc02145f4bb0d854fedadb58c6caaef4b99

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 + details: { 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.details.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.details.choice
97102 newPosition.choice = poll.details.choices[choiceIndex]
98103 }
99104 return newPosition

Built with git-ssb-web