tribute icon indicating copy to clipboard operation
tribute copied to clipboard

Is it possible to execute a function when a @mention is removed?

Open oliveratgithub opened this issue 7 years ago ā€¢ 7 comments

Is there a way to call a function when a @mention string is being removed from the text input by the user?

Reason: Iā€˜m building an array with IDs of users to notify as soon as they are @mentioned - however, when you remove someone afterwards, Iā€˜d need to update the array and removing the affected ID again.

Thanks for any hints

oliveratgithub avatar Nov 24 '17 08:11 oliveratgithub

There currently isn't a way to do this. I would like to add several more events to the library and this is a good candidate. I'll put this on the roadmap.

mrsweaters avatar Dec 13 '17 17:12 mrsweaters

Cool, looking forward to it! šŸ‘

So long I'm taking server-side care of possible duplicates due to the same @mentions...

oliveratgithub avatar Dec 17 '17 22:12 oliveratgithub

@mrsweaters badly needed that one. looking forward. šŸ‘šŸ‘

ejlocop avatar Apr 27 '18 13:04 ejlocop

I have a workaround which could be tweaked later as a core solution (as reference I'm using vue-tribute).

Basically I use an array to store all current mentions that gets populated from the tribute-replaced event (only storing value). Whenever the text input changes I run a check and loop through all the mentions to see if they are still in the input.

If they are not then I remove them from the array, so that the array should always be a reference point for currently mentioned users.

Here is the vue code (my input is called comment because it's used in a comment system).

watch: {
    msg: function(comment) {
      // Polyfill for tribute-removed event
      this.mentions.map( (mention, i) => {
        if (!comment.includes(`@${mention}`)) {
          this.$delete(this.mentions, i);
        }
      });
    }
}

Truemedia avatar Sep 07 '18 10:09 Truemedia

@Truemedia, wouldn't it be more performant to perform that check on submit?

neilcamm avatar Oct 04 '18 20:10 neilcamm

Waking up an old thread - did this ever go anywhere?

caramgardner avatar Jan 12 '23 16:01 caramgardner

Would be a great feature to have

Yamaha32088 avatar Mar 28 '23 12:03 Yamaha32088