11import { autoEffect , clearEffect , store } from '@risingstack/react-easy-state' ;
22import { IMRWebViewDetail } from 'src/typings/commonTypes' ;
3- import { IActivity , IReviewer , IComment } from 'src/typings/respResult' ;
3+ import { IActivity , IComment , IMRReviewers } from 'src/typings/respResult' ;
44import { vscode } from 'webviews/constants/vscode' ;
55import { actions } from 'webviews/store/constants' ;
66import { MERGE_STATUS } from 'webviews/constants/mergeRequest' ;
77import { getMessageHandler } from 'webviews/utils/message' ;
88
9- interface IReviewers {
10- volunteer_reviewers : IReviewer [ ] ;
11- reviewers : IReviewer [ ] ;
12- }
13-
149const appStore = store ( {
1510 currentMR : ( vscode . getState ( ) ?. currentMR || { } ) as IMRWebViewDetail ,
1611 activities : ( vscode . getState ( ) ?. activities || [ ] ) as IActivity [ ] ,
1712 reviewers : ( vscode . getState ( ) ?. reviewers || {
1813 volunteer_reviewers : [ ] ,
1914 reviewers : [ ] ,
20- } ) as IReviewers ,
15+ } ) as IMRReviewers ,
2116 comments : ( vscode . getState ( ) ?. comments || [ ] ) as IComment [ ] ,
2217 updateCurrentMR ( data : IMRWebViewDetail ) {
2318 appStore . currentMR = data ;
2419 } ,
2520 updateMRActivities ( data : IActivity [ ] ) {
2621 appStore . activities = data ;
2722 } ,
28- updateMRReviewers ( data : IReviewers ) {
23+ updateMRReviewers ( data : IMRReviewers ) {
2924 appStore . reviewers = data ;
3025 } ,
3126 updateMRComments ( data : IComment [ ] ) {
@@ -115,11 +110,12 @@ const appStore = store({
115110 return result ;
116111 } ,
117112 async updateReviewers ( iid : string , list : number [ ] ) {
118- const result = await getMessageHandler ( appStore . messageHandler ) ( ) . postMessage ( {
113+ const resp = await getMessageHandler ( appStore . messageHandler ) ( ) . postMessage ( {
119114 command : actions . MR_UPDATE_REVIEWERS ,
120- args : [ iid , list ] ,
115+ args : { iid, list } ,
121116 } ) ;
122- return result ;
117+ appStore . reviewers = resp ;
118+ return ;
123119 } ,
124120 toggleUpdatingDesc ( status ?: boolean ) {
125121 if ( typeof status === `undefined` ) {
@@ -149,8 +145,11 @@ const appStore = store({
149145 addComment ( comment : IComment ) {
150146 appStore . comments . push ( comment ) ;
151147 } ,
148+ initMRReviewers ( list : IMRReviewers ) {
149+ appStore . reviewers = list ;
150+ } ,
152151 messageHandler ( message : any ) {
153- const { updateMRActivities, updateMRReviewers , updateMRComments } = appStore ;
152+ const { updateMRActivities, updateMRComments } = appStore ;
154153 const { command, res } = message ;
155154
156155 switch ( command ) {
@@ -162,10 +161,6 @@ const appStore = store({
162161 updateMRComments ( res ) ;
163162 break ;
164163 }
165- case actions . MR_UPDATE_REVIEWERS : {
166- res && updateMRReviewers ( res ) ;
167- break ;
168- }
169164 case actions . MR_ADD_COMMENT : {
170165 }
171166 default :
0 commit comments