From 6ab4a35952ca5ac64f0240ccabf3d3c098547826 Mon Sep 17 00:00:00 2001 From: Raghav Aggarwal Date: Mon, 9 Oct 2023 19:22:59 +0530 Subject: [PATCH] [MI-3561] Fixed issue: Getting multiple DMs when Oauth token is revoked (#42) * [MI-3561] Fixed issue: Getting multiple DMs when Oauth token is revoked - Created a single API to get the data for LHS and todo command. * [MI-3561] Review fixes 1. Replaced 'babel-eslint' package with '@babel/eslint-parser' as the previous one was deprecated * [MI-3561] Review fixes * [MI-3561] Review fix --- server/api.go | 72 +----------- server/gitlab/api.go | 111 ++++++++++-------- server/gitlab/gitlab.go | 9 +- server/gitlab/mocks/mock_gitlab.go | 23 +++- server/mocks/mock_gitlab.go | 23 +++- server/plugin.go | 78 ++---------- webapp/.eslintrc.json | 2 +- webapp/package-lock.json | 58 +++++---- webapp/package.json | 2 +- webapp/src/action_types/index.js | 5 +- webapp/src/actions/index.js | 84 +------------ webapp/src/client/client.js | 18 +-- .../src/components/sidebar_buttons/index.js | 18 +-- .../sidebar_buttons/sidebar_buttons.jsx | 12 +- webapp/src/reducers/index.js | 36 +----- webapp/src/selectors/index.js | 8 +- webapp/src/websocket/index.js | 15 +-- 17 files changed, 177 insertions(+), 397 deletions(-) diff --git a/server/api.go b/server/api.go index b17707d8..32ff418f 100644 --- a/server/api.go +++ b/server/api.go @@ -14,7 +14,6 @@ import ( "github.com/gorilla/mux" "github.com/pkg/errors" - gitlabLib "github.com/xanzy/go-gitlab" "golang.org/x/oauth2" "github.com/mattermost/mattermost/server/public/model" @@ -55,11 +54,8 @@ func (p *Plugin) initializeAPI() { apiRouter.HandleFunc("/user", p.checkAuth(p.attachContext(p.getGitlabUser), ResponseTypeJSON)).Methods(http.MethodPost) apiRouter.HandleFunc("/todo", p.checkAuth(p.attachUserContext(p.postToDo), ResponseTypeJSON)).Methods(http.MethodPost) - apiRouter.HandleFunc("/reviews", p.checkAuth(p.attachUserContext(p.getReviews), ResponseTypePlain)).Methods(http.MethodGet) - apiRouter.HandleFunc("/yourprs", p.checkAuth(p.attachUserContext(p.getYourPrs), ResponseTypePlain)).Methods(http.MethodGet) + apiRouter.HandleFunc("/lhs-data", p.checkAuth(p.attachUserContext(p.getLHSData), ResponseTypePlain)).Methods(http.MethodGet) apiRouter.HandleFunc("/prdetails", p.checkAuth(p.attachUserContext(p.getPrDetails), ResponseTypePlain)).Methods(http.MethodPost) - apiRouter.HandleFunc("/yourassignments", p.checkAuth(p.attachUserContext(p.getYourAssignments), ResponseTypePlain)).Methods(http.MethodGet) - apiRouter.HandleFunc("/unreads", p.checkAuth(p.attachUserContext(p.getUnreads), ResponseTypePlain)).Methods(http.MethodGet) apiRouter.HandleFunc("/settings", p.checkAuth(p.attachUserContext(p.updateSettings), ResponseTypePlain)).Methods(http.MethodPost) apiRouter.HandleFunc("/channel/{channel_id:[A-Za-z0-9]+}/subscriptions", p.checkAuth(p.attachUserContext(p.getChannelSubscriptions), ResponseTypeJSON)).Methods(http.MethodGet) @@ -530,66 +526,6 @@ func (p *Plugin) getConnected(c *Context, w http.ResponseWriter, r *http.Request p.writeAPIResponse(w, resp) } -func (p *Plugin) getUnreads(c *UserContext, w http.ResponseWriter, r *http.Request) { - var result []*gitlabLib.Todo - err := p.useGitlabClient(c.GitlabInfo, func(info *gitlab.UserInfo, token *oauth2.Token) error { - resp, err := p.GitlabClient.GetUnreads(c.Ctx, info, token) - if err != nil { - return err - } - result = resp - return nil - }) - - if err != nil { - c.Log.WithError(err).Warnf("Unable to list unreads in GitLab API") - p.writeAPIError(w, &APIErrorResponse{ID: "", Message: "Unable to list unreads in GitLab API.", StatusCode: http.StatusInternalServerError}) - return - } - - p.writeAPIResponse(w, result) -} - -func (p *Plugin) getReviews(c *UserContext, w http.ResponseWriter, r *http.Request) { - var result []*gitlab.MergeRequest - err := p.useGitlabClient(c.GitlabInfo, func(info *gitlab.UserInfo, token *oauth2.Token) error { - resp, err := p.GitlabClient.GetReviews(c.Ctx, info, token) - if err != nil { - return err - } - result = resp - return nil - }) - - if err != nil { - c.Log.WithError(err).Warnf("Unable to list merge-request where assignee in GitLab API") - p.writeAPIError(w, &APIErrorResponse{ID: "", Message: "Unable to list merge-request in GitLab API.", StatusCode: http.StatusInternalServerError}) - return - } - - p.writeAPIResponse(w, result) -} - -func (p *Plugin) getYourPrs(c *UserContext, w http.ResponseWriter, r *http.Request) { - var result []*gitlab.MergeRequest - err := p.useGitlabClient(c.GitlabInfo, func(info *gitlab.UserInfo, token *oauth2.Token) error { - resp, err := p.GitlabClient.GetYourPrs(c.Ctx, info, token) - if err != nil { - return err - } - result = resp - return nil - }) - - if err != nil { - c.Log.WithError(err).Warnf("Can't list merge-request where author in GitLab API") - p.writeAPIError(w, &APIErrorResponse{ID: "", Message: "Unable to list merge-request in GitLab API.", StatusCode: http.StatusInternalServerError}) - return - } - - p.writeAPIResponse(w, result) -} - func (p *Plugin) getPrDetails(c *UserContext, w http.ResponseWriter, r *http.Request) { var prList []*gitlab.PRDetails if err := json.NewDecoder(r.Body).Decode(&prList); err != nil { @@ -615,10 +551,10 @@ func (p *Plugin) getPrDetails(c *UserContext, w http.ResponseWriter, r *http.Req p.writeAPIResponse(w, result) } -func (p *Plugin) getYourAssignments(c *UserContext, w http.ResponseWriter, r *http.Request) { - var result []*gitlab.Issue +func (p *Plugin) getLHSData(c *UserContext, w http.ResponseWriter, r *http.Request) { + var result *gitlab.LHSContent err := p.useGitlabClient(c.GitlabInfo, func(info *gitlab.UserInfo, token *oauth2.Token) error { - resp, err := p.GitlabClient.GetYourAssignments(c.Ctx, info, token) + resp, err := p.GitlabClient.GetLHSData(c.Ctx, info, token) if err != nil { return err } diff --git a/server/gitlab/api.go b/server/gitlab/api.go index 268d3e43..0260fb25 100644 --- a/server/gitlab/api.go +++ b/server/gitlab/api.go @@ -40,6 +40,13 @@ type Issue struct { LabelsWithDetails []*internGitlab.Label `json:"labels_with_details,omitempty"` } +type LHSContent struct { + PRs []*MergeRequest `json:"prs"` + Reviews []*MergeRequest `json:"reviews"` + Assignments []*Issue `json:"assignments"` + Unreads []*internGitlab.Todo `json:"unreads"` +} + // NewGroupHook creates a webhook associated with a GitLab group func (g *gitlab) NewGroupHook(ctx context.Context, user *UserInfo, token *oauth2.Token, groupName string, webhookOptions *AddWebhookOptions) (*WebhookInfo, error) { client, err := g.GitlabConnect(*token) @@ -282,12 +289,51 @@ func (g *gitlab) GetProject(ctx context.Context, user *UserInfo, token *oauth2.T return project, nil } -func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*MergeRequest, error) { +func (g *gitlab) GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.Token) (*LHSContent, error) { client, err := g.GitlabConnect(*token) if err != nil { return nil, err } + grp, ctx := errgroup.WithContext(ctx) + + var reviews []*MergeRequest + grp.Go(func() error { + reviews, err = g.GetReviews(ctx, user, client) + return err + }) + + var assignments []*Issue + grp.Go(func() error { + assignments, err = g.GetYourAssignments(ctx, user, client) + return err + }) + + var mergeRequests []*MergeRequest + grp.Go(func() error { + mergeRequests, err = g.GetYourPrs(ctx, user, client) + return err + }) + + var unreads []*internGitlab.Todo + grp.Go(func() error { + unreads, err = g.GetUnreads(ctx, user, client) + return err + }) + + if err := grp.Wait(); err != nil { + return nil, err + } + + return &LHSContent{ + Reviews: reviews, + PRs: mergeRequests, + Assignments: assignments, + Unreads: unreads, + }, nil +} + +func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) { opened := stateOpened scope := scopeAll @@ -300,9 +346,7 @@ func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, token *oauth2.T ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { - var current []*internGitlab.MergeRequest - var resp *internGitlab.Response - current, resp, err = client.MergeRequests.ListMergeRequests(opt) + current, resp, err := client.MergeRequests.ListMergeRequests(opt) if err != nil { return nil, err } @@ -320,9 +364,7 @@ func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, token *oauth2.T ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { - var current []*internGitlab.MergeRequest - var resp *internGitlab.Response - current, resp, err = client.MergeRequests.ListGroupMergeRequests(g.gitlabGroup, opt) + current, resp, err := client.MergeRequests.ListGroupMergeRequests(g.gitlabGroup, opt) if err != nil { return nil, err } @@ -337,8 +379,7 @@ func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, token *oauth2.T mergeRequests := []*MergeRequest{} for _, mr := range mrs { if mr.Labels != nil { - var labelsWithDetails []*internGitlab.Label - labelsWithDetails, err = g.GetLabelDetails(client, mr.ProjectID, mr.Labels) + labelsWithDetails, err := g.GetLabelDetails(client, mr.ProjectID, mr.Labels) if err != nil { return nil, err } @@ -350,20 +391,13 @@ func (g *gitlab) GetReviews(ctx context.Context, user *UserInfo, token *oauth2.T } } - return mergeRequests, err + return mergeRequests, nil } -func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*MergeRequest, error) { - client, err := g.GitlabConnect(*token) - if err != nil { - return nil, err - } - +func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) { opened := stateOpened scope := scopeAll - var mrs []*internGitlab.MergeRequest - if g.gitlabGroup == "" { opt := &internGitlab.ListMergeRequestsOptions{ AuthorID: &user.GitlabUserID, @@ -372,9 +406,7 @@ func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, token *oauth2.T ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { - var current []*internGitlab.MergeRequest - var resp *internGitlab.Response - current, resp, err = client.MergeRequests.ListMergeRequests(opt) + current, resp, err := client.MergeRequests.ListMergeRequests(opt) if err != nil { return nil, err } @@ -392,9 +424,7 @@ func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, token *oauth2.T ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { - var current []*internGitlab.MergeRequest - var resp *internGitlab.Response - current, resp, err = client.MergeRequests.ListGroupMergeRequests(g.gitlabGroup, opt) + current, resp, err := client.MergeRequests.ListGroupMergeRequests(g.gitlabGroup, opt) if err != nil { return nil, err } @@ -409,8 +439,7 @@ func (g *gitlab) GetYourPrs(ctx context.Context, user *UserInfo, token *oauth2.T mergeRequests := []*MergeRequest{} for _, mr := range mrs { if mr.Labels != nil { - var labelsWithDetails []*internGitlab.Label - labelsWithDetails, err = g.GetLabelDetails(client, mr.ProjectID, mr.Labels) + labelsWithDetails, err := g.GetLabelDetails(client, mr.ProjectID, mr.Labels) if err != nil { return nil, err } @@ -518,14 +547,9 @@ func (g *gitlab) fetchYourPrDetails(c context.Context, log logger.Logger, client return nil } -func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*Issue, error) { - client, err := g.GitlabConnect(*token) - if err != nil { - return nil, err - } +func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error) { opened := stateOpened scope := scopeAll - var issues []*internGitlab.Issue if g.gitlabGroup == "" { @@ -536,9 +560,7 @@ func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, token * ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { - var current []*internGitlab.Issue - var resp *internGitlab.Response - current, resp, err = client.Issues.ListIssues(opt) + current, resp, err := client.Issues.ListIssues(opt) if err != nil { return nil, err } @@ -556,9 +578,7 @@ func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, token * ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { - var current []*internGitlab.Issue - var resp *internGitlab.Response - current, resp, err = client.Issues.ListGroupIssues(g.gitlabGroup, opt) + current, resp, err := client.Issues.ListGroupIssues(g.gitlabGroup, opt) if err != nil { return nil, err } @@ -573,8 +593,7 @@ func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, token * var result []*Issue for _, issue := range issues { if issue.Labels != nil { - var labelsWithDetails []*internGitlab.Label - labelsWithDetails, err = g.GetLabelDetails(client, issue.ProjectID, issue.Labels) + labelsWithDetails, err := g.GetLabelDetails(client, issue.ProjectID, issue.Labels) if err != nil { return nil, err } @@ -588,20 +607,14 @@ func (g *gitlab) GetYourAssignments(ctx context.Context, user *UserInfo, token * return result, nil } -func (g *gitlab) GetUnreads(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*internGitlab.Todo, error) { - client, err := g.GitlabConnect(*token) - if err != nil { - return nil, err - } - +func (g *gitlab) GetUnreads(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error) { var todos []*internGitlab.Todo + opt := &internGitlab.ListTodosOptions{ ListOptions: internGitlab.ListOptions{Page: 1, PerPage: perPage}, } for { - var current []*internGitlab.Todo - var resp *internGitlab.Response - current, resp, err = client.Todos.ListTodos(opt) + current, resp, err := client.Todos.ListTodos(opt) if err != nil { return nil, errors.Wrap(err, "can't list todo in GitLab api") } diff --git a/server/gitlab/gitlab.go b/server/gitlab/gitlab.go index 5a4f5fa9..20bbb0e5 100644 --- a/server/gitlab/gitlab.go +++ b/server/gitlab/gitlab.go @@ -28,10 +28,11 @@ type Gitlab interface { GetUserDetails(ctx context.Context, user *UserInfo, token *oauth2.Token) (*internGitlab.User, error) GetProject(ctx context.Context, user *UserInfo, token *oauth2.Token, owner, repo string) (*internGitlab.Project, error) GetYourPrDetails(ctx context.Context, log logger.Logger, user *UserInfo, token *oauth2.Token, prList []*PRDetails) ([]*PRDetails, error) - GetReviews(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*MergeRequest, error) - GetYourPrs(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*MergeRequest, error) - GetYourAssignments(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*Issue, error) - GetUnreads(ctx context.Context, user *UserInfo, token *oauth2.Token) ([]*internGitlab.Todo, error) + GetReviews(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) + GetYourPrs(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*MergeRequest, error) + GetLHSData(ctx context.Context, user *UserInfo, token *oauth2.Token) (*LHSContent, error) + GetYourAssignments(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*Issue, error) + GetUnreads(ctx context.Context, user *UserInfo, client *internGitlab.Client) ([]*internGitlab.Todo, error) GetProjectHooks(ctx context.Context, user *UserInfo, token *oauth2.Token, owner string, repo string) ([]*WebhookInfo, error) GetGroupHooks(ctx context.Context, user *UserInfo, token *oauth2.Token, owner string) ([]*WebhookInfo, error) NewProjectHook(ctx context.Context, user *UserInfo, token *oauth2.Token, projectID interface{}, projectHookOptions *AddWebhookOptions) (*WebhookInfo, error) diff --git a/server/gitlab/mocks/mock_gitlab.go b/server/gitlab/mocks/mock_gitlab.go index 37e18c0c..668bed95 100644 --- a/server/gitlab/mocks/mock_gitlab.go +++ b/server/gitlab/mocks/mock_gitlab.go @@ -68,6 +68,21 @@ func (mr *MockGitlabMockRecorder) GetGroupHooks(arg0, arg1, arg2, arg3 interface return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupHooks", reflect.TypeOf((*MockGitlab)(nil).GetGroupHooks), arg0, arg1, arg2, arg3) } +// GetLHSData mocks base method. +func (m *MockGitlab) GetLHSData(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) (*gitlab.LHSContent, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLHSData", arg0, arg1, arg2) + ret0, _ := ret[0].(*gitlab.LHSContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetLHSData indicates an expected call of GetLHSData. +func (mr *MockGitlabMockRecorder) GetLHSData(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLHSData", reflect.TypeOf((*MockGitlab)(nil).GetLHSData), arg0, arg1, arg2) +} + // GetProject mocks base method. func (m *MockGitlab) GetProject(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token, arg3, arg4 string) (*gitlab0.Project, error) { m.ctrl.T.Helper() @@ -99,7 +114,7 @@ func (mr *MockGitlabMockRecorder) GetProjectHooks(arg0, arg1, arg2, arg3, arg4 i } // GetReviews mocks base method. -func (m *MockGitlab) GetReviews(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) ([]*gitlab.MergeRequest, error) { +func (m *MockGitlab) GetReviews(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.MergeRequest, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetReviews", arg0, arg1, arg2) ret0, _ := ret[0].([]*gitlab.MergeRequest) @@ -114,7 +129,7 @@ func (mr *MockGitlabMockRecorder) GetReviews(arg0, arg1, arg2 interface{}) *gomo } // GetUnreads mocks base method. -func (m *MockGitlab) GetUnreads(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) ([]*gitlab0.Todo, error) { +func (m *MockGitlab) GetUnreads(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab0.Todo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetUnreads", arg0, arg1, arg2) ret0, _ := ret[0].([]*gitlab0.Todo) @@ -144,7 +159,7 @@ func (mr *MockGitlabMockRecorder) GetUserDetails(arg0, arg1, arg2 interface{}) * } // GetYourAssignments mocks base method. -func (m *MockGitlab) GetYourAssignments(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) ([]*gitlab.Issue, error) { +func (m *MockGitlab) GetYourAssignments(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.Issue, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetYourAssignments", arg0, arg1, arg2) ret0, _ := ret[0].([]*gitlab.Issue) @@ -174,7 +189,7 @@ func (mr *MockGitlabMockRecorder) GetYourPrDetails(arg0, arg1, arg2, arg3, arg4 } // GetYourPrs mocks base method. -func (m *MockGitlab) GetYourPrs(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) ([]*gitlab.MergeRequest, error) { +func (m *MockGitlab) GetYourPrs(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.MergeRequest, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetYourPrs", arg0, arg1, arg2) ret0, _ := ret[0].([]*gitlab.MergeRequest) diff --git a/server/mocks/mock_gitlab.go b/server/mocks/mock_gitlab.go index 37e18c0c..668bed95 100644 --- a/server/mocks/mock_gitlab.go +++ b/server/mocks/mock_gitlab.go @@ -68,6 +68,21 @@ func (mr *MockGitlabMockRecorder) GetGroupHooks(arg0, arg1, arg2, arg3 interface return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupHooks", reflect.TypeOf((*MockGitlab)(nil).GetGroupHooks), arg0, arg1, arg2, arg3) } +// GetLHSData mocks base method. +func (m *MockGitlab) GetLHSData(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) (*gitlab.LHSContent, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLHSData", arg0, arg1, arg2) + ret0, _ := ret[0].(*gitlab.LHSContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetLHSData indicates an expected call of GetLHSData. +func (mr *MockGitlabMockRecorder) GetLHSData(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLHSData", reflect.TypeOf((*MockGitlab)(nil).GetLHSData), arg0, arg1, arg2) +} + // GetProject mocks base method. func (m *MockGitlab) GetProject(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token, arg3, arg4 string) (*gitlab0.Project, error) { m.ctrl.T.Helper() @@ -99,7 +114,7 @@ func (mr *MockGitlabMockRecorder) GetProjectHooks(arg0, arg1, arg2, arg3, arg4 i } // GetReviews mocks base method. -func (m *MockGitlab) GetReviews(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) ([]*gitlab.MergeRequest, error) { +func (m *MockGitlab) GetReviews(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.MergeRequest, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetReviews", arg0, arg1, arg2) ret0, _ := ret[0].([]*gitlab.MergeRequest) @@ -114,7 +129,7 @@ func (mr *MockGitlabMockRecorder) GetReviews(arg0, arg1, arg2 interface{}) *gomo } // GetUnreads mocks base method. -func (m *MockGitlab) GetUnreads(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) ([]*gitlab0.Todo, error) { +func (m *MockGitlab) GetUnreads(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab0.Todo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetUnreads", arg0, arg1, arg2) ret0, _ := ret[0].([]*gitlab0.Todo) @@ -144,7 +159,7 @@ func (mr *MockGitlabMockRecorder) GetUserDetails(arg0, arg1, arg2 interface{}) * } // GetYourAssignments mocks base method. -func (m *MockGitlab) GetYourAssignments(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) ([]*gitlab.Issue, error) { +func (m *MockGitlab) GetYourAssignments(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.Issue, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetYourAssignments", arg0, arg1, arg2) ret0, _ := ret[0].([]*gitlab.Issue) @@ -174,7 +189,7 @@ func (mr *MockGitlabMockRecorder) GetYourPrDetails(arg0, arg1, arg2, arg3, arg4 } // GetYourPrs mocks base method. -func (m *MockGitlab) GetYourPrs(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *oauth2.Token) ([]*gitlab.MergeRequest, error) { +func (m *MockGitlab) GetYourPrs(arg0 context.Context, arg1 *gitlab.UserInfo, arg2 *gitlab0.Client) ([]*gitlab.MergeRequest, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetYourPrs", arg0, arg1, arg2) ret0, _ := ret[0].([]*gitlab.MergeRequest) diff --git a/server/plugin.go b/server/plugin.go index ab1790a6..90018922 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -24,7 +24,6 @@ import ( "github.com/pkg/errors" gitlabLib "github.com/xanzy/go-gitlab" "golang.org/x/oauth2" - "golang.org/x/sync/errgroup" root "github.com/mattermost/mattermost-plugin-gitlab" "github.com/mattermost/mattermost-plugin-gitlab/server/gitlab" @@ -577,23 +576,15 @@ func (p *Plugin) PostToDo(ctx context.Context, info *gitlab.UserInfo) { func (p *Plugin) GetToDo(ctx context.Context, user *gitlab.UserInfo) (bool, string, error) { hasTodo := false - g, ctx := errgroup.WithContext(ctx) - - notificationText := "" - g.Go(func() error { - var unreads []*gitlabLib.Todo - err := p.useGitlabClient(user, func(info *gitlab.UserInfo, token *oauth2.Token) error { - resp, err := p.GitlabClient.GetUnreads(ctx, info, token) - if err != nil { - return err - } - unreads = resp - return nil - }) + + var notificationText, reviewText, assignmentText, mergeRequestText string + err := p.useGitlabClient(user, func(info *gitlab.UserInfo, token *oauth2.Token) error { + resp, err := p.GitlabClient.GetLHSData(ctx, info, token) if err != nil { return err } + unreads := resp.Unreads notificationCount := 0 notificationContent := "" @@ -618,24 +609,7 @@ func (p *Plugin) GetToDo(ctx context.Context, user *gitlab.UserInfo) (bool, stri hasTodo = true } - return nil - }) - - reviewText := "" - g.Go(func() error { - var reviews []*gitlab.MergeRequest - err := p.useGitlabClient(user, func(info *gitlab.UserInfo, token *oauth2.Token) error { - resp, err := p.GitlabClient.GetReviews(ctx, info, token) - if err != nil { - return err - } - reviews = resp - return nil - }) - if err != nil { - return err - } - + reviews := resp.Reviews if len(reviews) == 0 { reviewText += "You don't have any merge requests awaiting your review.\n" } else { @@ -648,23 +622,7 @@ func (p *Plugin) GetToDo(ctx context.Context, user *gitlab.UserInfo) (bool, stri hasTodo = true } - return nil - }) - - assignmentText := "" - g.Go(func() error { - var yourAssignments []*gitlab.Issue - err := p.useGitlabClient(user, func(info *gitlab.UserInfo, token *oauth2.Token) error { - resp, err := p.GitlabClient.GetYourAssignments(ctx, info, token) - if err != nil { - return err - } - yourAssignments = resp - return nil - }) - if err != nil { - return err - } + yourAssignments := resp.Assignments if len(yourAssignments) == 0 { assignmentText += "You don't have any issues awaiting your dev.\n" @@ -678,24 +636,7 @@ func (p *Plugin) GetToDo(ctx context.Context, user *gitlab.UserInfo) (bool, stri hasTodo = true } - return nil - }) - - mergeRequestText := "" - g.Go(func() error { - var mergeRequests []*gitlab.MergeRequest - err := p.useGitlabClient(user, func(info *gitlab.UserInfo, token *oauth2.Token) error { - resp, err := p.GitlabClient.GetYourPrs(ctx, info, token) - if err != nil { - return err - } - mergeRequests = resp - return nil - }) - if err != nil { - return err - } - + mergeRequests := resp.PRs if len(mergeRequests) == 0 { mergeRequestText += "You don't have any open merge requests.\n" } else { @@ -710,8 +651,7 @@ func (p *Plugin) GetToDo(ctx context.Context, user *gitlab.UserInfo) (bool, stri return nil }) - - if err := g.Wait(); err != nil { + if err != nil { return false, "", err } diff --git a/webapp/.eslintrc.json b/webapp/.eslintrc.json index 1b547d5a..012367c3 100644 --- a/webapp/.eslintrc.json +++ b/webapp/.eslintrc.json @@ -10,7 +10,7 @@ "experimentalObjectRestSpread": true } }, - "parser": "babel-eslint", + "parser": "@babel/eslint-parser", "plugins": [ "react", "import" diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 28a39006..9798d277 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -77,6 +77,25 @@ } } }, + "@babel/eslint-parser": { + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.22.15.tgz", + "integrity": "sha512-yc8OOBIQk1EcRrpizuARSQS0TWAcOMpEJ1aafhNznaeYkeL+OhqnDObGFylB8ka8VFF/sZc+S4RzHyO+3LjQxg==", + "dev": true, + "requires": { + "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", + "eslint-visitor-keys": "^2.1.0", + "semver": "^6.3.1" + }, + "dependencies": { + "semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true + } + } + }, "@babel/generator": { "version": "7.18.2", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.18.2.tgz", @@ -1337,6 +1356,15 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "@nicolo-ribaudo/eslint-scope-5-internals": { + "version": "5.1.1-v1", + "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", + "integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==", + "dev": true, + "requires": { + "eslint-scope": "5.1.1" + } + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -2088,28 +2116,6 @@ "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, - "babel-eslint": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", - "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.0", - "@babel/traverse": "^7.7.0", - "@babel/types": "^7.7.0", - "eslint-visitor-keys": "^1.0.0", - "resolve": "^1.12.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } - } - }, "babel-loader": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.1.0.tgz", @@ -6139,7 +6145,7 @@ "react-custom-scrollbars": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/react-custom-scrollbars/-/react-custom-scrollbars-4.2.1.tgz", - "integrity": "sha1-gw/ZUCkn6X6KeMIIaBOJmyqLZts=", + "integrity": "sha512-VtJTUvZ7kPh/auZWIbBRceGPkE30XBYe+HktFxuMWBR2eVQQ+Ur6yFJMoaYcNpyGq22uYJ9Wx4UAEcC0K+LNPQ==", "requires": { "dom-css": "^2.0.0", "prop-types": "^15.5.10", @@ -7431,7 +7437,7 @@ "to-camel-case": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/to-camel-case/-/to-camel-case-1.0.0.tgz", - "integrity": "sha1-GlYFSy+daWKYzmamCJcyK29CPkY=", + "integrity": "sha512-nD8pQi5H34kyu1QDMFjzEIYqk0xa9Alt6ZfrdEMuHCFOfTLhDG5pgTu/aAM9Wt9lXILwlXmWP43b8sav0GNE8Q==", "requires": { "to-space-case": "^1.0.0" } @@ -7445,7 +7451,7 @@ "to-no-case": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/to-no-case/-/to-no-case-1.0.2.tgz", - "integrity": "sha1-xyKQcWTvaxeBMsjmmTAhLRtKoWo=" + "integrity": "sha512-Z3g735FxuZY8rodxV4gH7LxClE4H0hTIyHNIHdk+vpQxjLm0cwnKXq/OFVZ76SOQmto7txVcwSCwkU5kqp+FKg==" }, "to-object-path": { "version": "0.3.0", @@ -7492,7 +7498,7 @@ "to-space-case": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/to-space-case/-/to-space-case-1.0.0.tgz", - "integrity": "sha1-sFLar7Gysp3HcM6gFj5ewOvJ/Bc=", + "integrity": "sha512-rLdvwXZ39VOn1IxGL3V6ZstoTbwLRckQmn/U8ZDLuWwIXNpuZDhQ3AiRUlhTbOXFVE9C+dR51wM0CBDhk31VcA==", "requires": { "to-no-case": "^1.0.0" } diff --git a/webapp/package.json b/webapp/package.json index d8356e19..46e946b2 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -25,6 +25,7 @@ "devDependencies": { "@babel/cli": "7.11.6", "@babel/core": "7.11.6", + "@babel/eslint-parser": "7.22.15", "@babel/plugin-proposal-class-properties": "7.10.4", "@babel/plugin-proposal-nullish-coalescing-operator": "7.17.12", "@babel/plugin-proposal-optional-chaining": "7.11.0", @@ -42,7 +43,6 @@ "@types/react-transition-group": "4.4.0", "@typescript-eslint/eslint-plugin": "4.1.1", "@typescript-eslint/parser": "4.1.1", - "babel-eslint": "10.1.0", "babel-loader": "8.1.0", "babel-plugin-typescript-to-proptypes": "1.4.1", "css-loader": "4.3.0", diff --git a/webapp/src/action_types/index.js b/webapp/src/action_types/index.js index f67cbcf2..7d2745c1 100644 --- a/webapp/src/action_types/index.js +++ b/webapp/src/action_types/index.js @@ -1,13 +1,10 @@ import {id} from '../manifest'; export default { - RECEIVED_REVIEWS: `${id}_received_reviews`, - RECEIVED_YOUR_PRS: `${id}_received_your_prs`, RECEIVED_YOUR_PR_DETAILS: `${id}_received_your_pr_details`, RECEIVED_REVIEW_DETAILS: `${id}_received_review_details`, - RECEIVED_YOUR_ASSIGNMENTS: `${id}_received_your_assignments`, RECEIVED_MENTIONS: `${id}_received_mentions`, - RECEIVED_UNREADS: `${id}_received_unreads`, + RECEIVED_LHS_DATA: `${id}_received_lhs_data`, RECEIVED_CONNECTED: `${id}_received_connected`, RECEIVED_GITLAB_USER: `${id}_received_gitlab_user`, RECEIVED_SHOW_RHS_ACTION: `${id}_received_rhs_action`, diff --git a/webapp/src/actions/index.js b/webapp/src/actions/index.js index 779e27df..1b99348f 100644 --- a/webapp/src/actions/index.js +++ b/webapp/src/actions/index.js @@ -38,32 +38,6 @@ function checkAndHandleNotConnected(data) { }; } -export function getReviews() { - return async (dispatch, getState) => { - let data; - try { - data = await Client.getReviews(); - } catch (error) { - return {error}; - } - - const connected = await checkAndHandleNotConnected(data)( - dispatch, - getState, - ); - if (!connected) { - return {error: data}; - } - - dispatch({ - type: ActionTypes.RECEIVED_REVIEWS, - data, - }); - - return {data}; - }; -} - export function getReviewDetails(prList) { return async (dispatch, getState) => { let data; @@ -87,32 +61,6 @@ export function getReviewDetails(prList) { }; } -export function getYourPrs() { - return async (dispatch, getState) => { - let data; - try { - data = await Client.getYourPrs(); - } catch (error) { - return {error}; - } - - const connected = await checkAndHandleNotConnected(data)( - dispatch, - getState, - ); - if (!connected) { - return {error: data}; - } - - dispatch({ - type: ActionTypes.RECEIVED_YOUR_PRS, - data, - }); - - return {data}; - }; -} - export function getYourPrDetails(prList) { return async (dispatch, getState) => { let data; @@ -136,32 +84,6 @@ export function getYourPrDetails(prList) { }; } -export function getYourAssignments() { - return async (dispatch, getState) => { - let data; - try { - data = await Client.getYourAssignments(); - } catch (error) { - return {error}; - } - - const connected = await checkAndHandleNotConnected(data)( - dispatch, - getState, - ); - if (!connected) { - return {error: data}; - } - - dispatch({ - type: ActionTypes.RECEIVED_YOUR_ASSIGNMENTS, - data, - }); - - return {data}; - }; -} - export function getMentions() { return async (dispatch, getState) => { let data; @@ -188,11 +110,11 @@ export function getMentions() { }; } -export function getUnreads() { +export function getLHSData() { return async (dispatch, getState) => { let data; try { - data = await Client.getUnreads(); + data = await Client.getLHSData(); } catch (error) { return {error}; } @@ -206,7 +128,7 @@ export function getUnreads() { } dispatch({ - type: ActionTypes.RECEIVED_UNREADS, + type: ActionTypes.RECEIVED_LHS_DATA, data, }); diff --git a/webapp/src/client/client.js b/webapp/src/client/client.js index c8cd1696..fd269759 100644 --- a/webapp/src/client/client.js +++ b/webapp/src/client/client.js @@ -10,30 +10,18 @@ export default class Client { return this.doGet(`${this.url}/connected?reminder=` + reminder); }; - getReviews = async () => { - return this.doGet(`${this.url}/reviews`); - }; - - getYourPrs = async () => { - return this.doGet(`${this.url}/yourprs`); - }; - getPrsDetails = async (prList) => { return this.doPost(`${this.url}/prdetails`, prList); } - getYourAssignments = async () => { - return this.doGet(`${this.url}/yourassignments`); - }; + getLHSData= async () => { + return this.doGet(`${this.url}/lhs-data`); + } getMentions = async () => { return this.doGet(`${this.url}/mentions`); }; - getUnreads = async () => { - return this.doGet(`${this.url}/unreads`); - }; - getGitlabUser = async (userID) => { return this.doPost(`${this.url}/user`, {user_id: userID}); }; diff --git a/webapp/src/components/sidebar_buttons/index.js b/webapp/src/components/sidebar_buttons/index.js index ea40180c..4ad03720 100644 --- a/webapp/src/components/sidebar_buttons/index.js +++ b/webapp/src/components/sidebar_buttons/index.js @@ -2,11 +2,8 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import { - getReviews, - getUnreads, - getYourPrs, - getYourAssignments, updateRHSState, + getLHSData, } from '../../actions'; import {id} from '../../manifest'; @@ -20,10 +17,10 @@ function mapStateToProps(state) { connected: state[`plugins-${id}`].connected, username: state[`plugins-${id}`].username, clientId: state[`plugins-${id}`].clientId, - reviews: state[`plugins-${id}`].reviews, - yourPrs: state[`plugins-${id}`].yourPrs, - yourAssignments: state[`plugins-${id}`].yourAssignments, - unreads: state[`plugins-${id}`].unreads, + reviews: state[`plugins-${id}`].lhsData?.reviews, + yourPrs: state[`plugins-${id}`].lhsData?.prs, + yourAssignments: state[`plugins-${id}`].lhsData?.assignments, + unreads: state[`plugins-${id}`].lhsData?.unreads, gitlabURL: state[`plugins-${id}`].gitlabURL, org: state[`plugins-${id}`].organization, pluginServerRoute: getPluginServerRoute(state), @@ -35,11 +32,8 @@ function mapDispatchToProps(dispatch) { return { actions: bindActionCreators( { - getReviews, - getUnreads, - getYourPrs, - getYourAssignments, updateRHSState, + getLHSData, }, dispatch, ), diff --git a/webapp/src/components/sidebar_buttons/sidebar_buttons.jsx b/webapp/src/components/sidebar_buttons/sidebar_buttons.jsx index c057b522..3b4c1f17 100644 --- a/webapp/src/components/sidebar_buttons/sidebar_buttons.jsx +++ b/webapp/src/components/sidebar_buttons/sidebar_buttons.jsx @@ -21,11 +21,8 @@ export default class SidebarButtons extends React.PureComponent { pluginServerRoute: PropTypes.string.isRequired, showRHSPlugin: PropTypes.func.isRequired, actions: PropTypes.shape({ - getReviews: PropTypes.func.isRequired, - getUnreads: PropTypes.func.isRequired, - getYourPrs: PropTypes.func.isRequired, - getYourAssignments: PropTypes.func.isRequired, updateRHSState: PropTypes.func.isRequired, + getLHSData: PropTypes.func.isRequired, }).isRequired, }; @@ -59,12 +56,7 @@ export default class SidebarButtons extends React.PureComponent { } this.setState({refreshing: true}); - await Promise.all([ - this.props.actions.getReviews(), - this.props.actions.getUnreads(), - this.props.actions.getYourPrs(), - this.props.actions.getYourAssignments(), - ]); + await this.props.actions.getLHSData(); this.setState({refreshing: false}); }; diff --git a/webapp/src/reducers/index.js b/webapp/src/reducers/index.js index 93ab23f1..3cba5121 100644 --- a/webapp/src/reducers/index.js +++ b/webapp/src/reducers/index.js @@ -70,15 +70,6 @@ function clientId(state = '', action) { } } -function reviews(state = [], action) { - switch (action.type) { - case ActionTypes.RECEIVED_REVIEWS: - return action.data; - default: - return state; - } -} - function reviewDetails(state = [], action) { switch (action.type) { case ActionTypes.RECEIVED_REVIEW_DETAILS: @@ -88,15 +79,6 @@ function reviewDetails(state = [], action) { } } -function yourPrs(state = [], action) { - switch (action.type) { - case ActionTypes.RECEIVED_YOUR_PRS: - return action.data; - default: - return state; - } -} - function yourPrDetails(state = [], action) { switch (action.type) { case ActionTypes.RECEIVED_YOUR_PR_DETAILS: @@ -106,9 +88,9 @@ function yourPrDetails(state = [], action) { } } -function yourAssignments(state = [], action) { +function lhsData(state = [], action) { switch (action.type) { - case ActionTypes.RECEIVED_YOUR_ASSIGNMENTS: + case ActionTypes.RECEIVED_LHS_DATA: return action.data; default: return state; @@ -124,15 +106,6 @@ function mentions(state = [], action) { } } -function unreads(state = [], action) { - switch (action.type) { - case ActionTypes.RECEIVED_UNREADS: - return action.data; - default: - return state; - } -} - function rhsPluginAction(state = null, action) { switch (action.type) { case ActionTypes.RECEIVED_SHOW_RHS_ACTION: @@ -183,15 +156,12 @@ export default combineReducers({ username, settings, clientId, - reviews, - yourPrs, - yourAssignments, mentions, - unreads, gitlabUsers, rhsPluginAction, rhsState, yourPrDetails, reviewDetails, subscriptions, + lhsData, }); diff --git a/webapp/src/selectors/index.js b/webapp/src/selectors/index.js index f69ce9bc..f9fbc364 100644 --- a/webapp/src/selectors/index.js +++ b/webapp/src/selectors/index.js @@ -47,11 +47,11 @@ export const getSidebarData = createSelector( return { username: pluginState.username, reviewDetails: pluginState.reviewDetails, - reviews: mapPrsToDetails(pluginState.reviews, pluginState.reviewDetails), - yourPrs: mapPrsToDetails(pluginState.yourPrs, pluginState.yourPrDetails), + reviews: mapPrsToDetails(pluginState.lhsData?.reviews, pluginState.reviewDetails), + yourPrs: mapPrsToDetails(pluginState.lhsData?.prs, pluginState.yourPrDetails), yourPrDetails: pluginState.yourPrDetails, - yourAssignments: pluginState.yourAssignments, - unreads: pluginState.unreads, + yourAssignments: pluginState.lhsData?.assignments, + unreads: pluginState.lhsData?.unreads, org: pluginState.organization, gitlabURL: pluginState.gitlabURL, rhsState: pluginState.rhsState, diff --git a/webapp/src/websocket/index.js b/webapp/src/websocket/index.js index f9416751..0243c71b 100644 --- a/webapp/src/websocket/index.js +++ b/webapp/src/websocket/index.js @@ -2,10 +2,7 @@ import ActionTypes from '../action_types'; import Constants from '../constants'; import { getConnected, - getReviews, - getUnreads, - getYourPrs, - getYourAssignments, + getLHSData, } from '../actions'; import {id} from '../manifest'; @@ -49,10 +46,7 @@ export function handleReconnect(store, reminder = false) { store.getState, ); if (data && data.connected) { - getReviews()(store.dispatch, store.getState); - getUnreads()(store.dispatch, store.getState); - getYourPrs()(store.dispatch, store.getState); - getYourAssignments()(store.dispatch, store.getState); + getLHSData()(store.dispatch, store.getState); } }; } @@ -60,10 +54,7 @@ export function handleReconnect(store, reminder = false) { export function handleRefresh(store) { return () => { if (store.getState()[`plugins-${id}`].connected) { - getReviews()(store.dispatch, store.getState); - getUnreads()(store.dispatch, store.getState); - getYourPrs()(store.dispatch, store.getState); - getYourAssignments()(store.dispatch, store.getState); + getLHSData()(store.dispatch, store.getState); } }; }