gamification icon indicating copy to clipboard operation
gamification copied to clipboard

Fix missing / non-array user.ranks() issue on v17development/flarum-support

Open hackeresq opened this issue 1 year ago • 2 comments

Related to v17development/flarum-support-feedback#14 which causes support page to break.

Changes proposed in this pull request: This change adds a conditional check to make sure the user.ranks() is actually loaded. If the rank is falsey, it does not try to add user rank to the PostUser view.

Reviewers should focus on:

    if (user.ranks()) { // <-- added this conditional
      header_node.children = header_node.children
        .concat(
          user
            .ranks()
            .reverse()
            .splice(0, amt)
            .map((rank) => {
              return <span className="Post-Rank">{rankLabel(rank)}</span>;
            })
        )
        .filter(function (el) {
          return el.tag !== undefined;
        });
    }

Screenshot This is how the support tickets page was breaking: image

And here's the console log showing the ranks() trying to reverse() which is not available since it's not an array: image

Confirmed

  • [X] Frontend changes: tested on a local Flarum installation.
  • [X] Backend changes: tests are green (run composer test).

Required changes: N/A

hackeresq avatar Dec 05 '23 18:12 hackeresq

Not sure if that's the right way to do that. But let me know if that works.

hackeresq avatar Dec 13 '23 00:12 hackeresq

Hi @hackerESQ thanks for your contribution! This branch still has conflicts that must be resolved. I suggest that you git reset the branch back to the first commit you made and then force push to remote.

DavideIadeluca avatar Feb 29 '24 18:02 DavideIadeluca