Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
clarkwinkelmann opened this issue Aug 27, 2022 · 0 comments · Fixed by #182
Closed
Labels

Comments

@clarkwinkelmann
Copy link
Member

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

  • Flarum version: 1.4.0
  • Extension version: master
Output of "php flarum info", run this in terminal in your Flarum directory.

Possible solution(s)

const user = app.store.getBy('users', 'username', username);

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

@imorland imorland mentioned this issue Mar 24, 2023
3 tasks
imorland added a commit that referenced this issue Mar 24, 2023
@imorland imorland linked a pull request Mar 24, 2023 that will close this issue
3 tasks
imorland added a commit that referenced this issue Mar 24, 2023
* chore: use frontend extenders

* fix: use  rather than  #179

* fix: search user by slug #176

* chore: remove console.log()

* chore: return types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant