@@ -82,35 +82,14 @@ const milestoneUpdatedHandler = Promise.coroutine(function* (logger, msg, channe
8282 } ) ;
8383 }
8484
85- // if (data.original.order !== data.updated.order) {
86- // const milestoneWithSameOrder =
87- // _.find(milestones, milestone => milestone.id !== data.updated.id && milestone.order === data.updated.order);
88- // if (milestoneWithSameOrder) {
89- // // Increase the order from M to K: if there is an item with order K,
90- // // orders from M+1 to K should be made M to K-1
91- // if (data.original.order < data.updated.order) {
92- // _.each(milestones, (single) => {
93- // if (single.id !== data.updated.id
94- // && (data.original.order + 1) <= single.order
95- // && single.order <= data.updated.order) {
96- // single.order -= 1; // eslint-disable-line no-param-reassign
97- // }
98- // });
99- // } else {
100- // // Decrease the order from M to K: if there is an item with order K,
101- // // orders from K to M-1 should be made K+1 to M
102- // _.each(milestones, (single) => {
103- // if (single.id !== data.updated.id
104- // && data.updated.order <= single.order
105- // && single.order <= (data.original.order - 1)) {
106- // single.order += 1; // eslint-disable-line no-param-reassign
107- // }
108- // });
109- // }
110- // }
111- // }
85+ let updatedTimeline = doc . _source ; // eslint-disable-line no-underscore-dangle
86+ // if timeline has been modified during milestones updates
87+ if ( data . cascadedUpdates && data . cascadedUpdates . timeline && data . cascadedUpdates . timeline . updated ) {
88+ // merge updated timeline with the object in ES index, the same way as we do when updating timeline in ES using timeline endpoints
89+ updatedTimeline = _ . merge ( doc . _source , data . cascadedUpdates . timeline . updated ) ; // eslint-disable-line no-underscore-dangle
90+ }
11291
113- const merged = _ . assign ( doc . _source , { milestones } ) ; // eslint-disable-line no-underscore-dangle
92+ const merged = _ . assign ( updatedTimeline , { milestones } ) ;
11493 yield eClient . update ( {
11594 index : ES_TIMELINE_INDEX ,
11695 type : ES_TIMELINE_TYPE ,
0 commit comments