From d0516216049e3231ab23a0f610940af615f1d9a3 Mon Sep 17 00:00:00 2001 From: Fatih Acet Date: Tue, 22 Aug 2017 22:10:35 +0300 Subject: [PATCH] IssueNotesRefactor: Support legacy multiple notes for individual_note: true case. --- .../javascripts/notes/stores/mutations.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/notes/stores/mutations.js b/app/assets/javascripts/notes/stores/mutations.js index ce56fe74b1e..3b2b2089d6e 100644 --- a/app/assets/javascripts/notes/stores/mutations.js +++ b/app/assets/javascripts/notes/stores/mutations.js @@ -70,7 +70,22 @@ export default { Object.assign(state, { userData: data }); }, [types.SET_INITIAL_NOTES](state, notesData) { - Object.assign(state, { notes: notesData }); + const notes = []; + + notesData.forEach((note) => { + // To support legacy notes, should be very rare case. + if (note.individual_note && note.notes.length > 1) { + note.notes.forEach((n) => { + const nn = Object.assign({}, note); + nn.notes = [n]; // override notes array to only have one item to mimick individual_note + notes.push(nn); + }); + } else { + notes.push(note); + } + }); + + Object.assign(state, { notes }); }, [types.SET_LAST_FETCHED_AT](state, fetchedAt) { -- GitLab