XF 2.2 Content reactions implementation

FoxSecrets

Active member
I implemented reactions in my addon content, everything is working fine except the selected option after page reload.
I hit like, I have the infos in db, I can list all reactions, etc.

The only missing thing is the reaction I clicked, I can't see back into the Like button after page reloads, it shows the original button.

So my question is: how can I see the selected reaction back to the button?

1707699804070.webp
Controller:
Code:
  public function actionReact(ParameterBag $params)
  {
    $mycontent = $this->assertContentExists($params->mycontent_id);
    /** @var \XF\ControllerPlugin\Reaction $reactionPlugin */
    $reactionPlugin = $this->plugin('XF:Reaction');
    return $reactionPlugin->actionReactSimple($mycontent, 'my-content');
  }

  public function actionReactions(ParameterBag $params)
  {
    $mycontent = $this->assertContentExists($params->profile_id);
    $title = \XF::phrase('who_reacted_x', ['mycontent' => ($mycontent->username)]);
    /** @var \XF\ControllerPlugin\Reaction $reactionPlugin */
    $reactionPlugin = $this->plugin('XF:Reaction');
    return $reactionPlugin->actionReactions(
      $mycontent,
      'my-content/reactions',
      $title
    );
  }
 
Top Bottom