Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
c4381067
Commit
c4381067
authored
Aug 10, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Improve performance of getting last note
parent
3e0a76da
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
app/assets/javascripts/notes/stores/getters.js
app/assets/javascripts/notes/stores/getters.js
+8
-10
No files found.
app/assets/javascripts/notes/stores/getters.js
View file @
c4381067
import
_
from
'
underscore
'
;
export
const
notes
=
state
=>
state
.
notes
;
export
const
targetNoteHash
=
state
=>
state
.
targetNoteHash
;
...
...
@@ -16,15 +18,11 @@ export const notesById = state => state.notes.reduce((acc, note) => {
},
{});
const
reverseNotes
=
array
=>
array
.
slice
(
0
).
reverse
();
const
isLastNote
=
(
note
,
userId
)
=>
!
note
.
system
&&
note
.
author
.
id
===
userId
;
export
const
getCurrentUserLastNote
=
state
=>
userId
=>
reverseNotes
(
state
.
notes
)
.
reduce
((
acc
,
note
)
=>
{
acc
.
push
(
reverseNotes
(
note
.
notes
).
find
(
el
=>
isLastNote
(
el
,
userId
)));
return
acc
;
},
[]).
filter
(
el
=>
el
!==
undefined
)[
0
];
const
isLastNote
=
(
note
,
state
)
=>
!
note
.
system
&&
note
.
author
.
id
===
state
.
userData
.
id
;
// eslint-disable-next-line no-unused-vars
export
const
getDiscussionLastNote
=
state
=>
(
discussion
,
userId
)
=>
reverseNotes
(
discussion
.
notes
)
.
find
(
el
=>
isLastNote
(
el
,
userId
));
export
const
getCurrentUserLastNote
=
state
=>
_
.
flatten
(
reverseNotes
(
state
.
notes
)
.
map
(
note
=>
note
.
notes
)
)
.
find
(
el
=>
isLastNote
(
el
,
state
));
export
const
getDiscussionLastNote
=
state
=>
discussion
=>
reverseNotes
(
discussion
.
notes
)
.
find
(
el
=>
isLastNote
(
el
,
state
));
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