Skip to content

Commit 8ce22e1

Browse files
committed
feat(mr): activities.
1 parent 2b188e0 commit 8ce22e1

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export async function activate(context: vscode.ExtensionContext) {
5858
});
5959
});
6060
codingSrv.getMRActivities(mr.iid).then((activityResp) => {
61-
Panel.currentPanel?.broadcast(`mr.update.activities`, activityResp.data);
61+
Panel.currentPanel?.broadcast(`mr.activities.init`, activityResp.data);
6262
});
6363
codingSrv.getMRReviewers(mr.iid).then((reviewerResp) => {
6464
Panel.currentPanel?.broadcast(`mr.reviewers.init`, reviewerResp.data);

webviews/hooks/messageTransferHook.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { actions } from 'webviews/store/constants';
55
export default function messageTransferHook() {
66
useEffect(() => {
77
window.addEventListener('message', (ev) => {
8-
const { updateCurrentMR, toggleMRLoading, initMRReviewers } = appStore;
8+
const { updateCurrentMR, toggleMRLoading, initMRReviewers, initMRActivities } = appStore;
99
const { command, res } = ev?.data;
1010

1111
switch (command) {
@@ -21,6 +21,10 @@ export default function messageTransferHook() {
2121
initMRReviewers(res);
2222
break;
2323
}
24+
case actions.MR_ACTIVITIES_INIT: {
25+
initMRActivities(res);
26+
break;
27+
}
2428
default:
2529
break;
2630
}

webviews/store/appStore.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const appStore = store({
115115
args: { iid, list },
116116
});
117117
appStore.reviewers = resp;
118-
return;
118+
appStore.refreshMRActivities();
119119
},
120120
toggleUpdatingDesc(status?: boolean) {
121121
if (typeof status === `undefined`) {
@@ -141,22 +141,22 @@ const appStore = store({
141141
appStore.currentMR.data.merge_request.body = resp.body;
142142
appStore.currentMR.data.merge_request.body_plan = resp.body_plan;
143143
appStore.toggleUpdatingDesc(false);
144+
appStore.refreshMRActivities();
144145
},
145146
addComment(comment: IComment) {
146147
appStore.comments.push(comment);
147148
},
148149
initMRReviewers(list: IMRReviewers) {
149150
appStore.reviewers = list;
150151
},
152+
initMRActivities(data: IActivity[]) {
153+
appStore.updateMRActivities(data);
154+
},
151155
messageHandler(message: any) {
152-
const { updateMRActivities, updateMRComments } = appStore;
156+
const { updateMRComments } = appStore;
153157
const { command, res } = message;
154158

155159
switch (command) {
156-
case actions.UPDATE_MR_ACTIVITIES: {
157-
updateMRActivities(res);
158-
break;
159-
}
160160
case actions.MR_UPDATE_COMMENTS: {
161161
updateMRComments(res);
162162
break;

webviews/store/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export enum actions {
22
UPDATE_CURRENT_MR = `mr.update`,
3-
UPDATE_MR_ACTIVITIES = `mr.update.activities`,
43
CLOSE_MR = `mr.close`,
54
MR_APPROVE = `mr.approve`,
65
MR_DISAPPROVE = `mr.disapprove`,
@@ -13,4 +12,5 @@ export enum actions {
1312
MR_UPDATE_REVIEWERS = `mr.update.reviewers`,
1413
MR_UPDATE_DESC = `mr.update.desc`,
1514
MR_REVIEWERS_INIT = `mr.reviewers.init`,
15+
MR_ACTIVITIES_INIT = `mr.activities.init`,
1616
}

0 commit comments

Comments
 (0)