Commit a2cba2b1 authored by Fatih Acet's avatar Fatih Acet

IssueNotesRefactor: Use notesById getter.

parent 993936fb
......@@ -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]) {
......
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