From 862efaa711ee6d2cb3ce5593bb1113829678812f Mon Sep 17 00:00:00 2001 From: kshitij katiyar <90389917+Kshitij-Katiyar@users.noreply.github.com> Date: Mon, 9 Jan 2023 17:05:33 +0530 Subject: [PATCH] [MI-2582]:Fixed review comments for github issue #613 (#15) --- server/plugin/api.go | 9 +++------ .../components/sidebar_buttons/sidebar_buttons.jsx | 2 +- webapp/src/reducers/index.js | 14 +++++++------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/server/plugin/api.go b/server/plugin/api.go index 68df26995..d25027dcc 100644 --- a/server/plugin/api.go +++ b/server/plugin/api.go @@ -704,7 +704,6 @@ func (p *Plugin) getUnreadsData(c *UserContext) []*FilteredNotification { } func (p *Plugin) getReviewsData(c *UserContext) []*github.Issue { - var issue []*github.Issue config := p.getConfiguration() githubClient := p.githubConnectUser(c.Context.Ctx, c.GHInfo) @@ -714,14 +713,13 @@ func (p *Plugin) getReviewsData(c *UserContext) []*github.Issue { result, _, err := githubClient.Search.Issues(c.Ctx, query, &github.SearchOptions{}) if err != nil { c.Log.WithError(err).With(logger.LogContext{"query": query}).Warnf("Failed to search for review") - return issue + return []*github.Issue{} } return result.Issues } func (p *Plugin) getYourPrsData(c *UserContext) []*github.Issue { - var issue []*github.Issue config := p.getConfiguration() githubClient := p.githubConnectUser(c.Context.Ctx, c.GHInfo) @@ -731,7 +729,7 @@ func (p *Plugin) getYourPrsData(c *UserContext) []*github.Issue { result, _, err := githubClient.Search.Issues(c.Ctx, query, &github.SearchOptions{}) if err != nil { c.Log.WithError(err).With(logger.LogContext{"query": query}).Warnf("Failed to search for PRs") - return issue + return []*github.Issue{} } return result.Issues @@ -980,7 +978,6 @@ func (p *Plugin) createIssueComment(c *UserContext, w http.ResponseWriter, r *ht } func (p *Plugin) getYourAssignmentsData(c *UserContext) []*github.Issue { - var issue []*github.Issue config := p.getConfiguration() githubClient := p.githubConnectUser(c.Context.Ctx, c.GHInfo) @@ -990,7 +987,7 @@ func (p *Plugin) getYourAssignmentsData(c *UserContext) []*github.Issue { result, _, err := githubClient.Search.Issues(c.Ctx, query, &github.SearchOptions{}) if err != nil { c.Log.WithError(err).With(logger.LogContext{"query": query}).Warnf("Failed to search for assignments") - return issue + return []*github.Issue{} } return result.Issues diff --git a/webapp/src/components/sidebar_buttons/sidebar_buttons.jsx b/webapp/src/components/sidebar_buttons/sidebar_buttons.jsx index 37414c475..cbdbc0850 100644 --- a/webapp/src/components/sidebar_buttons/sidebar_buttons.jsx +++ b/webapp/src/components/sidebar_buttons/sidebar_buttons.jsx @@ -60,7 +60,7 @@ export default class SidebarButtons extends React.PureComponent { } this.setState({refreshing: true}); - await Promise.resolve(this.props.actions.getSidebarContent()); + await this.props.actions.getSidebarContent(); this.setState({refreshing: false}); } diff --git a/webapp/src/reducers/index.js b/webapp/src/reducers/index.js index 31ee6ba9c..6d1e9cbad 100644 --- a/webapp/src/reducers/index.js +++ b/webapp/src/reducers/index.js @@ -6,13 +6,6 @@ import {combineReducers} from 'redux'; import ActionTypes from '../action_types'; import Constants from '../constants'; -const defaultSidebarContent = { - reviews: [], - prs: [], - assignments: [], - unreads: [], -}; - function connected(state = false, action) { switch (action.type) { case ActionTypes.RECEIVED_CONNECTED: @@ -93,6 +86,13 @@ function reviewsDetails(state = [], action) { } } +const defaultSidebarContent = { + reviews: [], + prs: [], + assignments: [], + unreads: [], +}; + function sidebarContent(state = defaultSidebarContent, action) { switch (action.type) { case ActionTypes.RECEIVED_SIDEBAR_CONTENT: