Instead of re-building the entire list of messages everytime, replace `getMessageId` with this: 

```js
function getMessage(target) {
  var node = target;
  do {
    if (node.dataset && node.dataset.messageId) {
      return {
        id: +node.dataset.messageId,
        node: node
      };
    }
  } while (node = node.parentNode);

  return null;
}
```

And then delete the relevant node:

```js

var message = getMessage(event.target);

if (message === null) {
  return;
}

// ... make params etc...

ThreadUI.removeMessageDOM(message.node);

```


document.