koro

an event time scheduler
git clone https://tilde.team/~marisa/repo/koro.git
Log | Files | Refs | README | LICENSE

commit 38b8adb9dd049167f33829ad9e5a9764aca284ee
parent 752b8acc38cf09e988bdacb3d2f73336a18bf53f
Author: mokou <mokou@posteo.de>
Date:   Thu, 30 Jul 2020 05:57:44 +0200

fix(poll): Key answers

Diffstat:
Mpackage.json | 2+-
Msrc/pages/Event.svelte | 25++++++++++++-------------
Msrc/pages/Poll.svelte | 25+++++++++++++------------
3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/package.json b/package.json @@ -1,7 +1,7 @@ { "name": "koro", "private": true, - "version": "1.4.0-beta.3", + "version": "1.4.0-beta.4", "scripts": { "build": "webpack", "start": "webpack-dev-server", diff --git a/src/pages/Event.svelte b/src/pages/Event.svelte @@ -118,19 +118,18 @@ // because syncing the whole DB would be completely overkill, and we only // really need to know about the documents that we can see. live = syncDoc(params.id) - live.on('change', async (change) => { - // If a change to the document is detected, pull from the PouchDB, triggering - // a rerender. - const db = await pouch() - if (change.direction === 'pull') { - getEvent().catch((err) => { - error = `Couldn't find the event. You might be offline!` - }) - } - }) - live.on('error', (err) => { - console.error(err) - }) + if (live) { + live.on('change', change => { + // If a change to the document is detected, pull from the PouchDB, triggering + // a rerender. + if (change.direction === 'pull') { + event = change.change.docs[0] + } + }) + live.on('error', (err) => { + console.error(err) + }) + } }) onDestroy(() => { diff --git a/src/pages/Poll.svelte b/src/pages/Poll.svelte @@ -136,17 +136,18 @@ // Set up replication live = syncDoc(params.id) - live - .on('change', async (change) => { - const db = await pouch() - if (change.direction === 'pull') { - poll = change.change.docs[0] - calcVotes() - } - }) - .on('error', (err) => { - console.error(err) - }) + if (live) { + live + .on('change', change => { + if (change.direction === 'pull') { + poll = change.change.docs[0] + calcVotes() + } + }) + .on('error', (err) => { + console.error(err) + }) + } }) onDestroy(() => { @@ -178,7 +179,7 @@ </p> {:else if (poll.showResultsBeforeVoting && poll.responses) || $hasResponded[params.id]} <div class="max-w-xl"> - {#each poll.answers as answer, i} + {#each poll.answers as answer, i (answer)} <div style={getStyle(i)} class="rounded-t text-center py-3 px-3"> {answer} </div>