IssueNotesRefactor: Support legacy multiple notes for individual_note: true case.

This commit is contained in:
Fatih Acet 2017-08-22 22:10:35 +03:00
parent 479670df94
commit d051621604
1 changed files with 16 additions and 1 deletions

View File

@ -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) {