jovotech / jovo-framework

🔈 The React for Voice and Chat: Build Apps for Alexa, Messenger, Instagram, the Web, and more
https://www.jovo.tech
Apache License 2.0
1.67k stars 310 forks source link

:bug: Removed false positive duplicate global handler issue #1629

Closed sadlowskij closed 2 months ago

sadlowskij commented 3 months ago

Proposed Changes

This commit stops the same handler to be added to globalHandlerMap twice. This lead to an error, where it reported a duplicate handler even though it was the same handler twice. This can happen with intentMaps, e. g. you have an intentMap like this:

  routing: {
    intentMap: {
      'AMAZON.HelpIntent': 'HelpIntent',
    }
  },

and a handler like this:

  @Handle({global: true, intents: ['HelpIntent', 'AMAZON.HelpIntent']})
  help(): Promise<void> {
    throw new Error('just a test');
  }

I am aware that in most cases, you should just not use AMAZON.HelpIntent in the intents array and it works just fine. However, if you are using one and the same component in multiple projects that might have different intentmaps, this might actually make things easier. Also, even though this might not be the best implementation, I don't think it was intended to treat the same handler as duplicate in this specific scenario in the first place.

Types of Changes

Checklist