]> cat aescling's git repositories - mastodon.git/commitdiff
Fix NaN in Poll component (#10213)
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 7 Mar 2019 21:18:05 +0000 (22:18 +0100)
committerGitHub <noreply@github.com>
Thu, 7 Mar 2019 21:18:05 +0000 (22:18 +0100)
app/javascript/mastodon/components/poll.js

index bfff7b601160f90df43234b4d0c512c91931e418..a1b297ce750f1b32229636523f99cc5297bf5bfc 100644 (file)
@@ -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');