Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7b093581
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7b093581
编写于
8月 02, 2017
作者:
F
Filipa Lacerda
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ci skip] Fix emoji being posted twice originating an error
上级
d8ebcb74
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
23 addition
and
42 deletion
+23
-42
app/assets/javascripts/notes/components/issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+1
-0
app/assets/javascripts/notes/components/issue_note_awards_list.vue
...s/javascripts/notes/components/issue_note_awards_list.vue
+9
-3
app/assets/javascripts/notes/components/issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+1
-3
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+7
-28
app/assets/javascripts/notes/stores/mutations.js
app/assets/javascripts/notes/stores/mutations.js
+5
-8
未找到文件。
app/assets/javascripts/notes/components/issue_note.vue
浏览文件 @
7b093581
...
...
@@ -119,6 +119,7 @@
class=
"note timeline-entry"
:id=
"noteAnchorId"
:class=
"classNameBindings"
:data-award-url=
"note.toggle_award_path"
:note-id=
"note.id"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-icon"
>
...
...
app/assets/javascripts/notes/components/issue_note_awards_list.vue
浏览文件 @
7b093581
...
...
@@ -52,7 +52,12 @@
// We need to do this otherwise we will render the same emoji over and over again.
groupedAwards
()
{
const
awards
=
this
.
awards
.
reduce
((
acc
,
award
)
=>
{
if
(
acc
.
hasOwnProperty
(
award
.
name
))
{
acc
[
award
.
name
].
push
(
award
);
}
else
{
Object
.
assign
(
acc
,
{[
award
.
name
]:
[
award
]});
}
return
acc
;
},
{});
...
...
@@ -67,6 +72,7 @@
orderedAwards
.
thumbsdown
=
thumbsdown
;
delete
awards
.
thumbsdown
;
}
return
Object
.
assign
({},
orderedAwards
,
awards
);
},
isAuthoredByMe
()
{
...
...
@@ -75,7 +81,7 @@
},
methods
:
{
...
mapActions
([
'
toggleAward
'
,
'
toggleAward
Request
'
,
]),
getAwardHTML
(
name
)
{
return
Emoji
.
glEmojiTag
(
name
);
...
...
@@ -147,7 +153,7 @@
awardName
:
awardName
===
"
100
"
?
100
:
awardName
,
};
this
.
toggleAward
(
data
)
this
.
toggleAward
Request
(
data
)
.
catch
(()
=>
Flash
(
'
Something went wrong on our end.
'
));
},
},
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
浏览文件 @
7b093581
...
...
@@ -99,10 +99,8 @@
bindEventHubListeners
()
{
this
.
$el
.
parentElement
.
addEventListener
(
'
toggleAward
'
,
(
event
)
=>
{
const
{
awardName
,
noteId
}
=
event
.
detail
;
const
endpoint
=
this
.
notesById
[
noteId
].
toggle_award_path
;
this
.
actionToggleAward
({
awardName
,
noteId
})
this
.
actionToggleAward
({
endpoint
,
awardName
,
noteId
})
.
catch
((
error
)
=>
Flash
(
'
Something went wrong on our end.
'
));
});
// JQuery is needed here because it is a custom event being dispatched with jQuery.
...
...
app/assets/javascripts/notes/stores/actions.js
浏览文件 @
7b093581
...
...
@@ -174,7 +174,7 @@ export const poll = ({ commit, state, getters }) => {
if
(
!
Visibility
.
hidden
())
{
eTagPoll
.
makeRequest
();
}
else
{
this
.
service
.
poll
(
requestData
);
service
.
poll
(
requestData
);
}
Visibility
.
change
(()
=>
{
...
...
@@ -186,38 +186,17 @@ export const poll = ({ commit, state, getters }) => {
});
};
export
const
toggleAward
=
({
commit
,
getters
,
dispatch
},
data
)
=>
{
co
nst
{
endpoint
,
awardName
,
noteId
,
skipMutalityCheck
}
=
data
;
const
note
=
getters
.
notesById
[
noteId
]
;
export
const
toggleAward
=
({
commit
,
state
,
getters
,
dispatch
},
{
awardName
,
noteId
}
)
=>
{
co
mmit
(
types
.
TOGGLE_AWARD
,
{
awardName
,
note
:
getters
.
notesById
[
noteId
]
})
;
}
;
export
const
toggleAwardRequest
=
({
commit
,
getters
,
dispatch
},
data
)
=>
{
const
{
endpoint
,
awardName
}
=
data
;
return
service
.
toggleAward
(
endpoint
,
{
name
:
awardName
})
.
then
(
res
=>
res
.
json
())
.
then
(()
=>
{
commit
(
types
.
TOGGLE_AWARD
,
{
awardName
,
note
});
if
(
!
skipMutalityCheck
&&
(
awardName
===
constants
.
EMOJI_THUMBSUP
||
awardName
===
constants
.
EMOJI_THUMBSDOWN
))
{
const
counterAward
=
awardName
===
constants
.
EMOJI_THUMBSUP
?
constants
.
EMOJI_THUMBSDOWN
:
constants
.
EMOJI_THUMBSUP
;
const
targetNote
=
getters
.
notesById
[
noteId
];
let
noteHasAwardByCurrentUser
=
false
;
targetNote
.
award_emoji
.
forEach
((
a
)
=>
{
if
(
a
.
name
===
counterAward
&&
a
.
user
.
id
===
window
.
gon
.
current_user_id
)
{
noteHasAwardByCurrentUser
=
true
;
}
});
if
(
noteHasAwardByCurrentUser
)
{
Object
.
assign
(
data
,
{
awardName
:
counterAward
});
Object
.
assign
(
data
,
{
skipMutalityCheck
:
true
});
dispatch
(
types
.
TOGGLE_AWARD
,
data
);
}
}
dispatch
(
'
toggleAward
'
,
data
);
});
};
...
...
app/assets/javascripts/notes/stores/mutations.js
浏览文件 @
7b093581
...
...
@@ -102,16 +102,13 @@ export default {
[
types
.
TOGGLE_AWARD
](
state
,
data
)
{
const
{
awardName
,
note
}
=
data
;
const
{
id
,
name
,
username
}
=
state
.
userData
;
let
index
=
-
1
;
note
.
award_emoji
.
forEach
((
a
,
i
)
=>
{
if
(
a
.
name
===
awardName
&&
a
.
user
.
id
===
id
)
{
index
=
i
;
}
});
const
hasEmojiAwardedByCurrentUser
=
note
.
award_emoji
.
filter
(
emoji
=>
emoji
.
name
===
data
.
awardName
&&
emoji
.
user
.
id
===
id
);
if
(
index
>
-
1
)
{
// If current user has awarded this emoji, remove it.
note
.
award_emoji
.
splice
(
index
,
1
);
if
(
hasEmojiAwardedByCurrentUser
.
length
)
{
// If current user has awarded this emoji, remove it.
note
.
award_emoji
.
splice
(
note
.
award_emoji
.
indexOf
(
hasEmojiAwardedByCurrentUser
[
0
]),
1
);
}
else
{
note
.
award_emoji
.
push
({
name
:
awardName
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录