Newbie needs help dispatching changes

I’m new to ProseMirror, and attempting to implement a track changes in my editor. I have format changes working but cannot figure out acceptation or rejection of deletes. Below is a summary of the function I am calling to reject the deletion, which show remove the mark, however, this is not being reflected in the view.

const reject = function(type, pos, view) { 
  const tr ="track", true)
  const map = new Mapping()

    view.state.doc.nodesBetween(pos, view.state.doc.nodeSize - 2, (node, nodePos) => {

            if (node.attrs.track) {
                const track = node.attrs.track.filter(track => track.type !== "deletion")
                tr.setNodeMarkup(, null, Object.assign({}, node.attrs, {track}), node.marks)

            } else {

           + node.nodeSize),
    if (tr.steps.length) {

If anyone to highlight what I am missing, it would be very greatly appreciated.

I managed to get the change to be reflected in the view, but by using view.state.apply(tr), instead of view.dispatch(tr). I’m not sure if that’s the correct way, however, it appears to be working at the moment. if anyone care to explain the difference between the two, I would be very grateful.