Skip to content

Remove unused awards `checkMutuality` method

Problem

The checkMutuality method in awards_handler.js appears to no longer be used,

Background

The following discussion from !141930 (merged) should be addressed:

  • @lorenzvanherwaarden started a discussion: (+1 comment)

    question (non-blocking): were you able to test this case @annabeldunstone? I was trying to but I think checkMutuality() never gets called because checkForMutuality argument in the addAwardToEmojiBar function is always false or undefined.

    Here's a mermaid diagram of the functions calling each other in awards_handler.js that are related to checkMutuality (The nodes are functions):

    graph TD
        bindEvents -->|checkForMutuality: undefined| addAward
        addAward -->|checkForMutuality| addAwardToEmojiBar
        addAwardToEmojiBar -.->|only called when checkForMutuality is truthy or null| checkMutuality
        checkMutuality -->|checkForMutuality: false| addAward

    However, this is not really related to this MR, so I think we could do the cleanup in a follow-up.

    I also don't think the callback argument in addAward is ever set.

    P.S.: sometimes checkMutuality is used as the argument name instead of checkForMutuality, but I simplified it for some consistency in the diagram and explanation so I'm always referencing checkForMutuality as the argument and checkMutuality as the function.

  • @ekigbo response

    AFAICT addAwardToEmojiBar is called with a checkMutuality parameter in the addAward method, but none of the calls to addAward (except in tests) actually set a value for the checkMutuality parameter (except in the checkMutuality method itself where it is given false), so i dont think this is used anymore 🤔.

    Furthermore, if i'm reading this correctly, I think the aim is to ensure you can't react with both thumbsup AND thumbsdown, but it looks like that isnt working

    Screenshot_2024-01-22_at_4.22.16_pm.

Implementation guide

  1. In awards_handler.js:
    1. Remove checkMutuality() method
    2. Remove checkMutuality and checkForMutuality arguments of addAward() and addAwardToEmojiBar() methods and make sure that code calling these methods don't pass those mutuality arguments.
    3. Remove calls to checkMutuality()
  2. Adapt awards_handler_spec.js so it reflects the changes made in awards_handler.js
Edited by Lorenz van Herwaarden