BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
7b093581
Commit
7b093581
authored
Aug 02, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Fix emoji being posted twice originating an error
parent
d8ebcb74
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
42 deletions
+23
-42
issue_note.vue
app/assets/javascripts/notes/components/issue_note.vue
+1
-0
issue_note_awards_list.vue
...s/javascripts/notes/components/issue_note_awards_list.vue
+9
-3
issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+1
-3
actions.js
app/assets/javascripts/notes/stores/actions.js
+7
-28
mutations.js
app/assets/javascripts/notes/stores/mutations.js
+5
-8
No files found.
app/assets/javascripts/notes/components/issue_note.vue
View file @
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
View file @
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
)
=>
{
Object
.
assign
(
acc
,
{[
award
.
name
]:
[
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
View file @
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
View file @
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
View file @
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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment