diff --git a/assets/js/ordering/pointers.js b/assets/js/ordering/pointers.js index 94836d34d4..4f63e98616 100644 --- a/assets/js/ordering/pointers.js +++ b/assets/js/ordering/pointers.js @@ -113,23 +113,16 @@ export class Pointers extends Component { const { title, defaultResults } = this.state; let merged = defaultResults[title].slice(); - const setIds = {}; - merged.forEach((item) => { - setIds[item.ID] = item; - }); - pointers = pointers.sort((a, b) => { return a.order > b.order ? 1 : -1; }); + const pointersIds = pointers.map((pointer) => pointer.ID); - pointers.forEach((pointer) => { - // Remove the original if a duplicate - if (setIds[pointer.ID]) { - delete merged[merged.indexOf(setIds[pointer.ID])]; - merged = merged.filter((item) => item); - } + // Remove all custom pointers from the default results + merged = merged.filter((item) => pointersIds.indexOf(item.ID) === -1); - // Insert into proper location + // Insert pointers into their proper location + pointers.forEach((pointer) => { merged.splice(parseInt(pointer.order, 10) - 1, 0, pointer); });