FriendsOfFlarum / byobu

Well integrated, advanced private discussions for your Flarum forum.
https://discuss.flarum.org/d/4762-flagrow-by-bu-well-integrated-advanced-private-discussions
MIT License
54 stars 33 forks source link

Starting discussion from user profile fails when using custom user slug driver #176

Closed clarkwinkelmann closed 1 year ago

clarkwinkelmann commented 1 year ago

Bug Report

Current Behavior If the slug driver is set to something different than username, Flarum will crash with a javascript error when clicking the "Start private discussion" link on a user profile

Steps to Reproduce

  1. Set user slug driver to ID
  2. Visit any user profile
  3. Use dropdown button to start private discussion with user

Error loosely transcripted from screenshot:

TypeError: Cannot read properties of undefined (reading 'id') at addDefaultRecipients (PrivateDiscussionComposer.js)

Expected Behavior Should work with any slug driver.

Screenshots If applicable, add screenshots to help explain your problem.

Environment

Output of "php flarum info", run this in terminal in your Flarum directory.

Possible solution(s) https://github.com/FriendsOfFlarum/byobu/blob/bc5dafa1987b8a8b967374f6903a3cd56c08f553/js/src/forum/pages/discussions/PrivateDiscussionComposer.js#L107

I think just replacing 'username' with 'slug' as the second parameter should fix it.

This would probably be a good opportunity to gracefully handle null being returned by getBy even though it supposedly shouldn't happen.

Additional Context Based on report here https://discuss.flarum.org/d/4762-friendsofflarum-by-bu-well-integrated-advanced-private-discussions/1166