Open platform to collect and prioritize feedback
quick fix
goenning2c57bf4df61c
diff --git a/app/handlers/feedback.go b/app/handlers/feedback.goindex f3f87b3c1..40a3e42bc 100644--- a/app/handlers/feedback.go+++ b/app/handlers/feedback.go@@ -27,9 +27,12 @@ func (h AllHandlers) List() web.HandlerFunc {return c.Failure(err)}- supported, err := h.ideas.GetSupportedIdeas(c.User().ID)- if err != nil {- return c.Failure(err)+ var supported []int+ if c.IsAuthenticated() {+ supported, err = h.ideas.GetSupportedIdeas(c.User().ID)+ if err != nil {+ return c.Failure(err)+ }}return c.Page(echo.Map{diff --git a/public/components/SupportCounter.tsx b/public/components/SupportCounter.tsxindex 76fd8d12a..4905f3db0 100644--- a/public/components/SupportCounter.tsx+++ b/public/components/SupportCounter.tsx@@ -1,6 +1,6 @@import axios from "axios";import * as React from "react";-import { Idea } from "../models";+import { Idea, User } from "../models";import * as storage from "../storage";interface SupportCounterProps {@@ -10,6 +10,7 @@ interface SupportCounterProps {interface SupportCounterState {supported: boolean;total: number;+ user: User;}export class SupportCounter extends React.Component<SupportCounterProps, SupportCounterState> {@@ -19,12 +20,13 @@ export class SupportCounter extends React.Component<SupportCounterProps, Supportconst supported = storage.get<number[]>("supported") || [];this.state = {supported: supported.indexOf(props.idea.id) >= 0,- total: props.idea.totalSupporters+ total: props.idea.totalSupporters,+ user: storage.getCurrentUser()};}public async undo() {- if (!this.state.supported) { return; }+ if (!this.state.supported || !this.state.user) { return; }try {await axios.post(`/api/ideas/${this.props.idea.number}/unsupport`);@@ -40,7 +42,7 @@ export class SupportCounter extends React.Component<SupportCounterProps, Support}public async support() {- if (this.state.supported) { return; }+ if (this.state.supported || !this.state.user) { return; }try {await axios.post(`/api/ideas/${this.props.idea.number}/support`);