From ca45198ccbbdde88731f074fcab2b5c9310775c2 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 7 Mar 2019 22:18:05 +0100 Subject: [PATCH] [Glitch] Fix NaN in Poll component Port 75cb93676b1dd41d3e47f62466c0c6430691a990 to glitch-soc --- app/javascript/flavours/glitch/components/poll.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/components/poll.js b/app/javascript/flavours/glitch/components/poll.js index bfff7b6011..a1b297ce75 100644 --- a/app/javascript/flavours/glitch/components/poll.js +++ b/app/javascript/flavours/glitch/components/poll.js @@ -94,7 +94,7 @@ class Poll extends ImmutablePureComponent { renderOption (option, optionIndex) { const { poll, disabled } = this.props; - const percent = (option.get('votes_count') / poll.get('votes_count')) * 100; + const percent = poll.get('votes_count') === 0 ? 0 : (option.get('votes_count') / poll.get('votes_count')) * 100; const leading = poll.get('options').filterNot(other => other.get('title') === option.get('title')).every(other => option.get('votes_count') > other.get('votes_count')); const active = !!this.state.selected[`${optionIndex}`]; const showResults = poll.get('voted') || poll.get('expired');