summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2017-07-07 23:54:34 +0300
committerFatih Acet <acetfatih@gmail.com>2017-07-21 22:35:25 +0300
commita2cba2b1ef7d408c4fd573f838adbc2b45fde4cc (patch)
treeb845cde44feb6cec6d156e3e360090583ed85663
parent993936fbd0ea62acb37da865767a1e67bea5cc1f (diff)
downloadgitlab-ce-a2cba2b1ef7d408c4fd573f838adbc2b45fde4cc.tar.gz
IssueNotesRefactor: Use notesById getter.
-rw-r--r--app/assets/javascripts/notes/stores/issue_notes_store.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/app/assets/javascripts/notes/stores/issue_notes_store.js b/app/assets/javascripts/notes/stores/issue_notes_store.js
index f6af52ec364..6f3dd24cad3 100644
--- a/app/assets/javascripts/notes/stores/issue_notes_store.js
+++ b/app/assets/javascripts/notes/stores/issue_notes_store.js
@@ -16,6 +16,17 @@ const getters = {
targetNoteHash(storeState) {
return storeState.targetNoteHash;
},
+ notesById(storeState) {
+ const notesById = {};
+
+ storeState.notes.forEach((note) => {
+ note.notes.forEach((n) => {
+ notesById[n.id] = n;
+ });
+ });
+
+ return notesById;
+ },
};
const mutations = {
@@ -131,14 +142,7 @@ const actions = {
.then(res => res.json())
.then((res) => {
if (res.notes.length) {
- const notesById = {};
-
- // Simple lookup object to check whether we have a discussion id already in our store
- context.state.notes.forEach((note) => {
- note.notes.forEach((n) => {
- notesById[n.id] = true;
- });
- });
+ const { notesById } = context.getters;
res.notes.forEach((note) => {
if (notesById[note.id]) {