gamification
gamification copied to clipboard
Fix missing / non-array user.ranks() issue on v17development/flarum-support
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:
And here's the console log showing the ranks()
trying to reverse()
which is not available since it's not an array:
Confirmed
- [X] Frontend changes: tested on a local Flarum installation.
- [X] Backend changes: tests are green (run
composer test
).
Required changes: N/A
Not sure if that's the right way to do that. But let me know if that works.
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.