Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一杯枸杞茶ya
csdn-workflow
提交
89b1fee3
C
csdn-workflow
项目概览
一杯枸杞茶ya
/
csdn-workflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
csdn-workflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
89b1fee3
编写于
12月 10, 2020
作者:
K
Kev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: label notes dissapear after submitting a comment
上级
cd9315af
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
44 addition
and
18 deletion
+44
-18
src/gitlab_service.ts
src/gitlab_service.ts
+40
-4
src/webview_controller.js
src/webview_controller.js
+4
-14
未找到文件。
src/gitlab_service.ts
浏览文件 @
89b1fee3
...
...
@@ -482,8 +482,15 @@ export async function validateCIConfig(content: string) {
return
validCIConfig
;
}
export
async
function
fetchLabelEvents
(
issuable
:
RestIssuable
)
{
let
labelEvents
:
{
body
:
string
}[]
=
[];
interface
LabelEvent
{
label
:
unknown
;
body
:
string
;
// eslint-disable-next-line camelcase
created_at
:
string
;
}
export
async
function
fetchLabelEvents
(
issuable
:
RestIssuable
):
Promise
<
LabelEvent
[]
>
{
let
labelEvents
:
LabelEvent
[]
=
[];
try
{
const
type
=
issuable
.
sha
?
'
merge_requests
'
:
'
issues
'
;
...
...
@@ -503,8 +510,15 @@ export async function fetchLabelEvents(issuable: RestIssuable) {
return
labelEvents
;
}
export
async
function
fetchDiscussions
(
issuable
:
RestIssuable
,
page
=
1
)
{
let
discussions
:
unknown
[]
=
[];
interface
Discussion
{
notes
:
{
// eslint-disable-next-line camelcase
created_at
:
string
;
}[];
}
export
async
function
fetchDiscussions
(
issuable
:
RestIssuable
,
page
=
1
):
Promise
<
Discussion
[]
>
{
let
discussions
:
Discussion
[]
=
[];
try
{
const
type
=
issuable
.
sha
?
'
merge_requests
'
:
'
issues
'
;
...
...
@@ -579,3 +593,25 @@ export async function saveNote(params: {
return
{
success
:
false
};
}
type
note
=
Discussion
|
LabelEvent
;
function
isLabelEvent
(
object
:
any
):
object
is
LabelEvent
{
return
Boolean
(
object
.
label
);
}
export
async
function
fetchDiscussionsAndLabelEvents
(
issuable
:
RestIssuable
):
Promise
<
note
[]
>
{
const
[
discussions
,
labelEvents
]
=
await
Promise
.
all
([
fetchDiscussions
(
issuable
),
fetchLabelEvents
(
issuable
),
]);
const
combinedEvents
:
note
[]
=
[...
discussions
,
...
labelEvents
];
combinedEvents
.
sort
((
a
:
note
,
b
:
note
)
=>
{
const
aCreatedAt
=
isLabelEvent
(
a
)
?
a
.
created_at
:
a
.
notes
[
0
].
created_at
;
const
bCreatedAt
=
isLabelEvent
(
b
)
?
b
.
created_at
:
b
.
notes
[
0
].
created_at
;
return
aCreatedAt
<
bCreatedAt
?
-
1
:
1
;
});
return
combinedEvents
;
}
src/webview_controller.js
浏览文件 @
89b1fee3
...
...
@@ -84,8 +84,8 @@ const createMessageHandler = (panel, issuable, workspaceFolder) => async message
});
if
(
response
.
success
!==
false
)
{
const
newDiscussions
=
await
gitLabService
.
fetchDiscussion
s
(
issuable
);
panel
.
webview
.
postMessage
({
type
:
'
issuableFetch
'
,
issuable
,
discussions
:
newDiscussions
});
const
discussions
=
await
gitLabService
.
fetchDiscussionsAndLabelEvent
s
(
issuable
);
panel
.
webview
.
postMessage
({
type
:
'
issuableFetch
'
,
issuable
,
discussions
});
panel
.
webview
.
postMessage
({
type
:
'
noteSaved
'
});
}
else
{
panel
.
webview
.
postMessage
({
type
:
'
noteSaved
'
,
status
:
false
});
...
...
@@ -105,19 +105,9 @@ async function handleChangeViewState(panel, issuable) {
});
});
const
[
discussions
,
labelEvents
]
=
await
Promise
.
all
([
gitLabService
.
fetchDiscussions
(
issuable
),
gitLabService
.
fetchLabelEvents
(
issuable
),
]);
const
combinedEvents
=
discussions
.
concat
(
labelEvents
);
combinedEvents
.
sort
((
a
,
b
)
=>
{
const
aCreatedAt
=
a
.
label
?
a
.
created_at
:
a
.
notes
[
0
].
created_at
;
const
bCreatedAt
=
b
.
label
?
b
.
created_at
:
b
.
notes
[
0
].
created_at
;
return
aCreatedAt
<
bCreatedAt
?
-
1
:
1
;
});
const
discussonsAndLabels
=
await
gitLabService
.
fetchDiscussionsAndLabelEvents
(
issuable
);
await
appReadyPromise
;
panel
.
webview
.
postMessage
({
type
:
'
issuableFetch
'
,
issuable
,
discussions
:
combinedEvent
s
});
panel
.
webview
.
postMessage
({
type
:
'
issuableFetch
'
,
issuable
,
discussions
:
discussonsAndLabel
s
});
}
const
getIconPathForIssuable
=
issuable
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录