Commit a2cba2b1 authored by Fatih Acet's avatar Fatih Acet

IssueNotesRefactor: Use notesById getter.

parent 993936fb
...@@ -16,6 +16,17 @@ const getters = { ...@@ -16,6 +16,17 @@ const getters = {
targetNoteHash(storeState) { targetNoteHash(storeState) {
return storeState.targetNoteHash; return storeState.targetNoteHash;
}, },
notesById(storeState) {
const notesById = {};
storeState.notes.forEach((note) => {
note.notes.forEach((n) => {
notesById[n.id] = n;
});
});
return notesById;
},
}; };
const mutations = { const mutations = {
...@@ -131,14 +142,7 @@ const actions = { ...@@ -131,14 +142,7 @@ const actions = {
.then(res => res.json()) .then(res => res.json())
.then((res) => { .then((res) => {
if (res.notes.length) { if (res.notes.length) {
const notesById = {}; const { notesById } = context.getters;
// 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;
});
});
res.notes.forEach((note) => { res.notes.forEach((note) => {
if (notesById[note.id]) { if (notesById[note.id]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment